Sound on/off animation

I have a button that I’ve added to my game to turn the background sound on and off. The noise itself cuts on and off as desired. But I can’t get the image to swap back and forth properly.

Here’s an image of the existing logic. I have the animation boxes set to stay on last frame when done.

1 Like

What isn’t working exactly?

Is ‘Loop animation’ on? If not, then the animation will play only for the period of time it takes to finish the animation.

I think the click down should go into next on the toggle as well as in. You also don’t need two animation blocks and can just put that it goes into the stop on the same one.

1 Like

It is on. But I want it to cut on and off in line with the sound turning on and off.

Right now, the default is for the sound to be on when starting the game. Once you click the button, the sound turns off and the ‘sound on’ graphic switches to the ‘sound off’ graphic with the current animations settings. However, if you want to turn it back on, clicking will turn the sound on but will not change the image back to the ‘sound on’ graphic.

I think I used something like this in my game. Let me check…

1 Like

Use this concept, it should work:

The ‘Resume’ animation is when the game is resumed. In your case it should be the animation for when the music is off. The ‘Paused’ animation, in your case, should be for when the music is going. Try that and tell me if anything goes wrong or if you need more screenshots.

1 Like

Thank you! I’ve updated my set up and it works properly turning the sound off. But it’s not changing back when I turn sound on. When I tested it, the out1 doesn’t activate. Does that have to do with the ‘once’ trigger?

The once trigger sets the block resumed. The object starts as paused and goes to resumed when the game starts. I’m pretty sure your problem is not because of the once trigger for it is unnecessary in your game (I think).

Can I have the link to the game please? It might be easier to help if I can test stuff on the game itself.

Yep! Here it is: Flowlab Game Creator - Avoid IT Disaster

Don’t use ‘Stay on last frame when done’, instead use ‘Loop animation’. That should work.

(If this works, please mark this post as a Solution.)

Make the animations just ‘ON’ and just ‘OFF’. That is the problem after ‘Loop Animation’ is activated.

Screenshot

Also, activate ‘Loop’:

(I tested it, it works for me now. Just change those things and it will work.)

2 Likes

That works, thank you!