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? [import]uid: 109677 topic_id: 21730 reply_id: 321730[/import]

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 :slight_smile: [import]uid: 52491 topic_id: 21730 reply_id: 86304[/import]

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 :slight_smile:

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;  

Joakim [import]uid: 81188 topic_id: 21730 reply_id: 86306[/import]

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!

[import]uid: 109677 topic_id: 21730 reply_id: 86309[/import]