1. Hello Guest! It's with a heavy heart that we must announce the removal of the Legacy GMC Archive. If you wish to save anything from it, now's the time! Please see this topic for more information.
    Dismiss Notice

Taking just one instance from an object

Discussion in 'Programming' started by Altug Yasar, Jul 30, 2019.

  1. Altug Yasar

    Altug Yasar Member

    Joined:
    Jul 30, 2019
    Posts:
    2
    Hello guys!
    I have like 30 same object in 1 room and I want to do when I click that object image_index change but when I click all of the 30 instances changing.
    I want this code for just that instance.
    How can I do it?
    Sorry for bad English.

    -----------------------------------------------------------------------

    in objects create event:
    image_speed = 0;
    amISelected = false;


    in objects step event:
    if (mouse_check_button_pressed(mb_left)) {
    DoBox();
    }


    in DoBox:
    if (image_index = 0) {
    image_index = 1;
    }
    else if (image_index = 1) {
    image_index = 0;
    }
    amISelected = true;
     
  2. FrostyCat

    FrostyCat Member

    Joined:
    Jun 26, 2016
    Posts:
    4,709
    You only checked if the mouse is clicked, you never checked if it was on top of the current instance.
    Code:
    if (mouse_check_button_pressed(mb_left) && position_meeting(mouse_x, mouse_y, id)) {
      DoBox();
    }
    
     
    nikoscot likes this.

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