NEW: Pause/Resume Timers and a Table to Hold ALL Active Timers!

I just released version 1.3 of my BeebeGames Class today, and here are the new features:

* A total of 6 new functions (and 2 new methods) that all have to do with time and timers.

* A replacement for timer.performWithDelay() that will allow you to pause/resume your timers.

* A table that will hold all active timers (that were created with the new function) as well as functions that will allow you to pause, resume, and cancel all timers easily with one line of code respectively.

Here's a tutorial that goes over everything that was added today:

http://jonbeebe.tumblr.com/post/2439016279/how-to-use-the-new-time-functions

Here are all the new functions:

  • performAfterDelay()
  • timerObject:pause()
  • timerObject:resume()
  • timerObject:cancel()
  • resetTimeCounter()
  • getTimeCounted()
  • beebegames.activeTimers table
  • pauseAllTimers()
  • resumeAllTimers()
  • cancelAllTimers()

Once again, you can get the BeebeGames Class from the Corona Code Exchange, and learn how to use all of the above functions here:

http://jonbeebe.tumblr.com/post/2439016279/how-to-use-the-new-time-functions

So...you are kind of amazing. Not to sound weird but I would say you have been an inspiration to my use of Corona!

Thanks a lot, and keep up the good work!

Jon, thank you so very much! My vote goes to you for the Corona Developer of Year award!!! Happy holidays

Amazing contribution once again.

This grab bag of code you're providing is really helpful; commaThousands() and newRetinaText() are both pretty clever!

I'm a little leery of these timer functions though, because you're using enterFrame listeners to count the frames. That only works for timing if the framerate is rock solid and, well, it might not be.

Just yesterday I came up with a solution using system.getTimer() to pause delay timers; that way you're keeping track of absolute time and it doesn't matter what the framerate is:
http://developer.anscamobile.com/forum/2011/01/03/how-pause-performwithdelay

I'll probably write my own timer class with pause() resume() and cancel() methods just like you did because that is really convenient.

Thanks for the continued contributions Jon! I just yesterday wrote my own "timer pause" function, which isn't as open-ended as yours (it just works for one primary swapping timer, which is all that I need it for at the moment). Mine uses system.getTimer() like jhocking's above, which might (or might not) be more accurate... really hard to determine without extensive testing.

For all those facing this dilemma in their game, remember that Ansca has true transition pausing (and quite possibly Timer pauses) as a "top priority" in the roadmap. That means it's probably coming fairly soon. It's not wise to outright delay your game waiting for this... by all means, use Jon's function or write your own Timer pause function... but my own opinion is to not worry excessively about this because Ansca is probably adding this feature sooner than later. I'm going to continue to use my custom function and work on other game aspects in the meantime.

Frame-based transitions are fine with me, because if the frames are lagging behind, I always assume in-game time should lag with it (or things might get screwed up)... but that' just me, and my personal needs.

I agree with IgnisDesign, just look at all these as temporary fixes until the "real thing" gets released by Ansca :-)

Btw, version 1.7 was released today and includes an EASY way to make use of pregenerated random tables (saves on performance for apps that use a lot of math.random calls).

Download 1.7 here.

My tutorial on the new random tables functions here.

remember that Ansca has true transition pausing (and quite possibly Timer pauses) as a "top priority" in the roadmap.

I did not know that, great!

ADDITION: I just saw number 3 on the roadmap
http://www.anscamobile.com/resources/roadmap/

jon is this already in the latest release candidate and you're just teasing us? lol

Can someone give me some example code? im having trouble, all im doing is creating a timer and trying to get it to display on screen... do i want to create a Runtime listener for a function that calls local timePassed = getCountedTime( timeCounter )

and then display the result in a textobject?

views:2229 update:2011/9/19 13:40:57
corona forums © 2003-2011