Does System Wait 1.0 seconds really work

Get help using Construct 2

Post » Mon Apr 22, 2013 7:03 pm

I have something like

Every tick & System(if varx > vary) -> Action -> System wait 1.0 secs
                                 -> add 1 to a variable

What I expect is that every time var x > var y the system will wait 1 sec then add 1 to that variable

but its like it jumps that adds 1 and then again after 1.0 wait it adds again.

Anyone?
Krish
Hey! Did you know that you can hire me to make your games?

Click Here to See More
B
21
S
6
G
5
Posts: 391
Reputation: 5,627

Post » Mon Apr 22, 2013 7:15 pm

@krish

What about using Every X Seconds and set every 1 seconds ?
B
5
G
1
Posts: 11
Reputation: 947

Post » Mon Apr 22, 2013 8:00 pm

'Wait' does *not* pause the rest of the events. Most people get caught out by this. In your case if the event is true every tick, it will schedule a new 'Wait' every tick, so after 1 second it adds to the variable every tick (~60 times a second).

You probably want to use the 'Every X seconds' condition instead.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,590

Post » Mon Apr 22, 2013 8:45 pm

well basically what I want to do is

Change opacity of a layer from 0->100 (in increments of 1 every tick)
wait 3 secs
Then change it back from 100 ->0 (in decrements of 1 every tick)
and keep doing so

The other way I can think of is to have a variable like OpacityWaitTime.. set it to 3 every time opacity of level touches 0 or 100, substract 1 from variable every second.. and as it touches 0, trigger off the increment/decrements again.

:(

Any other cool/shorter suggestions :)
Krish
Hey! Did you know that you can hire me to make your games?

Click Here to See More
B
21
S
6
G
5
Posts: 391
Reputation: 5,627

Post » Mon Apr 22, 2013 8:54 pm

If you add dt to a value every second, it will increase by 1 every second.
If you don't know how dt works, read the tutorial on 'delta time and framerate independence'.
You'll need a boolean to decide when to decrease/increase.

So your code will look something like this:

boolean variable called 'increase'

if increase = true:
add dt to opacity

if increase = false:
subtract dt from opacity

if opacity > or = 100, trigger once
set increase to false

if opacity < or = 0, trigger once
set increase to truesqiddster2013-04-22 20:55:11
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,400

Post » Mon Apr 22, 2013 9:33 pm

@sqiddster
I fail to see where it waits 3 seconds though :(
Probably too blind at the moment sorry :)

I got the opacity changing every second already.. the problem was to make it wait 3 sec at end of reaching 0 or 100 and then go the other way.krish2013-04-22 21:34:45
Krish
Hey! Did you know that you can hire me to make your games?

Click Here to See More
B
21
S
6
G
5
Posts: 391
Reputation: 5,627


Return to How do I....?

Who is online

Users browsing this forum: spacedoubt and 3 guests