[Resolved] Question about new Sprite API

Hi all,
I’m converting my old code over to using the newer Sprite API and I ran into a small snag
which I hope someone can anser.

When I add a Sprite Listener to a number of animating sprites how do I determine which Sprite
caused the interrupt?
Before I used to use event.sprite.sequence but that no longer works. I also tried using self.id but that
doesn’t work either.

On a related note does the Sprite Listener now only get called when the Sprite animation starts and ends instead of on a animation step by step basis?

Thanks,
-Dennis [import]uid: 108253 topic_id: 30933 reply_id: 330933[/import]

Hi Dennis,

I think the new call to get the particular sprite (in a listener event) is just “event.target”… give that a try and let me know.

Also, I think other phases were rolled out for the sprite listener in the most recent public build. Phases like “next frame” to indicate when the sequence has changed to the next frame. The details probably haven’t been added to the online documentation yet, but they are contained somewhere in here.

http://developer.coronalabs.com/content/corona-sdk-release-notes-build-2012-894

Hope this helps,
Brent
[import]uid: 9747 topic_id: 30933 reply_id: 123690[/import]

Yup, that did it. They changed event.sprite to event.target. That fixed most of my problems.

Now I used to pause the animation if a certain frame had been reached so I’ll load the latest version
of Corona and try to see what phases they added. Hopefully next frame is there and I can query which frame from spiteObject.frame and that hopefully will do it.

Thanks so much for pointing me in the right direction.
Cheers,
-Dennis [import]uid: 108253 topic_id: 30933 reply_id: 123692[/import]

Hi Dennis,

I think the new call to get the particular sprite (in a listener event) is just “event.target”… give that a try and let me know.

Also, I think other phases were rolled out for the sprite listener in the most recent public build. Phases like “next frame” to indicate when the sequence has changed to the next frame. The details probably haven’t been added to the online documentation yet, but they are contained somewhere in here.

http://developer.coronalabs.com/content/corona-sdk-release-notes-build-2012-894

Hope this helps,
Brent
[import]uid: 9747 topic_id: 30933 reply_id: 123690[/import]

Yup, that did it. They changed event.sprite to event.target. That fixed most of my problems.

Now I used to pause the animation if a certain frame had been reached so I’ll load the latest version
of Corona and try to see what phases they added. Hopefully next frame is there and I can query which frame from spiteObject.frame and that hopefully will do it.

Thanks so much for pointing me in the right direction.
Cheers,
-Dennis [import]uid: 108253 topic_id: 30933 reply_id: 123692[/import]