every 1 second

Get help using Construct 2

Post » Tue Apr 17, 2012 4:57 pm

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.
B
123
S
19
G
16
Posts: 487
Reputation: 21,498

Post » Tue Apr 17, 2012 5:11 pm

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?
B
14
Posts: 5
Reputation: 587

Post » Tue Apr 17, 2012 5:19 pm

@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.
B
123
S
19
G
16
Posts: 487
Reputation: 21,498

Post » Tue Apr 17, 2012 5:26 pm

try adding int.

Every int(1) second
B
13
S
2
Posts: 87
Reputation: 1,244

Post » Tue Apr 17, 2012 5:28 pm

@hugothewhitewolf - uhm, I tried with every round(1) and also failed :(
B
123
S
19
G
16
Posts: 487
Reputation: 21,498

Post » Tue Apr 17, 2012 6:03 pm

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.
B
83
S
21
G
15
Posts: 1,039
Reputation: 15,134

Post » Tue Apr 17, 2012 6:17 pm

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.MarkRMichaels2012-04-17 18:18:29
B
14
Posts: 5
Reputation: 587

Post » Tue Apr 17, 2012 6:27 pm

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. : (
B
123
S
19
G
16
Posts: 487
Reputation: 21,498

Post » Tue Apr 17, 2012 6:35 pm

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



capx:
http://dl.dropbox.com/u/39382262/Timer.capx
B
34
S
13
G
8
Posts: 134
Reputation: 8,118

Post » Tue Apr 17, 2012 7:31 pm

"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.
Scirra Founder
B
359
S
214
G
72
Posts: 22,948
Reputation: 178,532

Next

Return to How do I....?

Who is online

Users browsing this forum: Braus and 14 guests