• Hey! Guest! The 37th GMC Jam will take place between May 28th, 12:00 UTC and June 1st, 12:00 UTC. Why not join in! Click here to find out more!

Drag And Drop click on an object

I see that you can set the mouse to do something when clicked but how do I make it so I can click on specific objects? GMS2 and dnd.

Thanks!
 

Taddio

Member
Basically, in your object, the mouse[pressed,check,released] event will trigger when clicking ON the object, wheras the GLOBAL mouse[pressed,check,released] will trigger if you click anywhere on the screen.
DnD or GML is the same, as it's in the event list
 

Taddio

Member
ah, in that case would he need to use the keyword other to have access to the object he clicks?
Ohhhh no, absolutely not!
The keyword other only works inside of a with statement, and in the collision event.
Not going to work any other way.
Let me give you an example.
Say you have an obj_play_button, and when you click on it, you want to go to the main game room, then in obj_play_button mouse left released event you would put room_goto(rm_game);

An example for GLOBAL mouse pressed would be in a RTS when you select a unit and want it to move where you click (which obviously won't be on your obj_unit, right?)
Then in your obj_unit global right pressed event you would put your code to move the unit towards that spot you clicked (which could be complicated in a RTS, but you get the idea)
 

roozilla

Member
Sorry, I was thinking of it in regards to prior use with collision events and then lumping it in with events altogether.
 
Top