LazyTomato
Member
I wasn't really sure if i should post this here or in the programming section, but this is a problem i've had exclusively with GMS2 so i guess this'll have to do
So my game has a variable called global.music, which I use to handle what music is playing, fade it in and out and other fancy things. The game starts up at an init room that runs a script to set up every important variable for the game, then goes to the next room instantly (i.e. the title screen).
This script, among other things, loads the two main audiogroups in my game (audiogroup_music and audiogroup_sfx)
Now, as soon as i get to the title screen, some creation code for that room is supposed to assign a sound to the global.music variable and play it (so audio_play_sound(mus_title,1,1) )
So the problem here is: The title music doesn't play at all. Rest of the sounds in the game play just fine as soon as I start playing, and sound effects work too, but the music that was supposed to play when entering the room just isn't there. And the thing is, the sound does play if i take it out of my custom audiogroup and back into audiogroup_default.
I've also noticed that manually going back to the title screen after changing rooms to an in-game room makes the music play regardless of audiogroup. So I'm assuming it has something to do with the first time I'm attempting to play the sound... Which is weird, seeing as I started this game on GMS1 before porting it to GMS2, and this same code used to work perfectly fine.
I doubt it'll help much but here's the code i'm running:
So my game has a variable called global.music, which I use to handle what music is playing, fade it in and out and other fancy things. The game starts up at an init room that runs a script to set up every important variable for the game, then goes to the next room instantly (i.e. the title screen).
This script, among other things, loads the two main audiogroups in my game (audiogroup_music and audiogroup_sfx)
Now, as soon as i get to the title screen, some creation code for that room is supposed to assign a sound to the global.music variable and play it (so audio_play_sound(mus_title,1,1) )
So the problem here is: The title music doesn't play at all. Rest of the sounds in the game play just fine as soon as I start playing, and sound effects work too, but the music that was supposed to play when entering the room just isn't there. And the thing is, the sound does play if i take it out of my custom audiogroup and back into audiogroup_default.
I've also noticed that manually going back to the title screen after changing rooms to an in-game room makes the music play regardless of audiogroup. So I'm assuming it has something to do with the first time I'm attempting to play the sound... Which is weird, seeing as I started this game on GMS1 before porting it to GMS2, and this same code used to work perfectly fine.
I doubt it'll help much but here's the code i'm running:
Code:
//game_init()
//First setup, AKA absolutely everything
audio_channel_num(64)
audio_group_load(audiogroup_music)
audio_group_load(audiogroup_sfx)
audio_group_set_gain(audiogroup_music,1,0)
audio_group_set_gain(audiogroup_sfx,1,0)
global.music=-1
global.music_battle=-1
globalvar battle_mode;
battle_mode=false //Determines if we're currently in a battle or not. Used for music changing and such.
//Control setup
enum key { left, right, up, down, attack, shoot, jump, pause, menu_enter, menu_back };
for(var i=10; i>0; i--) global.keys[i] = 0;
global.keys[key.left] = vk_left
global.keys[key.right] = vk_right
global.keys[key.up] = vk_up
global.keys[key.down] = vk_down
global.keys[key.attack] = ord("X")
global.keys[key.shoot] = ord("C")
global.keys[key.jump] = ord("Z")
global.keys[key.pause] = vk_escape
global.keys[key.menu_enter] = ord("X")
global.keys[key.menu_back] = ord("Z")
room_goto_next();