Sprite do not fire end | next | loop events

1 reply [Last post]
MauMau
User offline. Last seen 10 weeks 4 days ago. Offline
Joined: 1 Oct 2010

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...

Replies

x-pressive.com's picture
x-pressive.com
User offline. Last seen 2 days 11 hours ago. Offline
Joined: 23 Oct 2010

Doesn't seem to work for me either...

Viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.