• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GameMaker Question about rooms and objects

U

User

Guest
For about three days I'm testing my code. And noticed an interesting "feature".
I create a room - loading_room. I want run some preload script (scripts in the future) in this room.
Now the script is small and it runs very quickly.
Then i want to go to the next room.

loading_room RoomCreationCode
Code:
some_small_script();
room_goto_next();
In the future i will have more scripts. The load will be longer.
And I have to show something to the user. For example the text - "Loading - pls wait...".
So I need to place the object in the room. Set its properties and events.
Now we have an object, some_small_script(); and room_goto_next();

And in 40% of cases this code will cause an error. But if we do delay about 1-2 seconds (use alarm in another object) - there will be no error.

As I understand it, the following happens:
the first RoomCreationCode is executed
the second - object events code
And if we use room_goto_next(); in RoomCreationCode, we may not be able to complete the object events code.
I'm right?

Will it be a universal solution to place in the room a timer object (alarm->room_goto_next())?
Timer object with a value of 1 (lets set the minimum value).
And place this timer object (instance) last in the Instance Creation Order of this room.

So first will be load RoomCreationCode, then all objects (instance code) and last instance - timer object (instance) and we go to the next room.
This ensures that all code is executed and there will be no errors.
I'm right?
 
Top