Y
Yobokkie
Guest
Greetings to all, I'm messing around with game maker and learning the ropes. But I've hit a bit of a snag that google seems unable to help me with.
Basically I have a controller object that runs various things in a room and I'm trying to get it to play the background music based on a variable set in the instance creation code. So in my creation code for the controller object I have: global.bgmusic = bgm_1;
And then on the create event of the object I have a script that says audio_play_sound(global.bgmusic, 1, true);
But the game keeps giving an error to say the variable doesn't exists. I'm sure it's something noob I'm doing wrong, but I can't find any answers and from what I can see the instance creation code should run before the create event, so why is it giving the error to say that the variable doesn't exist?
If this isn't the right way to go about playing music for different rooms, perhaps someone could point me in the right direction? I'd prefer to have attached to an object for the sake of persistence, and not restarting every time the room is changed.
Thanks for your help, I've learnt a lot just by lurking here and reading other people responses.
Basically I have a controller object that runs various things in a room and I'm trying to get it to play the background music based on a variable set in the instance creation code. So in my creation code for the controller object I have: global.bgmusic = bgm_1;
And then on the create event of the object I have a script that says audio_play_sound(global.bgmusic, 1, true);
But the game keeps giving an error to say the variable doesn't exists. I'm sure it's something noob I'm doing wrong, but I can't find any answers and from what I can see the instance creation code should run before the create event, so why is it giving the error to say that the variable doesn't exist?
If this isn't the right way to go about playing music for different rooms, perhaps someone could point me in the right direction? I'd prefer to have attached to an object for the sake of persistence, and not restarting every time the room is changed.
Thanks for your help, I've learnt a lot just by lurking here and reading other people responses.