• 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!

[SOLVED] Mouse Over / D'n'D?!

[game maker 8]

Hey guys!
I wanted to know, how to check a "collision" with the cursor.
I'm making a simple drag & Drop function and started like that:


If mouse left button is clicked, then move the object to mouse_x and mouse_y. Yeah, but right now it doesn't matter, where I click, and the object will immediately be placed at mouse_x and mouse_y.

How can I tell GM8 that the object is only supposed to go to mouse x & y, when the object was actually clicked on?
I want to do it in code, because the normal step even is only running IF it's not being dragged. Everything works so far. I just don't know how to check the mouse "collision".

Thanks in advance!
 
A

Aura

Guest
Step:
Code:
if (mouse_check_button_pressed(mb_left)) {
   if (position_meeting(mouse_x, mouse_y, id)) {
      // Do something
   }
}
If you're trying to drag instances, then that is definitely not the best method. Let me know what you're trying to do and I might suggest better alternatives.
 
Thanks for your replies!
Uhm @Aura: I'm just trying to drag my player object somewhere. (for debugging reasons).
But I need to learn about creating a drag n drop system anyways. For any cases.
What I needed to know was the position_meeting thing.
What's the difference between position & place_meeting?
Thanks!
 
A

Aura

Guest
There's no new language for GM:S. It's still GML. The only difference is that a lot of new functions have been added and some old functions been made obsolete. Now that GMS 2 has come out, you should at least consider moving on to GM:S.
 
There's no new language for GM:S. It's still GML. The only difference is that a lot of new functions have been added and some old functions been made obsolete. Now that GMS 2 has come out, you should at least consider moving on to GM:S.
Yes, I know that there is not literally a 'new' language. But a lot of things to get used to. You're probably right. :p :)
 
Top