Xbox LIVE Indie Games

code sample details

Silverlight XNA Game Components (Mango, C#/VB)

Code Sample


This sample provides an implementation and demonstration of a GameComponent system for use in games leveraging Silverlight and XNA Framework.

Sample Overview

When moving from the XNA Framework’s “Game” class to the Silverlight application model for the new integrated Silverlight/XNA features, one piece of functionality that isn’t provided is a system for game components. While developers could choose to move away from game components, this sample provides a way to adapt existing game components to work in the new application model.

The GameComponent and DrawableGameComponent classes provided in the sample match almost exactly with the standard XNA Framework types, however because there is no Game class or GameTime class, the constructors are no longer the same and the Update and Draw methods have also changed. This means that a component subclassing these types will not be identical to a component subclassing the standard XNA Framework types. However this sample implementation can be used in a standard Game class based project, so you can still use these new component types for Windows and Xbox 360.

The sample shows how you can create multiple cats, each represented by a component, which are then updated and drawn as part of the component collection. This enables you to create compartmentalized game objects with a single container to handle all the updating and drawing.

All content and source code downloaded from this page are bound to the Microsoft Permissive License (Ms-PL).



GS 4.0


GS 4.0

find education content
var gDomain=''; var gDcsId='dcschd84w10000w4lw9hcqmsz_8n3x'; var gTrackEvents=1; var gFpc='WT_FPC'; /*<\/scr"+"ipt>");} /*]]>*/