Fangames > Programming Questions

Executing a Code after the Music Stops

(1/2) > >>

Tamatou:
Hello old friends!

I am making a Avoidance Medley with songs in a random order. Kinda like "I Wanna care about the Asteriod River"

Stupid Question, but how do I make the next song play, after the first one finished.
Like I want GM to execute a Code after a song finished that destroys all the cherries and chooses the next song randomly
I know how to make it choose a random song but how do I make it execute a code after a song finished playing?

lawatson:
try this code out to remove objects:
with playerKiller{
    instance_destroy();
}

just know that unless you use FMod or something you will have to make a whole lot of different sounds for each part of the song. I think I know a way to make it play the correct songs, but that aside, here's the code for stopping sounds:

sound_stop_all();

have fun making this

Tamatou:
Thank you for the Reply

I know how to stop sounds and how to destory instances but what I want is GM to execute a code (or just do something) after a song finishied playing.

I load the songs externally so I use this code:

--- Code: ---dice = round(random(6))

[code]dice = round(random(6))

if dice = 0
{
audio_playmusic(paul_chuck);
}

if dice = 1
{
audio_playmusic(lucky_star);
}

if dice = 2
{
audio_playmusic(hey_arnold);
}

if dice = 3
{
audio_playmusic(katy_kat);
}

if dice = 4
{
audio_playmusic(super_mario);
}

if dice = 5
{
audio_playmusic(guru_ant);
}

if dice = 6
{
audio_playmusic(andante);
}
--- End code ---

of corse alot more songs will be added.
What I want is GM to execute this same code (with slight alterations but that is not the point) again after one song finished playing.

I know I could do this with alarms but that would be a bit exhausting since all the songs are a different lengh (frame count) I just want GM to know when a song is done and make it choose the next one.

Arclooper:
Put the code inside an alarm and inside each if for a song you also put a timer for the same alarm with the size of the song. I mean, it bit be kinda annoying but it's the simplest way.

Though I guess you can also use  if !sound_isplaying(selected song) inside an if for the equivalent dice number for the song in the step event, that should prolly work too, but tbh that sounds like more work than just getting the times, personally :p


--- Code: ---if dice == 0
{
if !sound_isplaying(paul_chuck)
{dice = round(random(6))}
}

--- End code ---

Also I might be wrong but doesn't that code allow it for there to be repeats of the songs?

Keygrin:
If I wanted to avoid playing the same song until all the other songs are played...:


--- Code: ---if dice=0
{
global.song0=1
audio_playmusic(paul_chuck)
}


--- End code ---

In some Step Event:

--- Code: ---
if dice=0
if global.song0=1
dice = round(random(6))


--- End code ---

You'd want the dice variable to keep randomizing if it's on a value corresponding to the song that was already played. This probably won't work, though.

Navigation

[0] Message Index

[#] Next page

Go to full version