D
Deleted member 45063
Guest
Hello GMC.
I just created a new project in which I use different control objects, each one responsible for managing a different module of the game. Since instances are organized in layers I wanted all of my control objects to be in a single "control" layer. In order to do this in the first room I execute a piece of code that iterates through all rooms and adds the layer if it isn't present there already. However when I do this the creation of the first control object in that same room fails with the following error message:
In order to reproduce this just create a new GML project with a blank object called ctrl_dummy and a room callled rm_init with the following room creation code:
I haven't used GameMaker in some years so is there something that I am just missing entirely or should the layer be recognized?
Thanks in advance for your support!
I just created a new project in which I use different control objects, each one responsible for managing a different module of the game. Since instances are organized in layers I wanted all of my control objects to be in a single "control" layer. In order to do this in the first room I execute a piece of code that iterates through all rooms and adds the layer if it isn't present there already. However when I do this the creation of the first control object in that same room fails with the following error message:
Code:
___________________________________________
############################################################################################
FATAL FATAL ERROR in Room Creation Code for room rm_init
instance_create_layer :: specified layer "control" does not exist
at gml_Room_rm_init_Create (line 15) - instance_create_layer(0, 0, LAYER_NAME, ctrl_dummy);
############################################################################################
--------------------------------------------------------------------------------------------
stack frame is
gml_Room_rm_init_Create (line 15)
Code:
#macro LAYER_NAME "control"
#macro LAYER_DEPTH -10000
var current_room = 0;
while (room_exists(current_room)) {
layer_set_target_room(current_room);
if (!layer_exists(LAYER_NAME)) {
show_debug_message("Create layer for " + room_get_name(current_room));
layer_create(LAYER_DEPTH, LAYER_NAME);
}
current_room++;
}
layer_reset_target_room();
instance_create_layer(0, 0, LAYER_NAME, ctrl_dummy);
Thanks in advance for your support!
IDE Version 2.2.4.474, Runtime 2.2.4.374, Windows 10