GML Problem With Gun Facing Same Direction as Player.

Discussion in 'Programming' started by SpriteZero, Jul 11, 2019 at 2:35 AM.

  1. SpriteZero

    SpriteZero Member

    Joined:
    Thursday
    Posts:
    2
    I am fairly new to GML and Game Maker Studio 2 in general. I am coding a long term project (a platformer game) and have come across an issue with making my players gun face the same direction as him. if he is facing right, it faces right, if he is facing left, it doesn't face left.

    In my o_players draw event.
    Code:
    /// @description Draw player and gun
    // Player
    if keyboard_check(vk_left) {
    image_xscale = -1;
    }
    if keyboard_check(vk_right) {
    image_xscale = 1;
    }
    draw_self();
    draw_sprite_ext(s_pistol, 0, x, y, 1, 1, 0, image_blend, image_alpha);
    
    any help is appreciated!
     
  2. Mercerenies

    Mercerenies Member

    Joined:
    Jun 21, 2016
    Posts:
    114
    Code:
    draw_sprite_ext(s_pistol, 0, x, y, 1, 1, 0, image_blend, image_alpha);
    Those fifth and sixth parameters are the scaling parameters for the sprite. Try
    Code:
    draw_sprite_ext(s_pistol, 0, x, y, image_xscale, image_yscale, 0, image_blend, image_alpha);
     
    SpriteZero likes this.
  3. SpriteZero

    SpriteZero Member

    Joined:
    Thursday
    Posts:
    2
    Worked like a charm! Thank you a bunch. It was bothering me for days!
     

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