I tried to play a sprite animation one time then delete it when the animation sequences has ended. According to the documentation, it should be possible to add event listeners to sprite that get triggered when the animation ends or loops. However, none of those events is triggered, the listener is never called:
[lua]require(“sprite”)
Data = require “myAnimation”
Sheet = sprite.newSpriteSheetFromData( “myAnimation.png”, Data.getSpriteSheetData() )
SpriteSet = sprite.newSpriteSet(Sheet, 1, 25)
sprite.add (SpriteSet, “Default”, 1, 25, 250, 1)
function AnimationComplete(event)
print(“LISTENER CALLED!”)
end
Img = sprite.newSprite( SpriteSet )
Img.x = 100
Img.y = 100
Img:addEventListener(“end”, AnimationComplete)
–Img:addEventListener(“next”, AnimationComplete)
–Img:addEventListener(“loop”, AnimationComplete)
Img:prepare(“Default”)
Img:play ()[/lua]
If this is my own fault, please let me know -I can’t find any reasion why this doesn’t work though… [import]uid: 9644 topic_id: 4118 reply_id: 304118[/import]