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:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | 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 () |
If this is my own fault, please let me know -I can't find any reasion why this doesn't work though...
Doesn't seem to work for me either...