How do I set an alarm sound when energy is low

Get help using Construct 2

Post » Mon Aug 22, 2016 2:19 am

I tried setting a global variable and, when below a certain number, a "warning alarm" goes off.

But when the number goes back up, it won't shut off.

I tried:

health < 20
alarmOn = false ..... Play "alarm" sound, alarmON = true

health > 20
alarmOn = true ......Stop "alarm" sound, alarmON = false


and no go.

Any help will be appreciated.
B
6
S
1
G
2
Posts: 9
Reputation: 893

Post » Mon Aug 22, 2016 3:38 am

Make alarmOn a global variable and use 0 for FALSE and use 1 for TRUE

alarmOn = 1 > Play "alarm"
alarmOn = 0 > Stop "alarm"

health<20 > Set alarmOn "1"
health>20 > Set alarmOn "0"
Image
B
75
S
23
G
3
Posts: 673
Reputation: 9,293

Post » Mon Aug 22, 2016 5:42 am

You can also try a every x seconds with else:

Health < 20
Every x seconds - play alarm

Else - stop alarm
Mistakes were made.
B
54
S
28
G
115
Posts: 1,705
Reputation: 65,083


Return to How do I....?

Who is online

Users browsing this forum: FabianB and 8 guests