GMS 2 Help

Discussion in 'Programming' started by James Lin, Oct 10, 2019.

Tags:
  1. James Lin

    James Lin Member

    Joined:
    Mar 18, 2019
    Posts:
    10
    I need help the code does not work for the left animation and the idle animations
     
  2. Lonewolff

    Lonewolff Member

    Joined:
    Jan 8, 2018
    Posts:
    1,207
    Code formatting is what you need.
     
  3. TsukaYuriko

    TsukaYuriko Q&A Spawn Camper Forum Staff Moderator

    Joined:
    Apr 21, 2016
    Posts:
    1,626
    That can be read as "if sign(move_x) evaluates to true and sign(move_y) equals zero".

    See: How NOT to use && and ||

    If you're still facing problems, please post the code where you set move_x.
     
  4. James Lin

    James Lin Member

    Joined:
    Mar 18, 2019
    Posts:
    10
    First, I am having issues with the idle animations still so not work
     
    Last edited: Oct 11, 2019
  5. IKEcoolcoder

    IKEcoolcoder Member

    Joined:
    Oct 11, 2019
    Posts:
    1
    Make your idle animation ur main sprite
     
  6. TsukaYuriko

    TsukaYuriko Q&A Spawn Camper Forum Staff Moderator

    Joined:
    Apr 21, 2016
    Posts:
    1,626
    You're checking if move_x equals 0, but never setting it to that. The same goes for the y variant.
     
  7. TheouAegis

    TheouAegis Member

    Joined:
    Jul 3, 2016
    Posts:
    6,889
    Code:
    if move_x == 0 {
        move_x = (left_key - right_key);
        if move_x != 0 move_y = 0;
    }
    else
    if move_y == 0 {
        move_y = (up_key - down_key);
        if move_y != 0 move_x = 0;
    }
    Considering you set move_y=0 before checking the up and down keys, I gathered you wanted something like this for movement. Although this would cause a weird, diagonal movement with the sprite rapidly alternating back and forth. But then again, your code didn't say you didn't want that, either.


    As IKEcoolcoder was pointing out, you are setting image_index for your idle sprite, when you should be using sprite_index.
     

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