Ansca, thanks so much for "sprite.timeScale"!

I just noticed this new API slipped into the documentation; not sure exactly when it happened. I’m going to implement it now. I specifically requested this feature, and I want to thank you immensely for adding it. :slight_smile:

I sincerely believe this is a valuable addition to the sprite API for many developers, since it allows for MUCH easier speed control of animated sprites, and (perhaps even more useful) perfect synchronization of a sprite which needs to animate at different rates in different frame order patterns.

http://developer.anscamobile.com/reference/index/spriteinstancetimescale

Again, thanks Ansca! You guys rock. :slight_smile:

Brent Sorrentino
Ignis Design
[import]uid: 9747 topic_id: 10857 reply_id: 310857[/import]

Hello Brent,

We just added this new feature to our API last week. You have a very sharp eye! And thanks for the kind words! Please feel free to give us feedback on how well this new feature works for you.

One interesting bit of feedback that we’ve received was to change the min timeScale constraint to zero so that developers can pause the animation. Another was to allow negative timeScales in order to go backwards in the animation sequence, although I’m not sure if we can fit that one by the next release. [import]uid: 32256 topic_id: 10857 reply_id: 39673[/import]

Josh is the “guy” who did it - I had briefly mentioned it here, and “boom” done.

Thanks Josh and hope you guys find it useful

C. [import]uid: 24 topic_id: 10857 reply_id: 39675[/import]

Thanks again Josh! I tested “spriteInstance.timeScale” using Daily Build 528, and it works perfectly. :slight_smile:

Just to recap how cool and efficient this is, here’s a “before” and “after” from my code:

BEFORE [code]
– definition step
local playerSet = sprite.newSpriteSet( plSheet, 1, 10 )
sprite.add( playerSet, “plFloating”, 1, 10, 360, 0 )
sprite.add( playerSet, “plFlying”, 1, 10, 180, 0 )

– later: player starts flying
local frame = Player.currentFrame
Player:prepare(“plFlying”)
Player.currentFrame = frame --lines 7 & 9 needed to sync the animations
Player:play()

– and when player stops flying…
local frame = Player.currentFrame
Player:prepare(“plFloating”)
Player.currentFrame = frame
Player:play()
[/code]

AFTER --player starts flying Player.timeScale = 2.0 --player stops flying Player.timeScale = 1.0

And so 8 lines of code became 2 lines! Also the animation is now perfectly synchronized because Corona doesn’t need to change sheets and look up frames, which technically worked but sometimes caused a visible skip when the switch occurred near the middle of a frame change.

Going forth with this API: I don’t think a value of “0” is necessary, because isn’t that exactly the same as the “:pause()” and “:play()” APIs? Maybe I’m not considering a scenario where having timeScale=0 might be necessary.

As for negative timescale, that could be very useful! I can imagine someday needing a method to simply reverse a one-directional animation, and currently that would require two different sprite sets, similar to my “before” scenario above.

Anyway, thanks again for your efforts here.

Brent Sorrentino
Ignis Design
[import]uid: 9747 topic_id: 10857 reply_id: 39699[/import]