Time for action – updating and displaying ScoreZooms

  1. Add a Queue object to the Game1 class to hold active ScoreZooms:
    Queue<ScoreZoom> ScoreZooms = new Queue<ScoreZoom>();
  2. 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();
    }
  3. In the Update() method, inside the case section for GameState.Playing, add the call to update any active ScoreZooms. This can be placed right before the case's break; statement:
    UpdateScoreZooms();
  4. Add the following to the CheckScoringChain() method to create a ScoreZoom 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.