Chaser
Member
Sorry to post about what is probably something i've done but i going out of my mind here
Mouse_check_button_pressed(mb_left)
This function will return true if the mouse button being checked has been pressed or false if it has not. This function will only be triggered once for any mouse button when it is first pressed and to trigger it again the button will need to have been released and pressed again. Note that it will be considered triggered for the duration of the step, and for all instances that have any mouse events or that use this same function.
So, i want an object to be created when i press the left mouse button, but only if a variable is true. In order to set the variable to true i need to left mouse button press on an object.
in the object it has this:
create event
global.active = false
mouse left press event
if global.active = false
{
global.active = true;
}
if global.active = false
{
global.active = true;
}
Now on my other object (which is the mouse cursor)
Step Event
x = mouse_x;
y = mouse_y;
Left pressed event
if global.active = 1
{
if !instance_exists(obj_marker_1)
{
instance_create_depth(mouse_x,mouse_y,-10,obj_marker_1);
}
}
else
{
//do nothing
}
Now this seems pretty straight forward to me. Once the global.active is set to true my NEXT left press should create the instance i want. But what is happening is as soon as left click on the object(and turn global.active from false to true) it immediately creates the instance. At the time the first left pressed is actioned the variable is false so it shouldn't do that should it?? It says this function will only trigger once.
What is happening here that i'm not getting my head round? It's driving me bonkers. Seems like this function is triggering every step, not just once? Could someone put me out of my misery
Mouse_check_button_pressed(mb_left)
This function will return true if the mouse button being checked has been pressed or false if it has not. This function will only be triggered once for any mouse button when it is first pressed and to trigger it again the button will need to have been released and pressed again. Note that it will be considered triggered for the duration of the step, and for all instances that have any mouse events or that use this same function.
So, i want an object to be created when i press the left mouse button, but only if a variable is true. In order to set the variable to true i need to left mouse button press on an object.
in the object it has this:
create event
global.active = false
mouse left press event
if global.active = false
{
global.active = true;
}
if global.active = false
{
global.active = true;
}
Now on my other object (which is the mouse cursor)
Step Event
x = mouse_x;
y = mouse_y;
Left pressed event
if global.active = 1
{
if !instance_exists(obj_marker_1)
{
instance_create_depth(mouse_x,mouse_y,-10,obj_marker_1);
}
}
else
{
//do nothing
}
Now this seems pretty straight forward to me. Once the global.active is set to true my NEXT left press should create the instance i want. But what is happening is as soon as left click on the object(and turn global.active from false to true) it immediately creates the instance. At the time the first left pressed is actioned the variable is false so it shouldn't do that should it?? It says this function will only trigger once.
What is happening here that i'm not getting my head round? It's driving me bonkers. Seems like this function is triggering every step, not just once? Could someone put me out of my misery