Hi,
I have a problem with an if-statement and I can't figure it out.
I am working on a point 'n click game.
What I want:
a) When the mousepointer (obj_mousepointer) is moved over an object then show textline 1 (showtext = 1) in a textbox (obj_textbox). e.g.: "This is an old door".
b) When the mousepointer is moved on an object AND the player stands on top of the object then show textline 2. "The door is locked".
c) When neither is the case just show no nothing at all.
The textbox should be removed as soon as the mousepointer is not placed over the object any more or another line is displayed.
Problem:
When I run the game and place the mousepointer in an object the textbox is not displayed.
What confuses me to no end is, that two of my debug messages are displayed: "Mousecursor on Obj" AND "No Object selected".
It seems to me, that the first condition is always true therefore it destroys obj_textbox.
When i comment out instance_destroy(obj_textbox) everything is displayed.
I changed the order of the statements, tried switches and some other variations of if, if not, else, else if etc. but to no avail.
Obj_Textbox holds only information on the textbox itself. The Draw -Event just starts the text-script.
Sorry if I missed the solution in an other thread.
I am glad for every hint.
I have a problem with an if-statement and I can't figure it out.
I am working on a point 'n click game.
What I want:
a) When the mousepointer (obj_mousepointer) is moved over an object then show textline 1 (showtext = 1) in a textbox (obj_textbox). e.g.: "This is an old door".
b) When the mousepointer is moved on an object AND the player stands on top of the object then show textline 2. "The door is locked".
c) When neither is the case just show no nothing at all.
The textbox should be removed as soon as the mousepointer is not placed over the object any more or another line is displayed.
Problem:
When I run the game and place the mousepointer in an object the textbox is not displayed.
What confuses me to no end is, that two of my debug messages are displayed: "Mousecursor on Obj" AND "No Object selected".
It seems to me, that the first condition is always true therefore it destroys obj_textbox.
When i comment out instance_destroy(obj_textbox) everything is displayed.
I changed the order of the statements, tried switches and some other variations of if, if not, else, else if etc. but to no avail.
Obj_Textbox holds only information on the textbox itself. The Draw -Event just starts the text-script.
Sorry if I missed the solution in an other thread.
I am glad for every hint.
Code:
if (!place_meeting(x,y, obj_mousepointer)) {
showtext = 0;
instance_destroy(obj_textbox);
show_debug_message(string("No Object selected"));
}
else if (place_meeting(x,y, obj_mousepointer) && !place_meeting(x,y,obj_player)) {
showtext = 1;
show_debug_message(string("Mousecursor on Obj"));
}
else if (place_meeting(x,y, obj_mousepointer) && place_meeting(x,y,obj_player)) {
showtext = 2;
show_debug_message(string("Player & Mousecursor on Obj"));
}