Legacy GM instance_create doesn 't work

H

Hoepilaar

Guest
I am trying to create a button that when pressed creates a GUI on the side of the room. for the GUI to be interactive, i made buttons (obj_more, obj_less) wich should spawn when the button is pressed. But when I try the code I also used for another button (wich worked) it didn 't work. I also didn 't get any errors. Here 's my code (inside left click event)
Code:
global.ActiveMenu = sbuild;
global.ActiveState = 0;

//create more and less
var more = instance_create(712, 184, obj_more);
more.modGoal = BuildObj;
var less = instance_create(904, 184, obj_less);
less.modGoal = BuildObj;
if (anyoneCouldHelp == true) {
draw_text(0, 0, "that would be awesome!");
}
 

Misty

Member
In each object's create event put a show message. That will show if the object is real for sure.
 

Simon Gust

Member
Is the event the global left mouse button click event? Make sure it's the global one.
A quick way to test if the event is firing at all is to put a
Code:
game_end();
into it and see if the game closes.
 
H

Hoepilaar

Guest
Is the event the global left mouse button click event? Make sure it's the global one.
A quick way to test if the event is firing at all is to put a
Code:
game_end();
into it and see if the game closes.
In each object's create event put a show message. That will show if the object is real for sure.
So I used de debug module (F6) to test if the instances acctually spawned, and no they didnt, but the script did fire (after testing with game_end). Making it a global mouse event just broke the whole game so that wasnt the solution either.
 

Misty

Member
Put a show_message in the Step event of obj_more and obj_less and see how many times it fires. (Put "-1" as the message of obj_less and "1" as the message of obj_more.)
 
what does modGoal do and whats BuildObj -is it an instance_create() too?- and actually I've encountered problems with using those DnD mouse click events which didn't work but when I tried a key, it did work strangely, maybe they are like collision based clicking upon the object that the event exist.

Try point_in_rectangle() type of functions
 
H

Hoepilaar

Guest
Put a show_message in the Step event of obj_more and obj_less and see how many times it fires. (Put "-1" as the message of obj_less and "1" as the message of obj_more.)
I have found my problem, I had an object deleting the more/less objects every step. What stupid of me :bash:
 
Top