Legacy GM Looping music

M

Middy_Moony

Guest
Right hello there guys and gals.

The question i have for you is about Music Looping cause its something i have no clue about like i have a piece of music that starts a loop at 0:27 and the loop finished at 1:51 how would i do it so when the music piece hits 1:51 it loops back to 0:27 so that i have a seamless looping piece of music?
 
A

Aura

Guest
Initialize a variable that tells you if the first part has been played.

Code:
played = false;
In the Step event, if the music isn't being played already, check if this variable is false. If it is, play the sound and if it isn't, play the sound and set the track position using the audio_sound_set_track_position() function.

Code:
if (!audio_is_playing(snd_MainTrack)) {
   if (!played) {
      audio_play_sound(snd_MainTrack, 0, false);
   }
   else {
      var snd = audio_play_sound(snd_MainTrack, 0, false);
      audio_sound_set_track_position(snd, 27);
   }
}
 
Top