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

GML "Draw Sprite" on click

Discussion in 'Programming' started by Ellys, Aug 13, 2019.

  1. Ellys

    Ellys Member

    Joined:
    Aug 11, 2019
    Posts:
    6
    Hey coders,

    I want to draw a sprite on click and have it stay there until I click again.
    This is what i have so far.

    if mouse_check_button_released(mb_left) && position_meeting(mouse_x, mouse_y, oStats)
    {
    draw_sprite(sStatBG, 0, 400, 400);
    }

    I understand the draw function is usually in the draw event but that draws the sprite immediately instead of on click. So this code is currently in my step (evidently doesn't work)

    Any help would be appreciated, thank you.
     
  2. curato

    curato Member

    Joined:
    Jun 30, 2016
    Posts:
    326
    If I were doing it I would make the object and use a variable to store the true false of if it is clicked or not then override the standard draw even with an if statement of if clicked is true then call draw_self to get the sprite assigned to the object.
     

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