Sprite Questions

I’m working on a game. I have an image used as a sprite sheet. It contains four different game elements each with 2 frames and another frame used as an explosion. All of the sprites refer to the same sprite sheet which contains all of the frames.

I used sprite.add() to add an extra “explode” sequence. At this point tapping a sprite switches it to the "explode"sequence. I want to know when this new sequence ends. I gave it a number for loop but I never seem to get an “end” event.

I’m open to suggestions. If anyone has a any pointers on using sprites in this way please pass them along!

[import]uid: 98652 topic_id: 18951 reply_id: 318951[/import]

soggybag,
This is actually pretty easy to do by setting up an eventListener on the sprite.

[lua]local function spriteListener( event )
print( “Sprite listener” … event.name, event.sprite, event.phase, event.sprite.sequence)
end

– Add sprite listener
instance:addEventListener( “sprite”, spriteListener )[/lua]

You can find out more information from the API listed here:
http://developer.anscamobile.com/reference/index/spriteinstanceaddeventlistener [import]uid: 102698 topic_id: 18951 reply_id: 73010[/import]

Thanks for the reply. I realized after posting that I hadn’t started the new sequence with sprite:play(). And, so wasn’t getting the “end” phase event.

I rearranged everything to use a single sprite sheet. Then added a sequence for each game element using sprite.add().
[import]uid: 98652 topic_id: 18951 reply_id: 73013[/import]

Glad to hear you got it sorted :slight_smile: [import]uid: 84637 topic_id: 18951 reply_id: 73354[/import]

Glad to hear you got it sorted :slight_smile: [import]uid: 84637 topic_id: 18951 reply_id: 73355[/import]