We now have the User Controls defined. We need to move many sprites based on these User Controls. Now, we are going to create a generalized superclass to manage the most common operations related to a User Control working as a sprite.
1. Stay in the
SilverlightInvaders2DVector
project2. Create a new abstract class—
UpdateableUIElement
3. Add the following public property to determine whether the user interface element is alive or not:
public bool isAlive { set; get; }
4. Add the following public abstract method to encapsulate updates based on the elapsed time:
public abstract void Update(TimeSpan elapsedTime);
5. Create a new abstract class—SpriteWrapper (a subclass of UpdateableUIElement) —using the following declaration:
public abstract class SpriteWrapper: UpdateableUIElement
6. Add the following
protected
variables:// Indicates whether the sprite has been rendered or not protected bool _rendered = false; // The UserControl instance...