animation sometimes plays twice

a sprite animation that is triggered by a collision sometimes plays twice (or frame cycle begins in middle? hard to tell actually, animation sequence just sometimes looks odd).

I use postCollision as trigger and did check there is indeed just 1 trigger. So I am unsure what to do about that to solve problem.

If the problem really is that cycle is off, can that be reset?

Assuming you've used a print statement to check it only fires once (which it sounds like you have) then perhaps try;
print(sprite.currentFrame)

If it is starting in the middle (perhaps due to previous events?) then you could set the frame to 1 before playing which would fix that.

Peach :)

Hi,

That happens because there are several of events detected. I had the same problem but I solved that by adding my own tag to the sprite - and when the first collision happens I change the tag.

Heres some fragments of the code and it may be some errors, just from my weird head :)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
mySprite.Tag = "Monkey";
 
 
local function monkeyCollision(event)
         
        if event.phase == "ended" then
           if event.object1.Tag == "Monkey" then
                 
                 event.object1.Tag == "Gorilla";
                 -- Do your stuff......              
 
           end;
        end;
end;

I made a mental reference to event tags for later use!

The start frame in the 3 frame sequence was alternating between 1 and 3, setting start to 1 fixed it.

Thanks so much!

views:2300 update:2012/2/13 9:11:28
corona forums © 2003-2011