timeScale is having no effect on my sprites

I’ve seen some posts that they are having the same issue, but never a fix or confirmation.

Does object.timeScale work correctly? Is there a best practices because it doesn’t work for me.

[lua]

player = display.newSprite( runSheet, runData ) --get info from TexturePacker

player:setSequence( “run” )

player.state = “running”

player:play()

player.timeScale = 0.5

[/lua]

The above code has no effect.

So after messing around a bit, if I set the time variable when setting up the sprite sequence, the timeScale will work.

Not ideal at all because I wanted to use it to avoid having to figure out the time for each animation.

Hi @ChunkyApps,

I was going to respond along these lines, but I see you already determined the cause/solution. Out of curiosity, what would be the “ideal” alternative in this case? The time scale must be based from something, and that’s a declared time for the sequence. Without a time for the sequence, what would .timeScale actually do?

If you want to use “frame-based” speed, but also .timeScale, I suppose you could compute the time of each sequence based on the number of sequence frames and your app frames-per-second. For example, if your “fps” was 60, that would be 60 animation frames per second with frame-based animation, so if your animation contained 30 frames, (30/60)*1000 = 500, thus a time setting of 500.

Take care,

Brent

Exactly right Brett.

My scenario is this: I am running the app at 30 fps

I have an animation sequence of 18 frames that should play at 15fps

If I could just make timeScale = 0.5 without having to determine how long 18 frames would take at a setting of 30fps, it would be nice.

In other words, base it on the app fps if time isn’t declared

So after messing around a bit, if I set the time variable when setting up the sprite sequence, the timeScale will work.

Not ideal at all because I wanted to use it to avoid having to figure out the time for each animation.

Hi @ChunkyApps,

I was going to respond along these lines, but I see you already determined the cause/solution. Out of curiosity, what would be the “ideal” alternative in this case? The time scale must be based from something, and that’s a declared time for the sequence. Without a time for the sequence, what would .timeScale actually do?

If you want to use “frame-based” speed, but also .timeScale, I suppose you could compute the time of each sequence based on the number of sequence frames and your app frames-per-second. For example, if your “fps” was 60, that would be 60 animation frames per second with frame-based animation, so if your animation contained 30 frames, (30/60)*1000 = 500, thus a time setting of 500.

Take care,

Brent

Exactly right Brett.

My scenario is this: I am running the app at 30 fps

I have an animation sequence of 18 frames that should play at 15fps

If I could just make timeScale = 0.5 without having to determine how long 18 frames would take at a setting of 30fps, it would be nice.

In other words, base it on the app fps if time isn’t declared