How do I toggle sound in cocoon JS?

Get help using Construct 2

Post » Tue Jun 10, 2014 5:09 am

You can try changing the master volume or by tag. Instead of using dB I use this formula to put a volume from 0 to 100
Code: Select all
33*log10(X/100)
for X from 0 to 100, or
Code: Select all
33*log10(X)
for X from 0 to 1.
For toggle try this:
Image
B
81
S
21
G
23
Posts: 515
Reputation: 18,702

Post » Tue Jun 10, 2014 10:29 am

Cipriux wrote:You can try changing the master volume or by tag. Instead of using dB I use this formula to put a volume from 0 to 100
Code: Select all
33*log10(X/100)
for X from 0 to 100, or
Code: Select all
33*log10(X)
for X from 0 to 1.
For toggle try this:
Image


Thanks!
Gonna try it soon! :D
B
8
S
2
Posts: 203
Reputation: 1,169

Post » Thu Jun 12, 2014 7:28 am

@ijoin

I handle the sound toggling with a global variable "Sound". If Sound=1 all sounds will be played.

Live-HTML Demo: http://envato.wdbase.de/wp-content/demo/candyland/

This is the code behind handling the toggle function/animation.
toggle_sound.png


And this is the sound function handling the playing of the sound if it's enabled.
toggle_sound_2.png


This is a very simple function, but it works perfect on all platforms i've tried so far.
You do not have the required permissions to view the files attached to this post.
Image Image iTunes: Match3 | Google Play: Match3
B
100
S
35
G
30
Posts: 1,136
Reputation: 28,085

Post » Thu Jun 12, 2014 9:21 am

AndreasR wrote:@ijoin

I handle the sound toggling with a global variable "Sound". If Sound=1 all sounds will be played.

Live-HTML Demo: http://envato.wdbase.de/wp-content/demo/candyland/

This is the code behind handling the toggle function/animation.
toggle_sound.png


And this is the sound function handling the playing of the sound if it's enabled.
toggle_sound_2.png


This is a very simple function, but it works perfect on all platforms i've tried so far.


Thanks @AndreasR
Glad, Construct 2 community has someone helpful like you :D

Btw, tried your candygame, got any tutorial to make select character and the doodle system?

Thanks again!
B
8
S
2
Posts: 203
Reputation: 1,169

Post » Thu Jun 12, 2014 1:09 pm

@ijoin I'm glad to help you out ;)
No it's no tutorial planned, but i also will offer this game at codecanyon for about 10-13$. Game is on upload and if you are interessted feel free to buy it. It includes the complete C2 project and all Graphics (free license for privat and commerical) and I give full support to my basements and you are allowed to publish and modify it on any platform you wish ;)

It should be online in a few days, just PM me if you want know more about and i can provide you the link ;)
Image Image iTunes: Match3 | Google Play: Match3
B
100
S
35
G
30
Posts: 1,136
Reputation: 28,085

Post » Sun Feb 28, 2016 4:14 am

I really thought that Construct 2 would contain a global "mute audio" action. I was stunned to discover that it contains a plethora of audio actions but not a simple global "Mute/Unmute All". I struggled with this until I found @Cipriux 's example above:

Cipriux wrote:You can try changing the master volume or by tag. Instead of using dB I use this formula


I'm used to seeing code but missing hidden stuff out because a capx is worth a thousand images, so I really thought your solution was too good to be true. But, hey ho, it really is as simple as that! Just a variable and 2 lines of code! I had been struggling with this for hours so @Cipriux thank you SO much! :D

I couldn't get any of the other proposed solutions on this page to do what I wanted but @Cipriux nailed it :)

"To be yourself in a world that is constantly trying to make you something else is the greatest accomplishment."

Ralph Waldo Emerson
B
10
S
2
G
1
Posts: 56
Reputation: 1,300

Post » Tue Mar 08, 2016 8:32 pm

@cipriux, awesome thank you. Why 33? Just could not figure that out? Perhaps I am being daft?
B
13
S
4
Posts: 67
Reputation: 1,270

Post » Tue Mar 08, 2016 8:45 pm

@AngelEyes I didn't came up with the formula, I found it digging the internet or this forum, I don't remember, it was 2 years ago. The formula must be an approximation of a more complex function....I don't know :)
B
81
S
21
G
23
Posts: 515
Reputation: 18,702

Post » Wed Mar 09, 2016 7:37 pm

Thanks @Cipriux, I did realise that it all happened a while back. Never the less, it was really helpful thanks.
B
13
S
4
Posts: 67
Reputation: 1,270

Previous

Return to How do I....?

Who is online

Users browsing this forum: dop2000, gonzdevour and 39 guests