0 Favourites

[BEHAVIOR] Timer (reworked)

This forum is currently in read-only mode.
  • Hi folks,

    Just for fun I fiddled with the Timer behavior sources

    and as it was broken (couldn't create two different timer on the same behavior), I started to rework it a bit.

    So now not only can you create as much timer as you want,

    but you also have one new condition:

    • timer "timername" is running: true if the timer is currently running

    and two new expression:

    • count("timerName"): returns the current value of the counter
    • initialValue("timerName"): returns the initial value you put in the counter

    I'll support this plugin so if you have any bug and/or feature request, feel free to ask (:

    Timer.zip

    You'll have to overwrite the original plugin to avoid conflict

    Just in case there's bugs you can fall back on the original one

    Timer_original.zip

    Have fun (:Yann2012-11-20 22:32:02

  • Awesome, thanks Yann =D

  • thanks a lot

    <img src="smileys/smiley4.gif" border="0" align="middle" />

  • A "bit" late but� THANKS Yann!!

    I was so mad with Timer until realize it was broken and looked for a solution � and it's quite recent, I had problems with it long ago, but just now when I tried to use again (forgot that something was wrong) that I decided to search the forum.

    Thanks again o/

    ~Alt+Tab� resuming project~

  • Looks like I can't use the new expressions, the "New Action" window says that "Parameter 1 of (...) does not take 'string'". (nor 'integer')

    But the most important for me works: simultaneous timers

  • WesleyNR

    Hmm weird, expressions works well with me. Maybe you did something wrong with the syntax and maybe I should have provided examples

    Anyway, the proper syntax is:

    If you created a timer like that

    Sprite: Start timer "test" with length 10000, Repeat, Don't destroy when finished

    you can get the current count and the initial value this way:

    Sprite[Timer].count("test")
    Sprite[Timer].initialValue("test")

    This way you can even display some percentages like this

    round((Sprite[Timer].count("test") / Sprite[Timer].initialValue("test")) * 100)

    (Ah I saw a small little mistake, for the initialValue expression it the default is value, it should be name)

  • After some tests, I see that the problem happens when "Sprite" (from the example) is a family instead of an object.

    And another thing I noticed is when you "start" a timer with 0ms, the game crashes. Surely no one would need a timer with 0ms, but maybe the lenght is in function of something else and if it becomes zero the crash can happen. We could also test if it's zero and don't try to start, but...

  • WesleyNR

    Thanks for the info, I'll see what I can do about it when I get home (:

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • Hi,

    I am new Construct2, so I cannot figure out how to add this external Timer plugin to Construct2. Please help me in this.

    Thanks.!

  • maxdilbe

    See where it says Construct Classic at the top?

  • Oh sh*t..!

    Sorry. Wrong place..

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)