Audio on/off

Get help using Construct 2

Post » Thu Oct 24, 2013 7:25 pm

Hey all,

I've got problem with audio.

There is my .capx file:
http://ge.tt/9nP5VAw/v/0

I want to have on/off button to music. When player click music button, background music is off, and on that button will show mute icon, when he click again on that button, he got back music and mute icon is destroyed.

I don't know how to fix that ;/
B
10
S
3
G
1
Posts: 14
Reputation: 1,220

Post » Thu Oct 24, 2013 7:54 pm

http://s000.tinyupload.com/index.php?file_id=94856930351796752422

Main problem was onoff=1 condition always triggering, because you set it to 1 in the subevent before this, in case it wasn't already 1. Use else instead.
Visual Novel 'Engine' in 100 Events
if you ever have to choose between buying Construct 2 on scirra.com or on Steam, read this: Review
B
22
S
9
G
1
Posts: 788
Reputation: 3,788

Post » Thu Oct 24, 2013 8:07 pm

Thanks for your help.

I should do any global variable if I want have audio control in settings panel of game?
B
10
S
3
G
1
Posts: 14
Reputation: 1,220

Post » Thu Oct 24, 2013 10:22 pm

Haven't worked with audio yet (I'm rather new to the program myself), but:

with audio there comes a condition: is silent. And you can set the game to silent. So there is not really a need for a "muted"-variable.
Other than that, if you want your player to adjust volume levels for music, speech, sound effects differently, I guess you need 3 global variables, each standing for the volume decrease for bgm, speech, sfx. And for each tick, set the volume for the tag bgm to x, speech to y and sfx to z.
Visual Novel 'Engine' in 100 Events
if you ever have to choose between buying Construct 2 on scirra.com or on Steam, read this: Review
B
22
S
9
G
1
Posts: 788
Reputation: 3,788

Post » Thu Oct 24, 2013 11:24 pm

I usually set a global variable so that when they return to the page, it remember's that they turned off the music.

I make a sprite button with two frames, 0=on & 1=off
the global variable hold the same values so the frame can be set with it when returning to the page.

I check the sprite for a touch and if the sprite is on frame 0 switch it to 1 and if it's a 1 switch it to 0. and set the global.


The common problem with buttons:
since the second event also sees the click, and the frame switched in the first event to 1, it will fire switching it right back to 0.

So, when the first event fires, wait 0 or .1 before setting the value, so that it will wait a tick before setting the value. The second event saw the value was still 0 and didn't fire. Then the value changes next tick.

(wait 0 waits until the next tick.)Paradox2013-10-24 23:34:48
B
239
S
62
G
33
Posts: 903
Reputation: 40,562

Post » Fri Oct 25, 2013 9:32 am

@Paradox thanks for that advice, but I have still problem, when I go to other layout music is playing (when is on) but when I come back to start layout music start playing from begining.

You can check this there:   http://ge.tt/6GiQqDw/v/0 Abdizriel2013-10-25 11:27:46
B
10
S
3
G
1
Posts: 14
Reputation: 1,220


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 41 guests