Time for action – updating and displaying ScoreZooms
- Add a
Queue
object to the Game1 class to hold activeScoreZooms
:Queue<ScoreZoom> ScoreZooms = new Queue<ScoreZoom>();
- Add a new helper method to the Game1 class to update the
ScoreZooms
queue:private void UpdateScoreZooms() { int dequeueCounter = 0; foreach (ScoreZoom zoom in ScoreZooms) { zoom.Update(); if (zoom.IsCompleted) dequeueCounter++; } for (int d = 0; d < dequeueCounter; d++) ScoreZooms.Dequeue(); }
- In the
Update()
method, inside the case section forGameState.Playing
, add the call to update any active ScoreZooms. This can be placed right before the case'sbreak;
statement:UpdateScoreZooms();
- Add the following to the
CheckScoringChain()
method to create aScoreZoom
when the player scores. ...
Get XNA 4.0 Game Development by Example Beginner's Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.