Time for action – creating the ScoreZoom class
Add a new class file called
ScoreZoom.cs
to the Game1 class.Add the following
using
directive to the top of the file:using Microsoft.Xna.Framework.Graphics;
Add the following declarations to the ScoreZoom class:
public string Text; public Color DrawColor; private int displayCounter; private int maxDisplayCount = 30; private float scale = 0.4f; private float lastScaleAmount = 0.0f; private float scaleAmount = 0.4f;
Add the
Scale
read-only property to the ScoreZoom class:public float Scale { get { return scaleAmount * displayCounter; } }
Add a Boolean property to indicate when the ScoreZoom has finished displaying:
public bool IsCompleted { get { return (displayCounter > maxDisplayCount); } }
Create a constructor for the ScoreZoom class:
public ScoreZoom(string displayText, Color fontColor) { Text = displayText; DrawColor = fontColor; displayCounter = 0; }
Add an
Update()
method to the ScoreZoom class:public void Update() { ...