1. Hey! Guest! The 34th GMC Jam will take place between August 22nd, 12:00 UTC (Thursday noon) and August 26th, 12:00 UTC (Monday noon). Why not join in! Click here to find out more!
    Dismiss Notice

GM:S 1.4 Clicking on a sprite

Discussion in 'Programming' started by prithvidiamond, Jun 27, 2016.

  1. prithvidiamond

    prithvidiamond Member

    Joined:
    Jun 21, 2016
    Posts:
    39
    Hello guys I am back with another useless and noob problem in GML (cause I am noob :( ):

    You see I want to click on a sprite such that if it equal to a variable, it does something.

    I am unable to code this and would like some help (more like tutoring cause I am NOOB :( )

    All help is surely appreciated from such a wonderful community,

    prithvidiamond
     
  2. johnwo

    johnwo Member

    Joined:
    Jun 20, 2016
    Posts:
    220
    Use something like:
    Code:
    // Step event
    if mouse_check_button_pressed(mb_left) { // Check if a mouse button was pressed; mb_left = left mouse-button
        var inst = collision_point(mouse_x, mouse_y, YourObject, true, true); // Check the mouse_x/y position for an instance, store that instance-id in the variable inst
        if inst != noone and YourCondition then { // Add your condition here
            // Do something; Add your statements here.
        }
    }
    
    Hope that helps!

    Cheers!
     
  3. prithvidiamond

    prithvidiamond Member

    Joined:
    Jun 21, 2016
    Posts:
    39
    I will surely try,

    Thanks,

    prithvidiamond
     

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