changing a sprite using the same button

Discussion in 'Programming' started by Antonio Bertagna, Dec 3, 2018.

Tags:
  1. Antonio Bertagna

    Antonio Bertagna Member

    Joined:
    Nov 22, 2018
    Posts:
    9
    Hi, i was wondering how i can change a sprite multiple times using the space bar, since they are dialogue buttons, so when the first appears i can press space and change it. then again and it will change. im not very good at coding and any help will be appreciated.
     
  2. CreatorAtNight

    CreatorAtNight Member

    Joined:
    Jun 23, 2018
    Posts:
    117
  3. Antonio Bertagna

    Antonio Bertagna Member

    Joined:
    Nov 22, 2018
    Posts:
    9
    unfortunately it didn't work, cause I'm only using the trail version it wont let me create another sprite,however i do have them in a group. so can i call on the group and do it that way
     
  4. roozilla

    roozilla Member

    Joined:
    Feb 4, 2017
    Posts:
    19
    I'm assuming when you say group you mean you have an sprite like spr_dialogue that has 4 sub images
    You can use the draw_sprite_ext function to do what you need. Just have a count variable that holds the value of the subimage you need drawn at the time.

    Then you can add a key pressed event or check if the vk_space button is pressed in a step event to increment the count variable for your sprites subimage.
    Some bits of code:

    In your obj_dialogs create event
    Count = 0;

    Step event:
    If Check_key_pressed(vk_space)
    Count++;

    Draw Event:
    Draw_Sprite_ext(spr_dialog, count, ...);

    // I cant remember for sure but draw_self() might be needes
     

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