TGC Codebase Backup



Click for Animated Explosion Sprite by JLMoondog

9th Sep 2012 12:55
Summary

This code shows how to create an animated sprite and then play it whenever the mouse is clicked. When not playing the sprite is hidden .



Description



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    rem
rem AGK Application
rem

LoadImage (1, "exp2_0.png")
CreateSprite (1, 1)
SetSpriteAnimation (1, 64, 64, 16)
SetSpriteVisible (1, 0)

exp = 0

rem A Wizard Did It!
do

If exp = 0
    If GetPointerPressed() = 1
        x = GetPointerX()-32
        y = GetPointerY()-32
        exp = 1
    Endif
Endif

If exp = 1
    SetSpritePosition (1, x, y)
    SetSpriteVisible (1, 1)
    PlaySprite (1,30)
    exp = 2
Endif

If exp = 2
    If GetSpriteCurrentFrame(1) = 16
        SetSpriteVisible (1, 0)
        SetSpriteFrame (1, 1)
        exp = 0
    Endif
Endif

 Sync()
loop