Windows Create an object on click

L

lexafram

Guest
Hello, i'm kinda new to game maker and i wonder how you could create an object when you click and where your mouse is.
thanks for your help
 

Simon Gust

Member
Code:
if (mouse_check_button_pressed(mb_left)) // command for clicking
{
   instance_create(mouse_x, mouse_y, OBJECT); // command for creating an object, mouse_x and y are the positions the mouse is at (absolute)
}
 

jo-thijs

Member
Hello, i'm kinda new to game maker and i wonder how you could create an object when you click and where your mouse is.
thanks for your help
Hi and welcome to the GMC!

Have an invisible controller object.
Put in the "mouse global mouse left pressed" event the following code:
Code:
instance_create(mouse_x, mouse_y, OBJ);
where you replace "OBJ" with the name of the object of which you want to create an instance.
Then put this controller object in your room.

EDIT: I got ninja'd!
 

Electros

Member
The manual is a great source of info, hit F1 in whatever flavour of Gamemaker you are using. Then see if you can find the bits you need to construct what you want it to do. Take a look at "Instance Functions", and "Mouse Input".

Aware I've been beaten to the punch, but I think getting used to finding what you need from the manual is a good skill to have. :)
 
Top