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

This happens when two sprites hit each-other. The SpriteEventArgs that is returned contains the sprite that this sprite hits.

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

    public event SpriteSpriteEventHandler SpriteHitsSprite

#### Value

Type: SpriteLibrary
Sprite
SpriteEventHandler
Examples
Copy

     public void DefineSprite()
     {
         Sprite mySprite = MySpriteController.SpriteFromName("Monster");
         mySprite.SpriteHitsSprite += MonsterHitBySprite;
     }

     public void MonsterHitBySprite(object sender, SpriteEventArgs e)
     {
        Sprite me = (Sprite)sender;
        //Check to see if we got hit by a "shot" sprite
        if (e.TargetSprite.SpriteOriginName == "Shot")
        {
            //we got shot.  DIE!
            Sprite nSprite = MySpriteController.DuplicateSprite("Explosion");
            nSprite.PutBaseImageLocation(me.BaseImageLocation);  //put the explosion where the "hit" sprite is
            nSprite.SetSize(me.GetSize); //Use the size of the sprite that got hit.
            nSprite.AnimateOnce(0); //Animate once.  Hopefully the explosion destroys itself when the animation ends

            //Play a boob sound
            SoundPlayer newPlayer = new SoundPlayer(Properties.Resources.Boom);
            newPlayer.Play();

            //destroy the sprite that got hit
            me.Destroy();
            //destroy the "shot" sprite that hit us
            e.TargetSprite.Destroy();
        }
    }

See Also

#### Reference

Sprite Class
SpriteLibrary Namespace