Domanda

i want to ask if i want to create agame loop for controling motion in my 2D Silverlight game ( sample game like snake) which will run on Windows Phone , what is the best practice to do this ? i found different methods used: 1- CompositionTarget.Render(). 2- Dispatcher Timer. 3- stroy board.

which is more suitable for creating sample game loop ?

È stato utile?

Soluzione

Out of your methods listed, DIspatcher Timer is the best method for creating a game loop.

HOWEVER, I strongly encourage you not to use Silverlight and instead use the XNA API if you want to create a game, even for simple games like Snake its much easier to program a game with game architecture, Silverlight is designed for Event-Driven Applications (normal apps) and XNA is designed specifically with games in mind (Update Logic, then Drawing 2D or 3D images on the GPU). Also, if you stick with silverlight unless you use storyboards that make use of the composition thread, none of your drawing will be hardware-accelerated and will really slow down the performance of your application.

Also, if you target Windows Phone 8 specifically you can create a Direct3D app and use the DirectX Toolkit to get the "xna" spritebatch class in C++. A game loop and 2D drawing code will be automatically setup for you using that method.

Altri suggerimenti

The XNA's game loop on Windows Phone is based on Silverlight's Dispatcher Timer. So it's definitely suitable for this kind of purpose.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top