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 SpriteHitsPictureBox Event

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.

Namespace: SpriteLibrary
Assembly: SpriteLibrary (in SpriteLibrary.dll) Version: 1.0.0.6 (1.0.0.6)
Syntax
C#
Copy

    public event SpriteSpriteEventHandler SpriteHitsPictureBox

#### Value

Type: SpriteLibrary
Sprite
SpriteEventHandler
Examples
Here is an example of us defining a Sprite. We retrieve a named Sprite and set the function on the master template to call the SpriteBounces function whenever the Sprite hits the picturebox.

You only need to add the function once, if you are putting it on the Named Sprite. After that time, all the sprites duplicated from the template will have this function set for them.
Copy

    public void DefineSprite()
    {
        Sprite mySprite = MySpriteController.SpriteFromName("Ball");
        mySprite.SpriteHitsPictureBox += SpriteBounces;
    }

    public void SpriteBounces(object sender, EventArgs e)
    {
       Sprite me = (Sprite)sender;
       int degrees = (int)me.GetSpriteDegrees();
       if (Math.Abs(degrees) > 120)
       {
           me.SetSpriteDirectionDegrees(0);//go right
       }
       else
       {
           me.SetSpriteDirectionDegrees(180); //go back left
       }
    }

See Also

#### Reference

Sprite Class
SpriteLibrary Namespace