1. Hey! Guest! The 35th GMC Jam will take place between November 28th, 12:00 UTC - December 2nd, 12:00 UTC. Why not join in! Click here to find out more!
    Dismiss Notice

Drag And Drop click on an object

Discussion in 'Programming' started by giraffeman210, Mar 8, 2019.

  1. giraffeman210

    giraffeman210 Member

    Joined:
    Sep 23, 2018
    Posts:
    79
    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!
     
  2. roozilla

    roozilla Member

    Joined:
    Feb 4, 2017
    Posts:
    111
    look into instance_position game maker, also mouse_x and mouse_y
     
  3. Taddio

    Taddio Member

    Joined:
    Nov 16, 2018
    Posts:
    463
    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
     
  4. roozilla

    roozilla Member

    Joined:
    Feb 4, 2017
    Posts:
    111
    ah, in that case would he need to use the keyword other to have access to the object he clicks?
     
  5. FrostyCat

    FrostyCat Member

    Joined:
    Jun 26, 2016
    Posts:
    4,601
    No, you implement the mouse event in the object type that you want responding to clicks.

    Why don't you read the Manual entry on other to see where it can be used? A standard mouse event certainly isn't one of those places.
     
    roozilla likes this.
  6. Taddio

    Taddio Member

    Joined:
    Nov 16, 2018
    Posts:
    463
    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 likes this.
  7. roozilla

    roozilla Member

    Joined:
    Feb 4, 2017
    Posts:
    111
    Sorry, I was thinking of it in regards to prior use with collision events and then lumping it in with events altogether.
     
  8. Taddio

    Taddio Member

    Joined:
    Nov 16, 2018
    Posts:
    463
    Yeah, think of the mouse event (not global) as a collision event object/cursor.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice