timer pause and resume bug?

Hi,

I made the test with the code below:

  
local p = false  
  
local function test()  
 print("hello")  
end  
a = timer.performWithDelay(4000, test, 0)  
  
local function pauseMe(e)  
if e.phase == "began" then  
 if p == false then  
 timer.pause(a)  
 print("timer has been paused")  
 p = true  
 else  
 timer.resume(a)  
 print("timer has been resumed")  
 p = false  
 end  
end  
end  
  
Runtime:addEventListener("touch", pauseMe)  

If I keep clicking on the screen quickly several times, “hello” will never be printed even the last click was to resume. I’m using 617 build.

Anyone seen such issue?

Steve [import]uid: 84159 topic_id: 15096 reply_id: 315096[/import]

617 isn’t a stable build… I tried this on 591 and I just get told: “attempt to call field ‘pause’, a nil value”… sounds like a bug to me. Might want to drop it in the bug reports.

Which, I know, is silly because 591 does’t implement that yet. But the “hello” print statement does go off every 4 seconds as it should. Maybe that info will help. [import]uid: 10818 topic_id: 15096 reply_id: 55859[/import]

Hey guys,

First up - pause and resume was introduced after .591 - download daily build .602 and this code will work fine. (Tested and confirmed.)

Peach :slight_smile: [import]uid: 52491 topic_id: 15096 reply_id: 55861[/import]

How about the latest daily build?

Steve [import]uid: 84159 topic_id: 15096 reply_id: 55887[/import]

You can test it on the latest daily and see what happens - if it works, great :slight_smile:

Daily builds aren’t guaranteed to work perfectly, or even at all, so it’s a matter of experimentation :wink: [import]uid: 52491 topic_id: 15096 reply_id: 55998[/import]

@peach, I still have the problem. Sometimes timer resumes, sometimes not. I made the same test with the module and it works accurately.

Steve [import]uid: 84159 topic_id: 15096 reply_id: 56010[/import]

Daily builds are NOT guaranteed to work perfectly as I said above.

I haven’t had any issues with it in .602, but until there’s a stable build supporting it, it should not be presumed to be a perfect feature.

Glad you found something to suit your needs in the meantime.

Peach :slight_smile: [import]uid: 52491 topic_id: 15096 reply_id: 56132[/import]

I’ve been having the same issues, but I found a quick and easy fix. For some reason the pause and resume stuff doesn’t work perfectly if you use it instantaneously within a touch listener (or in my case, it was a collision listener). So have it wait a millisec before calling it. Here’s you code, but working:

[lua]local p = false

local function test()
print(“hello”)
end
a = timer.performWithDelay(4000, test, 0)

local function pauseMe(e)
if e.phase == “began” then
if p == false then
local function pauseNow()
timer.pause(a)
print(“timer has been paused”)
p = true
end
timer.performWithDelay(1, pauseNow)
else
local function resumeNow()
timer.resume(a)
print(“timer has been resumed”)
p = false
end
timer.performWithDelay(1, resumeNow)
end
end
end

Runtime:addEventListener(“touch”, pauseMe)[/lua]

It’s probably a good idea to submit this as a bug to ansca and reference this post in your bug submission, so that they can get this fixed with all of the info at their disposal.

Thanks,

Matt
W2MD [import]uid: 10211 topic_id: 15096 reply_id: 57820[/import]

Nice workaround! I was trying out so many ways to apply the use of both API’s. Similar to what you were trying to figure out.

Chelle [import]uid: 22552 topic_id: 15096 reply_id: 59674[/import]

Hi, All,

Thank you for sharing info. about timer resume.

I tried this method on corona build 2011.695, seems timer.resume() has bugs when using multi timers.

I have tested for one timer only it works fine, so I think it may be a threading issue for timers in corona. hope this will give you a little help. [import]uid: 24678 topic_id: 15096 reply_id: 69868[/import]

Currently timer.pause and timer.resume are not working. We hope to have this working in a daily build soon. [import]uid: 7559 topic_id: 15096 reply_id: 70053[/import]