Time for action – viewing the StarField in action
Add the following declaration to the
Game1
class:Private _starField as StarField
In the declarations area of the
Game1
class, temporarily modify the declaration forgameState
fromGameStates.TitleScreen
toGameStates.Playing
:Private gameState as GameStates = GameStates.Playing
Update the
LoadContent()
method of theGame1
class to initialize the_starField
object. Be sure to place this code, after thespriteSheet
texture is loaded:_starField = new StarField( Me.Window.ClientBounds.Width, Me.Window.ClientBounds.Height, 200, new Vector2(0, 30), spriteSheet, new Rectangle(0, 450, 2, 2))
In the
Upate()
method, add the following line to theGameStates.Playing
section of theSelect..Case
statement you created earlier:_starField.Update(gameTime)
In the
Draw()
method, change the background color fromColor.CornflowerBlue
toColor.Black
.Still in the
Draw()
method, add the following line to theif
block containingGameStates.Playing...