How to play a sprite only once?

Hi Everyone…

Could you help me please to find out

how I can make a sprite play only 1 time…

I try on line but I did not find anything that I could use.

Also, when you use

explosion:pause( ) – explosion is the sprite

if it has 10 frames, it will pause in which frame?

and when play, it will continue from what ever frame it was stop… or will start from frame 1?

also, when you “hide” the scene… is there a need to actually “stop” the sprite – like

explosion:stop( )

or not?

Thanks for your help

When you define the sprite sequence there is a variable called loopCount that you can set.  If you set it to 1, the sequence will play once then stop on its own:
 

    explosionSequenceData = {
        { name = “dbiExplosion”,
            frames={
                1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49
            },
            time=explosionTime, loopCount=1
        },
    }

Of course that is code from one of my games and is used for illustration purposes only and won’t be something you can just drop directly into your game.

Thanks Rob. I did not know about loopCount… it did work great.

Thanks

When you define the sprite sequence there is a variable called loopCount that you can set.  If you set it to 1, the sequence will play once then stop on its own:
 

    explosionSequenceData = {
        { name = “dbiExplosion”,
            frames={
                1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49
            },
            time=explosionTime, loopCount=1
        },
    }

Of course that is code from one of my games and is used for illustration purposes only and won’t be something you can just drop directly into your game.

Thanks Rob. I did not know about loopCount… it did work great.

Thanks