Help using the WAIT command -- noob question

Get help using Construct 2

Post » Sat Jan 26, 2013 4:01 am

I am making a Gremlins game and during the bonus round it shows the mogwai's that you've saved one by one, left to right, with about a 1 second delay before the next one is presented.

Although it works fine with no delay, if I put the delay in, the behavior becomes unpredictable and it does not work correctly.

I do understand that this is not working because despite reading several tutorials and forum posts on the wait command, I cannot seem to get my head around it.

Here are some screenshots:
(everything in red is not in the game itself)



Here is the code that I am using to do it, but take into account, it does not work correctly.



Can anyone suggest a simple way to add a delay as each mogwai is shown?
B
15
S
2
G
3
Posts: 61
Reputation: 2,321

Post » Sat Jan 26, 2013 4:23 am

Wait causes many people grief until they get it. Wait does NOT stop the game from progressing. What happens is that, to the side, in parallel, there is a wait and then any actions/sub-events immediately FOLLOWING the wait action are performed.

Your code, as is, is going to continually loop in the WHILE event because of this, but the two MogweiNumber sub-events will occur after one second (with the Wait turned on again that is).

Hopefully this is enough to let you rethink your wait code.
ImageImageImage
B
67
S
19
G
123
Posts: 3,208
Reputation: 73,903

Post » Sat Jan 26, 2013 4:14 pm

All I really want it to do is, instead of putting the little mogwais in a line all at once, It will display them 1 at a time.

Doesn't seem like it would be that tough, I just don't know how to do it.
B
15
S
2
G
3
Posts: 61
Reputation: 2,321

Post » Sat Jan 26, 2013 5:11 pm

I think if you add an Every 1 Second condition it will cause a wait in between. Not on computer so I can't confirm this though.
B
40
S
12
G
7
Posts: 603
Reputation: 7,656

Post » Sat Jan 26, 2013 5:20 pm

One possibility:
ImageImageImage
B
67
S
19
G
123
Posts: 3,208
Reputation: 73,903

Post » Sat Jan 26, 2013 5:25 pm

I would suggest making your own timer and not let the game progress unless the timer is at 0:

timer.capx (r116)
B
27
S
8
G
8
Posts: 903
Reputation: 8,452

Post » Sat Jan 26, 2013 5:30 pm

EncryptedCow's method also works.


There is a subtle difference though. This method only runs on every second since the game began. For one second you don't really notice anything, but if the delay was longer, say 10 seconds, the first run can take anywhere from 0 to 10 seconds to start.

Note: You don't need/want the WHILE in your code.blackhornet2013-01-26 17:43:35
ImageImageImage
B
67
S
19
G
123
Posts: 3,208
Reputation: 73,903

Post » Tue Jan 29, 2013 5:00 am



I like this code , but what is that variable called 'dt'?

B
15
S
2
G
3
Posts: 61
Reputation: 2,321

Post » Tue Jan 29, 2013 10:18 pm

It's delta-time, read this tutorial for more info.
B
27
S
8
G
8
Posts: 903
Reputation: 8,452


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 20 guests