bool drawUserInput; ButtonColors?[] currentTouchSampleColors = new ButtonColors?[4]; // Define spheres covering the various buttons BoundingSphere redShpere; BoundingSphere blueShpere; BoundingSphere greenShpere; BoundingSphere yellowShpere; // Rendering members SpriteBatch spriteBatch; Texture2D buttonsTexture; These variables will give the Level class access to the game object and to a SpriteBatch that can be used for visual output and will allow it to keep track of the player’s progress. Add a set of initialization methods for the Level class. Two of the methods are constructors and the third is an override of the DrawableGameComponent’s Initialize method, which is typically used for loading resources required by the component before displaying it: C# public Level(Game game, SpriteBatch spriteBatch, int levelNumber, int movesPerformed, Texture2D buttonsTexture) : base(game) { this.levelNumber = levelNumber; this.spriteBatch = spriteBatch; CurrentState = LevelState.NotReady; this.buttonsTexture = buttonsTexture; MovesPerformed = movesPerformed; } public Level(Game game, SpriteBatch spriteBatch, int levelNumber, Texture2D buttonsTexture) : this(game, spriteBatch, levelNumber, 0, buttonsTexture) { } public override void Initialize() { // Update delays to match level difficulty UpdateDelays(); // Define button bounding spheres DefineBoundingSpheres(); // Load sequences for current level from definitions XML
bool drawUserInput; ButtonColors?[] currentTouchSampleColors = new ButtonColors?[4]; // Define spheres covering the various buttons BoundingSphere redShpere; BoundingSphere blueShpere; BoundingSphere greenShpere; BoundingSphere yellowShpere; // Rendering members SpriteBatch spriteBatch; Texture2D buttonsTexture; These variables will give the Level class access to the game object and to a SpriteBatch that can be used for visual output and will allow it to keep track of the player’s progress. Add a set of initialization methods for the Level class. Two of the methods are constructors and the third is an override of the DrawableGameComponent’s Initialize method, which is typically used for loading resources required by the component before displaying it: C# public Level(Game game, SpriteBatch spriteBatch, int levelNumber, int movesPerformed, Texture2D buttonsTexture) : base(game) { this.levelNumber = levelNumber; this.spriteBatch = spriteBatch; CurrentState = LevelState.NotReady; this.buttonsTexture = buttonsTexture; MovesPerformed = movesPerformed; } public Level(Game game, SpriteBatch spriteBatch, int levelNumber, Texture2D buttonsTexture) : this(game, spriteBatch, levelNumber, 0, buttonsTexture) { } public override void Initialize() { // Update delays to match level difficulty UpdateDelays(); // Define button bounding spheres DefineBoundingSpheres(); // Load sequences for current level from definitions XML
MultitouchGameDevelopmentWithXNA.docx