Howdy, JJampion, and welcome to the GMC. $:^ ]
I know this has essentially been answered already, but I wanted to also answer for two reasons.
- I've been away for over a year because reasons. I could really use the quickie practice. $:^ P
- I find the above answers could be trimmed down a lot.
Now, there's plenty that could be said about object parenting and bit-flipping a bunch of different settings (and whether or not your sprite is animated and thus really needs two sprites or just one sprite with two frames, one on, one off), but right now, let's just stick to what you have here.
Let's say that your sprites are
spr_btn_music_on
and
spr_btn_music_off
with simple sprite masks, and that your default stuff is on. Let's also say you have a good way already to start your music, pause/mute/end your music, and resume/unmute/restart your music, whether via a main controller or this button or a global script or whatever. ~shrug~ You fiddle to what you need, obviously!
~~~~~~~~~~~~~
Music button, Create Event:
(the moment the game creates this instance in the room)
GML:
is_music = true;
// music playing code
Music button, Left Mouse Button Pressed Event:
(the moment the player clicks the instance with the left mouse button)
GML:
is_music = !is_music;
if (is_music) {
sprite_index = spr_btn_music_on;
// music on code
} else {
sprite_index = spr_btn_music_off;
// music off code
}
That's it! I hope this helps,