How do I trigger an event once only?

Just started using Construct 2? Post your questions here

Post » Sat Jul 25, 2015 6:07 am

Hi,

I have set a condition so that when score > 10 a notification will appear on screen as sprite. How do I make it so that it only appear once .. so that when the next time the player score more than 10 it won't appear again?
B
23
S
10
G
2
Posts: 104
Reputation: 3,071

Post » Sat Jul 25, 2015 6:23 am

There may be a better way of doing it, but I'd just have a global variable that is set to 0, and change it to 1 when the event happens the first time. Check the variable every time the event gets called, and only do your event actions when the global variable is set to 0.
B
29
S
16
G
23
Posts: 68
Reputation: 13,723

Post » Sat Jul 25, 2015 7:33 am

Thanks terrancd. It worked :)
B
23
S
10
G
2
Posts: 104
Reputation: 3,071

Post » Sun Jul 26, 2015 7:33 am

Add the "Trigger Once While True" System condition to the event. It must be at the bottom of the list of conditions.

It will trigger once, and only trigger again once the condition becomes false, then true again.

Then to disable this, you could either keep it in a group and deactivate the group in the actions, or use a global boolean as previous suggested.

I prefer to use groups for activating / deactivating bits of functionality.
B
12
S
4
Posts: 48
Reputation: 910


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 1 guest