Using Lua.
I have a few timers in my game. I would like to update some of the timers only when an event happens, like getCrankChange == 0. And have other timers be updated every frame. As pd.timer.updateTimers() will update all of them, don't know how to achieve this.
Timers are implemented in CoreLibs/timer.lua
so you could always make changes to a copy of that file included in your project (so that your changes don't get wiped out when there is an SDK update).
I might modify the playdate.timer.updateTimers()
to take an optional array argument?
I'm curious about what you're trying to achieve - is it just to save processing time updating timers you're not using at the moment?
Thanks @dan, will try this.
What I'm trying to achieve:
- Use a timer to spawn an enemy every 5 seconds.
- Only update the timer when there was a change in the crank position this frame.
- So if no crank change for lets say 3 seconds, the timer won't get updated.
In addition to these, I have other timers which I want to update regardless of crank position change.
Someone on Discord suggested having a manual timer where I accumulate the timer only on change and reset it on reaching the time required.