130 likes | 301 Views
Windows Phone 7 Game Development with XNA. Dan Colasanti ImproviSoft LLC Presented at the CNY .Net Developers Meeting March 9, 2011. Introduction to XNA A Brief History. XNA is Microsoft’s Free Game Development Kit for Windows, XBOX 360, and Windows Phone 7
E N D
Windows Phone 7 Game Development with XNA Dan Colasanti ImproviSoft LLC Presented at the CNY .Net Developers Meeting March 9, 2011
Introduction to XNAA Brief History • XNA is Microsoft’s Free Game Development Kit • for Windows, XBOX 360, and Windows Phone 7 • XNA games are made with Visual Studio in C# • XNA 4.0 was released in 2010 • Only XNA 4.0 is compatible with Windows Phone 7 • XNA 4.0 was preceded by: • XNA 1.0 (2006), 2.0 (2007), 3.0 (2008), 3.1 (2009: Zune HD) • Dec. 2002: “Managed DirectX” : C# (no longer exists) • 1995 - Today: “DirectX” - C++ API (XNA doesn’t replace it!) • 1995: Win32 “Game SDK” – aka: the 1st version of DirectX Dan Colasanti - March 9, 2011
Introduction to XNAXNA Advantages • XNA is less complex than DirectX • Easier to get started developing games • XNA abstracts the Game Loop & manages resources • automatically double-buffers graphics • provides a clear object model for creating games • Managed code • XNA is pointer-free and provides garbage collection • 3D on Windows Phone 7 • Can be used to develop 3D games for WP7 – Silverlight can’t • Cross Platform • One solution for Windows, Windows Phone, and XBOX 360 Dan Colasanti - March 9, 2011
Introduction to XNAXNA Disadvantages • C# only • VB & C++ devs are out of luck • No UI Designer • Can’t use Expression UI designer as with Silverlight • Must code everything • For simple 2D games/animations, may be easier to use Silverlight • Limited SIP keyboard • Can display it, but not customizable as in Silverlight • No Video on WP7 • Currently no XNA support for video playback on WP7 • Breaking Changes in XNA 4.0 • Many breaking changes, with some features from earlier XNA versions removed, making porting existing games to 4.0 difficult • Fewer Microsoft Developer events for XNA Dan Colasanti - March 9, 2011
XNA Game Development FrameworkNamespaces Audio Storage Content Net Design Microsoft.Xna.Framework Media Game Input GamerServices Graphics Dan Colasanti - March 9, 2011
XNA Game Development FrameworkThe Game Class & Protected Members • Your game inherits from the XNA Game class: public class MyGame : Microsoft.Xna.Framework.Game • See the Game class interface at:http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.game_members.aspx • Inherited XNA Game class members include: • Initialize() – init GraphicsDevice, SpriteBatch, Components, … • LoadContent() – load graphics, sound effects, music, etc. • UnloadContent() • Update(GameTimegameTime) – game logic, handle input • Draw(GameTimegameTime) – called at 30fps for WP7 • The Framework calls into these functions to start the game and to execute the Game Loop Dan Colasanti - March 9, 2011
The XNA Game Life Cycle Update UnloadContent Initialize LoadContent Draw Dan Colasanti - March 9, 2011
XNA Game Development FrameworkThe Game Class – Inherited Properties • Inherited XNA Game class Properties include: • Components • a collection of developer-specified GameComponents that are managed by the framework • Content • the current ContentManager • GraphicsDevice • for viewport dimensions & setting render targets • Services • developer-specified services that will be used by game objects • Window • for the display orientation and handling Window events Dan Colasanti - March 9, 2011
XNA Game Development FrameworkThe Game Class – Inherited Events • Inherited XNA Game class event handlers • Can be overridden to implement tombstoning and to start/stop services (e.g. audio mgr or license mgr) • or WP7 Games can handle similar events from:Microsoft.Phone.Shell.PhoneApplicationService.Current • Activated – raised when the OS restarts the game • Deactivated – raised when the OS suspends the game • Launching – raised when the user starts the game • Closing – raised when the game is exited normally • If making a cross platform game, overriding game-class event handlers is the preferred method Dan Colasanti - March 9, 2011
XNA Limitations on Windows Phone 7 • Limited SIP Keyboard Support • Cannot play & control video (coming in 2011) • Can launch Media Player, but that exits your game • No peer-to-peer networking (coming in 2011) • Cannot use custom pixel shaders (not in 4.0) • RenderTargets switches cause screen flicker (ugh!) • No UI designer or standard UI controls • 3rd party libraries available for Silverlight, not XNA Dan Colasanti - March 9, 2011
Code DemonstrationsXNA for Windows Phone 7 • 2D Graphics & Text • Sound Effects & Music • Saving & Loading Games - Tombstoning • Trial Mode License Implementation • WP7 Devices: Accelerometer, Vibrate, Camera, Touch • User Input & Notifications • Local High Scores • Cross Platform Development • And More! Dan Colasanti - March 9, 2011
XNA Game Studio 4.0Downloads & Resources • Download XNA GS4.0 (in the WP7 Dev Tools):http://create.msdn.com/en-us/resources/downloads • Download the WP7 Dev Tools January 2011 Update:http://create.msdn.com/en-us/news/Windows_Phone_Developer_Tools_January_2011_Update • *Free* XNA Resources: • Book “Programming Windows Phone 7” – Charles PetzoldFree PDF: http://www.charlespetzold.com/phone/ • Code Samples: http://create.msdn.com/en-us/education/roadmap • Shawn Hargreaves Blog: http://blogs.msdn.com/b/shawnhar/ • Free Books: http://www.globalnerdy.com/2011/02/15/free-books-on-windows-phone-7-development/ • Video Training: http://channel9.msdn.com/Blogs/egibson/Windows-Phone-7-Jump-Start-Session-1-of-12-Introduction Dan Colasanti - March 9, 2011
Thanks for Attending! • Feel free to contact me with any questions: • Dan Colasanti • Email: Dan.Colasanti@ImproviSoft.com • Web: www.improvisoft.com • Blog: www.improvisoft.com/blog/ • Twitter: @DanColasanti Dan Colasanti - March 9, 2011