M
matthulm
Guest
Hello,
I can't quite get my head around how this 'if' statement
I'm currently setting up a settings menu that will create different button objects, then once I close the settings menu, it will destroy those buttons. However, the 'if' statement keeps creating the buttons every step.
The 'if' statement is located in a "Step" event, and I've set it so the buttons will only spawn if the button does not already exist. I've used this technique before and it has worked fine but for some reason it's having issues now
The settings button works fine on the menu, but not the level room
Any help would be much appreciated
EDIT 1: I've set an alarm to delay the instance_create_layer(); and that has not worked
EDIT 2: Turns out I was accidentally destroying my controller object which handled the code to destroy the objects
I can't quite get my head around how this 'if' statement
I'm currently setting up a settings menu that will create different button objects, then once I close the settings menu, it will destroy those buttons. However, the 'if' statement keeps creating the buttons every step.
Code:
/// @description Insert description here
// You can write your code in this editor
if settings = 1
{
if room = rmmenu
{
instance_deactivate_object(oplay);
instance_deactivate_object(oleader);
//instance_deactivate_object(osettingsbut);
if !instance_exists(osoundbut)
{
instance_create_layer(room_width/2+300,room_height/2-60,"INSTANCES",osoundbut);
}
if !instance_exists(omusicbut)
{
instance_create_layer(room_width/2+300,room_height/2+60,"INSTANCES",omusicbut);
}
}
if room = rmlevel
{
instance_deactivate_layer("Instances");
if !instance_exists(osoundbut)
{
if instance_create_layer(room_width/2+300,room_height/2-60,"INSTANCES",osoundbut)
{
show_debug_message("Sound Button Created")
}
}
if !instance_exists(omusicbut)
{
instance_create_layer(room_width/2+300,room_height/2+60,"INSTANCES",omusicbut);
}
}
The settings button works fine on the menu, but not the level room
Any help would be much appreciated
EDIT 1: I've set an alarm to delay the instance_create_layer(); and that has not worked
EDIT 2: Turns out I was accidentally destroying my controller object which handled the code to destroy the objects
Last edited by a moderator: