Help with Constant Variables?

Get help using Construct 2

Post » Wed Feb 26, 2014 11:07 am

Not sure if my topic title helps at all but basically I have run into a problem and I am pretty sure I know what is causing it. Take a look.

Image

The variable CurrentLayout is always true. How do I make it so when the variable is updated, all events related to that are only "Ran Once" sort-a-thing?
Thank you!
B
56
S
15
G
13
Posts: 825
Reputation: 17,643

Post » Wed Feb 26, 2014 11:55 am

Try to add the "Trigger Once" condition :) It will trigger "once will true".
B
39
S
15
G
5
Posts: 295
Reputation: 6,089

Post » Wed Feb 26, 2014 12:04 pm

I was about to say the same thing. ;)
B
11
S
5
G
2
Posts: 496
Reputation: 2,306

Post » Wed Feb 26, 2014 12:15 pm

@Joskin there is no way to "Trigger Once". Its constantly true.

Edit:
Here is what I did. Still not working.
Image
B
56
S
15
G
13
Posts: 825
Reputation: 17,643

Post » Wed Feb 26, 2014 12:33 pm

From the manual :

Trigger once while true
Turn an ordinary event (which is tested every tick) in to a trigger. For example, if an event plays a sound when lives equals 0, normally this event runs every tick. This plays about 60 sounds a second and would sound pretty bad. Adding Trigger once while true after the other conditions makes the event run just once when it first becomes true. This makes the previous example only play a sound once the first time your lives reaches 0. It must be the last condition in an event.

So normally it should work if you place the trigger once after the condition ! :)
B
39
S
15
G
5
Posts: 295
Reputation: 6,089

Post » Wed Feb 26, 2014 12:40 pm

This may not work because you change layout. It is possible (i'm not sure) that the "once while true" doesn't work between layouts. In this case, functions is the way to go. Keep updating "currentLayout" like you do, but after substracting/adding one to currentLayout, call a function "changeLayout" in witch you put all the other events. Remove the "once while true" if you do so.
This way, those events won't be evaluated every tick, but only when the user clicks on sprLeft or sprRight.
B
17
S
8
G
4
Posts: 461
Reputation: 6,127

Post » Wed Feb 26, 2014 1:01 pm

Never used Functions before. Guess it's time to learn.
B
56
S
15
G
13
Posts: 825
Reputation: 17,643

Post » Wed Feb 26, 2014 1:03 pm

@Tekniko it doesn't work with the trigger once after the condition CurrentLayout = x ?
B
39
S
15
G
5
Posts: 295
Reputation: 6,089

Post » Wed Feb 26, 2014 10:16 pm

Alright, here is what I came up with. Everything seems to work now. Thank you all! @Joskin @Guizmus

Image
B
56
S
15
G
13
Posts: 825
Reputation: 17,643


Return to How do I....?

Who is online

Users browsing this forum: Apollo14, MaujDeveloper and 5 guests