Make a sound play only once on VARIABLE = 0

Get help using Construct 2

Post » Mon Dec 05, 2011 1:47 pm

Hi!

I'm trying to make a sound play only once when a variable arrives at zero.

I'm making a zombie killing game and when the zombie count arrives at zero I play a sound and show a screen that says winner, etc.

But the problem is that the sounds get played back-to-back on every tick and it's making an insane effect hehe. Here's what I've done:



Thanks!
B
6
G
2
Posts: 43
Reputation: 1,211

Post » Mon Dec 05, 2011 2:03 pm

Add the "Trigger once" condition
B
62
S
21
G
12
Posts: 1,910
Reputation: 13,155

Post » Mon Dec 05, 2011 2:12 pm

Oh I wasn't aware of this condition! Thank you!
B
6
G
2
Posts: 43
Reputation: 1,211

Post » Mon Dec 05, 2011 4:26 pm

Oh but, in this "Trigger Once" there's no condition to put? How do I trigger it once if let's say : NB_ENEMIES arrives at zero? Thanks!
B
6
G
2
Posts: 43
Reputation: 1,211

Post » Mon Dec 05, 2011 4:51 pm

Example capx

AS you can see, I used the expression "Count" that counts the number of instances of an object on screen.

In events, you can associate several conditions (right click, add another condition)

Also the order in which the conditions are placed matters. At first, I had "Trigger once while true" as the first condition, and it did not work. Placing it as a second event works as intended.

This example might not apply totally to what you're doing. But I guess it is a good base, and with a few tweaking/adaptation it will fit right in.

And nothing prevents you from comparing a variable rather than an expression.Kyatric2011-12-05 16:52:09
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,999
Reputation: 57,793

Post » Mon Dec 05, 2011 5:29 pm

You just add 'trigger once' at the bottom of the event you want to trigger once.
Scirra Founder
B
359
S
214
G
72
Posts: 22,949
Reputation: 178,544

Post » Mon Dec 05, 2011 11:15 pm

Thanks to both of you!

Both of your answers served me very well!

I'm starting to get all the posibilites C2 has to offer. Seriously, I'm starting to have a very good game hehe.

I'll put it up on the arcade as soon as I have a complete level!

This is AWESOME! :-)
B
6
G
2
Posts: 43
Reputation: 1,211


Return to How do I....?

Who is online

Users browsing this forum: 99Instances2Go, Yahoo [Bot] and 26 guests