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

GM:S 1.4 Show subtitles/play sounds when num. of button clicks reaches certain amounts

Discussion in 'Programming' started by CrashRocks1419, Jul 7, 2018.

  1. Hello everyone! I have a problem with some code in my game.

    I am making a button simulator game, where when you get to so many clicks, an audio clip will play, along with subtitles to go along with the voices.

    In obj_button Create event, I have
    Code:
    clicks = 0
    which sets the variable iirc.

    In the Left Released event, I have:

    Code:
    clicks += 1;
    
    In obj_subtitle Draw GUI event, I have:
    Code:
    draw_set_alpha(0.4);
    draw_set_colour(c_black);
    if (clicks = 10){
        draw_roundrect(160,352,640,416,false);
    }
    
    ... which should draw the box for the subtitles.

    However, clicking the button 10 times does not create the subtitle box. Is there something I am forgetting in the code?
     
  2. Relic

    Relic Member

    Joined:
    Jun 27, 2017
    Posts:
    725
    Obj_subtitle has a variable clicks, as does obj_button.

    Adding to the clicks variable for the button does not also add to the clicks variable for the subtitles.

    Put the drawing code in the button obj or have the subtitle object check the button clicks by using obj_button.clicks (only valid if you only have one button instance)
     

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