Corona SDK: 2013.1157
I’m converting one of my apps from the deprecated sprite.* API to the new API and have run into a regression bug.
Dynamically setting object.timeScale works fine in the old API, but skips frames in the new one.
I have a sprite-object with 5 frames where the timeScale is set depending on how fast the object is moving. The timeScale is calculated in the onSpriteEvent handler on each “loop” event.
The weird thing is that the frame skipping only occurs if the timeScale value changes between calls. If it remains the same between calls, no frame skipping occurs.
Here’s a dump from the onSpriteEvent handler when the speed is changing. The frames should progress from frame 1 to 5 in sequential order, but as you can see, some frames are skipped after changing the timeScale.
loop 1
1 goalieblue loop setspeed 0.82054866790771
next 5
loop 1
1 goalieblue loop setspeed 0.73574411392212
next 4
next 5
loop 1
1 goalieblue loop setspeed 0.62053208351135
next 3
next 4
next 5
loop 1
1 goalieblue loop setspeed 0.71538330078125
next 4
next 5
loop 1
1 goalieblue loop setspeed 0.6395166683197
next 3
next 4
next 5
loop 1
1 goalieblue loop setspeed 0.66574281692505
next 2
next 3
next 4
next 5
loop 1
1 goalieblue loop setspeed 0.70823823928833
next 3
next 4
next 5
…and here’s a dump when timeScale is set to the *same* value on every call. No frame skipping occurs.
loop 1
1 goalieblue loop setspeed 0.5
next 2
next 3
next 4
next 5
loop 1
1 goalieblue loop setspeed 0.5
next 2
next 3
next 4
next 5
loop 1
1 goalieblue loop setspeed 0.5
next 2
next 3
next 4
next 5
loop 1
1 goalieblue loop setspeed 0.5
next 2
next 3
next 4
next 5
Any advice would be appreciated.