How to check then animation in sprite sheet stopped playing?

Hello!

i have a sprite sheet with a ship and an explosion, i just loop the first frame so i can see the ship and then play 2 - 33 for the explosion.

The problem is artifacts after the explosion has played like part of the explosion stays on the screen, and sometimes it shows the ship.

i thought of checking then explosion was done and then remove it from screen but the property animating dosnt seems to work?

1
2
3
4
5
6
7
8
9
10
11
12
        elseif (event.other.name == "ground") then
        
                        
                        spriteInstance:prepare("explosion")
                        spriteInstance:play("explosion")
 
                        
                        if(spriteInstance.animating == false)then
 
                        print("Ready")
                        
                        end

If you want people testing this for you I'd suggest throwing up either plug and play or a zip with a sprite. Hard to help if you can't see everything in action ;)

Hey Peach!

Of course:) My thought just was to get information if this would work? Wouldnt the if statement print out ready then the animation is done? Or should this be written some other way? Will post some code then i am at my imac, just have access to my ipad right now:)

/Inkoqnito

Finally i got it working the way i want it to!

the reason was that i just listened for an collision in my function so, i just made another listener and function and in that i just listened for sprite and then it stopped animating i gave it the order to spriteSheet:dispose()

But i wonder is this a good way to do it? What i am thinking of is that every time the ship crashes i will restart the game and i will need to reload the spriteSheet, does this use unnecessary memory? Or should just pause it and reset the sprite sheet?

Kind regards

Inkoqnito

Maybe it would be better to pause the animation, make the ship invisible after the destroy animation has completed playing then reload the level ?

views:1397 update:2011/10/22 17:28:16
corona forums © 2003-2011