Chris Cavanagh’s Silverlight Physics Simulator


Chris Cavanagh, physics modeler extraordinaire, has created a Silverlight based physics modeler.  This is a fun sample to play with but I noticed in his blog post that he’s using the HtmlTimer.  This class is a wrapper on the javascript setInterval method and as such has a relatively low priority for calling back to the user.  This is why the class is marked obsolete.  The best way to build a high priority timer in the Silverlight v1.1 alpha is to use a XAML animation and hook it’s completed event.  The Lumines video player I wrote uses this.  I’ve let Chris know about this trick and hopefully he’ll incorporate this.  I have a feeling this is the cause of the stuttering he’s seeing.  In v1.1 we will be adding a proper timer class to replace the HtmlTimer.


Click the image below to run the sample.  More info and a promise of source code can be found in Chris’ blog post.



Comments (6)

  1. BobStrogg says:

    I’ve changed the demo to use a Storyboard (much nicer) and the source code is now available!

    http://chriscavanagh.wordpress.com/2007/05/24/silverlight-2d-physics-source-code/

  2. samirsshah says:

    This simulater started me thinking about arcade games (the simulater looks a lot like an arcade game). Silverlight may be used to port 2D arcade games from XBox.

  3. Silverlight news – May 27,2007

  4. Page Brooks says:

    Silverlight 2 has a Timer (DispatcherTimer)