Confused with every X seconds

Discussion and feedback on Construct 2

Post » Thu Jun 02, 2016 9:10 pm

Hi, I am confused with the operation of every X seconds.

I create an object every 5 seconds but if you reset the layout to the third second (for example), then the object is now created after two seconds.
That is, the time has not been restarted!.

Is there any way to reset the time used in every X seconds when a layout restarts?

https://dl.dropboxusercontent.com/u/60803633/test18.capx

Image

Here you can see a picture of what I mean.

If you restart the layout in the second number 4, then after rebooting, after 1 second the object was created but I am using every 5 secs!.

Image
B
29
S
12
G
21
Posts: 801
Reputation: 14,453

Post » Thu Jun 02, 2016 9:18 pm

This is documented in the manual. If you want accurate timing, use the Timer behaviour.
ImageImageImage
B
71
S
22
G
240
Posts: 3,732
Reputation: 133,990

Post » Thu Jun 02, 2016 9:29 pm

I did not see anything about this here:

Every X seconds
Run the event regularly at a given time interval in seconds. This can also be used beneath other conditions to only run the event at a given time interval while the other conditions are true, e.g. "Player is holding spacebar AND every 0.5 seconds: fire laser".

I assume you mean the downloadable manual
B
29
S
12
G
21
Posts: 801
Reputation: 14,453

Post » Thu Jun 02, 2016 9:45 pm

It's in there somewhere. Every X seconds is based on the time the app starts, not when the layout starts.
ImageImageImage
B
71
S
22
G
240
Posts: 3,732
Reputation: 133,990

Post » Fri Jun 03, 2016 6:52 am

To make a timer that restarts every time the layout starts could be done many ways. Probably an easy pseudo example would be something like;
--------------------------------------------
Start of layout -> Set Global variable (timer) = 0

Every 1.0 seconds -> Add 1 to Global variable (timer)

If global variable (timer) = 5 -> do something
--------------------------------------------

Making a repeatable action would be a little trickier, but using a variable as the timer itself could work for sure.

*EDIT*
Just looked more closely at your event sheet there, and you're doing exactly this method already but maybe forgetting to set your variable on startup to 0. Global variables will always remember where they're at unless the program starts from the beginning again. You just need a reset on the variable you're already using when the layout starts up.

~Sol
Tired of crappy file hosts that are crappy? Get DROPBOX - https://db.tt/uwjysXJF
Moderator
B
83
S
34
G
40
Posts: 3,032
Reputation: 30,474


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 10 guests