every 1 second

0 favourites
  • 14 posts
From the Asset Store
This is a Dungeon Master tool & the 1st of 12 Combat Engines from the Building Combat Engines for Browser Games workshop
  • Hi there, I was wondering how I can use the event every 1 second, and I really need so much, as that even when the window is not focused, the event stay running and decreasing the counter.

    I need this cause I run the game on facebook with a timer that needs to be accurate for each move of player.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • when you add an event in the event sheet and select "system" as the object, there is a selection at the bottom called "Every X Seconds" This performs an action one for every interval between the number of seconds you have selected.

    Is this what you were looking for?

  • MarkRMichaels - unfortunately not, considering that I tried this way and others, but it seems that construct2 takes into account many things such as to render (fps) to give the value of every x second.

    If I put a count of 90 seconds and I need every one second subtract 1 from the counter until it reaches zero, it must be the most accurate.. and the rates vary widely, sometimes going one second, will further 0.7 seconds, and still 1.2/1.4 seconds, this makes the 90 seconds impractical and totally wrong.

  • try adding int.

    Every int(1) second

  • - uhm, I tried with every round(1) and also failed :(

  • I've found a very weird bug, here's a capx for you to see

    First test the game, and notice how the "every 1 second" event works as expected. Then comment the "Text2" event and test again. Now the "every 1 second" seems to have a huge random variation, a lot faster than 1 second.

  • I believe the "Every X Second" condition is based on your frame rate, like a lot of other things in Construct. In which case you would need to be getting a constant 30 frames per second to get an accurate timer. I don't know much about HTML 5 but if this is how Scirra has implemented it, that means there's probably no better way.

    You may want to look into ways to increase the consistency of your frame rate, if possible.

  • actually the game I'm doing is so simple, yet so simple that it is impossible to understand why the frame rates vary so much. : (

  • hmm.. i did a simple test for "Every X seconds" and it works fine on my machine

    <img src="http://i41.tinypic.com/35m2xjb.jpg" border="0">

    capx:

    http://dl.dropbox.com/u/39382262/Timer.capx

  • "Every X seconds" is not affected by the framerate - it runs based on real-world time rather than ticks.

    However, I think a few people are being thrown off by a current bug in Chrome 18. If there is nothing changing on the screen, the game will start running at hundreds of frames per second and the timers all screw up. The fix is to make sure you change something every frame - try just putting an unused text object outside the layout and always set it to tickcount to fix it.

    The problem should not happen in any other browser and is also fixed already in Chrome 19 so should disappear in a few weeks.

  • Ashley, I'm trying to use the factors to come up with everytick in milliseconds, just by multiply 60*Xquantity of seconds (which is the rate of frames per second)

  • Oh wow, haha. My apologies for the blatant misinformation. I took the tid-bit about "intervals being limited by the frame-rate" to mean that the counter is dependent of the frame rate.

  • I had only the text showing a number in that capx I posted, and the framerate was at between 100 and 700, so I guess that's the bug Ashley mentioned

  • "Every X seconds" is not affected by the framerate - it runs based on real-world time rather than ticks.

    However, I think a few people are being thrown off by a current bug in Chrome 18. If there is nothing changing on the screen, the game will start running at hundreds of frames per second and the timers all screw up. The fix is to make sure you change something every frame - try just putting an unused text object outside the layout and always set it to tickcount to fix it.

    The problem should not happen in any other browser and is also fixed already in Chrome 19 so should disappear in a few weeks.

    Thanks a lot for this.

    I was actually going mad over it already, as my timer would decrease at a random speed when idle'ing.

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