SpriteLibrary
SpriteLibrary
SpriteLibrary
Sprite Class
Sprite Events
CheckBeforeMove Event
Click Event
ClickTransparent Event
MouseEnter Event
MouseEnterTransparent Event
MouseHover Event
MouseHoverTransparent Event
MouseLeave Event
MouseLeaveTransparent Event
SpriteAnimationComplete Event
SpriteArrivedAtEndPoint Event
SpriteArrivedAtWaypoint Event
SpriteBeingDestroyed Event
SpriteChangesAnimationFrames Event
SpriteExitsPictureBox Event
SpriteHitsPictureBox Event
SpriteHitsSprite Event
SpriteInitializes Event

# Sprite Events

The Sprite type exposes the following members.

Events

| Name | Description
--- | --- | ---
| CheckBeforeMove | This event fires off before a sprite is drawn. Use it if you have constraints. You can change the location or cancel the move entirely.
| Click | This event happens when someone clicks on the sprite (on the rectangle in which the sprite is). If you want the event to fire off only when someone clicks on the visible part of the sprite, use ClickTransparent instead.
| ClickTransparent | This event happens when someone clicks on the sprite (on the sprite image itself). If the sprite is sometimes hidden, but you want the click to work even if it is not visible at that instant, use Click instead.
| MouseEnter | When the mouse moves over the sprite. Use this for a menu, when you want the menu item to glow when the mouse is over the menu item sprite.
| MouseEnterTransparent | When the mouse moves over a non-transparent portoin of the sprite. Use this for a menu, when you want the menu item to glow when the mouse is over the menu item sprite.
| MouseHover | This event happens when the mouse moves over the sprite, and then pauses. We use the hover timing from the parent form.
| MouseHoverTransparent | This event happens when the mouse moves over a non-transparent portion of the sprite, and then pauses. We use the hover timing from the parent form.
| MouseLeave | When the mouse moves off the sprite. Use this for a menu, when you want the menu item to stop glowing when the mouse moves away from the menu item sprite.
| MouseLeaveTransparent | When the mouse moves off the non-transparent portion of the sprite. Use this for a menu, when you want the menu item to stop glowing when the mouse moves away from the menu item sprite.
| SpriteAnimationComplete | Only used when you tell an animation to animate once. At the end of the animation, this function fires off. In the AdvDemo example, the dragon sprite has multiple animations. At the end of each of them, the game randomly chooses which animation to show next. And, it even chooses, every once in a while, to breathe fire.
| SpriteArrivedAtEndPoint | An event for when you tell a Sprite to MoveTo(Point) a specific point, or, when you tell the Sprite to MoveTo(list of points). When the Sprite has reached the final destination, the Sprite fires off this event.
| SpriteArrivedAtWaypoint | When you tell a sprite to MoveTo(list of points), this fires off every time it gets to one of the points. When it gets to the final point, only the SpriteAtEndPoint event fires off.
| SpriteBeingDestroyed | The Sprite has just been told to be destroyed. You might want to do some cleanup. If you need to destroy some payload data, or tell something to cleanup after the sprite this is where to do that.
| SpriteChangesAnimationFrames | When the frame of an animation changes. If you want to have something happen every time the foot of your monster comes down, when the swing of your sword is at certain points, etc. Check to see that the Animaton and FrameIndex are what you expect them to be.
| SpriteExitsPictureBox | This happens when the sprite has exited the picture box. Useful when you want to keep sprites from traveling on forever after exiting. For example, you may want to destroy the sprite now that it is no longer visible.
| SpriteHitsPictureBox | This happens when the sprite hits the border of the picture-box. Useful for when you want to have shots explode when they hit the side.
| SpriteHitsSprite | This happens when two sprites hit each-other. The SpriteEventArgs that is returned contains the sprite that this sprite hits.
| SpriteInitializes | This event happens right after the sprite is created. Use this to immediately set a sprite to animate once or something like that.

Top
See Also

#### Reference

Sprite Class
SpriteLibrary Namespace