Hi,
Update : How to cancel a Timer.delayedCall()?I'm facing something strange.
I'm creating a few timers and I'm storing them in a table.
local playerName = "Miki"
timer = Timer.new(0, 1)
timer:start()
self.charaTimers[playerName] = timer
print (timer) -- table: 0x109df5d50 |
Later I try to retrieve my timers and stop them :
for i, j in pairs(self.charaTimers) do
print (j) -- Displays table: 0x109df5d50
print (j:isRunning()) -- false
self.charaTimers[i]:stop()
-- or j:stop()
end |
Timers keep on running. So I thought I'm mistaking with pointers but it seems that 0x109df5d50 confirms that I should be able to do j:stop()
I'm trying to know if there is anything that looks wrong here before searching somewhere else, but I'm 99% sure that those timers aren't modified anywhere else.
Do you have any ideas?
Thank you.
Comments
I wanted to simplify my example script and I deleted a line. In fact I have :
So when I check if my timers are running after 3 secs only, isRunning() should display "true".
My problem is that I can't access the timers that I stored in my table, and my goal is to stop (or pause) them.
I want the timer to stop itself after one iteration, or it should be stopped by an external event if it's still running.
How are the Timers being instantiated? Because it still seems as if they wouldn't be running even with the line you are showing.
I assumed (and I was wrong) that a timer is running (since it was already created) when a delayedCall is set, but it's not.
I chose an alternative :
Can a delayedCall be cancelled?
Interestingly, I tried a quick test and it seems to copy the function entirely because if I set a delayedCall on a function, but before the time is up remove the function or set the function to something else, the original function definition is still called.
Likes: newbie2018
Maybe @atilim could confirm? Otherwise might be able to try to do some stress tests to see if there seems to be any significance between the two.
Likes: newbie2018
Although we have talked about some unofficial implementation, it would be better if it is support in the sdk itself
Likes: newbie2018
https://sites.google.com/site/xraystudiogame
Likes: Mells, newbie2018
Mutiple arguments for event system is what I have expected since I begin using gideros
Likes: atilim
https://sites.google.com/site/xraystudiogame
Likes: newbie2018