Why there’s no possibility to adjust timers and transitions’ timescale? Would be awesome!
Can you provide a better description?
Thanks
Rob
I’m requesting what is already done with animations: https://docs.coronalabs.com/api/type/SpriteObject/timeScale.html
Let’s suppose we’ve this piece of code
timer.performWithDelay(1000, someFunction)
“someFunction” will be executed a second later, but if there was a “timeScale” property setted to 0.5, that function would be executed not just a second later, but after 2 seconds
You can to go http://feedback.coronalabs.com and add an entry for this and get people to vote it up.
Rob
why not just do
local timeScale =1
local time = timer.performWithDelay((1000*timeScale), someFunction)
then adjust as needed
Thank you @Rob!
@jstrahan that’s so simple, but I’m not requesting this, I would love something like this:
local timerId = timer.performWithDelay(1000, someFunction) timer.performWidthDelay(500, function() timer.setTimeScale(timerId, 0.5) end)
If the second function [timer.setTimeScale] existed, the “someFunction” would be executed in 1.5 seconds in total. What I’m asking for is the possibility to set the timeScale whenever I want, not just at the beggining
And not just for timers, but for transitions too!
I could really use this feature with a Fast Forward button in my game. Will give it max upvotes if you make the feature request.
ok i have a timescale function for timers starting on transitions in a bit. will post code in a bit
Cool, looking forward to it
heres a look at the api that i have. if you have any suggestions let me know. transition.timeScale works with transition.to havent tested on other transition.
Note that since these api’s will be using undocumented variables it could be broken by changes made by CoronaLabs
to use require file like this
require ‘_apiExtend’
then you can use these new functions
timer.timeScale( timerId, timeScale )
transition.timeScale( transId, timeScale )
and you can read the current timeScale by
timerId.timeScale
transId.timeScale
if nil is returned then the timeScale has not been changed so it would be 1
link to code coming in a bit.
Thanks, I will give it a try soon and report back.
just realized that the timer.timeScale() function only works when iterations are set to infinite. will correct tonight if possible
Thank jstrahan. I tried with delay paramater on a transition and that results in an error. Not so sure how easy that is to fix, might be tricky?
can you post an example. did you download the new file
I have a newer file that has example project and couple new options that I plan to upload tonight so if something isn’t working id like to try and fix before I upload
I’m using the example from your site, the newest version. Downloaded again now just to be sure and still there.
So if you chance line 17 to
[lua]local trans = transition.to( ball, {delay = 5000, time = 10000, x = 300} )[/lua]
and uncomment line 22
[lua]transition.timeScale( trans, 2)[/lua]
You get error:
Runtime error
/Users/jonjonsson/Downloads/apiExtend (1)/_apiExtend.lua:27: bad argument #1 to ‘pairs’ (table expected, got nil)
stack traceback:
[C]: in function ‘pairs’
/Users/jonjonsson/Downloads/apiExtend (1)/_apiExtend.lua:27: in function ‘timeScale’
/Users/jonjonsson/Downloads/apiExtend (1)/main.lua:22: in main chunk
ok it must be that there’s no _keysStart table until after the delay. to work around delay the timeScale until the transition starts and maybe i can make it so timeScale gets delayed automatically in future code. thanks for the response.