• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Windows Create an object on click 2

L

lexafram

Guest
So i previously asked how to create an object on click and i tried different forms but non really worked:
Form 1: i went i the object i tried to spawn and created a left click pressed event where i put the code:
instance_create(mouse_x,mouse_y,obj_lightning)
that didn't work

Form 2: i made a create event where i put the command
if (mouse_check_button_pressed(mb_left))
instance_create(mouse_x,mouse_y,obj_lightning)
that didn't work either

does anyone know why it doesnt work and how to fix this?
thanks alot for your help
 
O

orSQUADstra

Guest
The Create event is ran in the first frame when the object is present.

To create an object on click, you have to make a separate object.
In that separate object, create a "Step Event" - which is ran every single frame.
Paste this:
Code:
if (mouse_check_button_pressed(mb_left))
{
   instance_create(mouse_x,mouse_y,obj_lightning)
}
Then place that object in your room. That's it.
 
L

lexafram

Guest
The Create event is ran in the first frame when the object is present.

To create an object on click, you have to make a separate object.
In that separate object, create a "Step Event" - which is ran every single frame.
Paste this:
Code:
if (mouse_check_button_pressed(mb_left))
{
   instance_create(mouse_x,mouse_y,obj_lightning)
}
Then place that object in your room. That's it.
thanks alot, but what is the difference between the step event and a mouse click event?
 
O

orSQUADstra

Guest
thanks alot, but what is the difference between the step event and a mouse click event?
The mouse click event only runs when the mouse is hovering the object and is clicked. But that also needs the object to be present in the room. You can't really do this with only one object.
 
Top