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

Help with Flipping Sprite

Discussion in 'Programming' started by BruhTheStatement, May 20, 2019.

  1. BruhTheStatement

    BruhTheStatement Member

    Joined:
    May 20, 2019
    Posts:
    3
    Hi! I'm trying to make a game (using a Youtube tutorial) and the code he used to flip his Sprite was
    if (hsp != 0) image_xscale = sign(hsp); (HSP Stands for Horizontal Speed) but when I use it my sprite flips but it Makes my Character thin and squished. any help would be greatly appreciated.
     
  2. zATARA_0

    zATARA_0 Member

    Joined:
    Apr 10, 2019
    Posts:
    45
    sign should only be able to return -1 or 1. It sounds like somehow you are setting your x scale to a decimel value.
     
  3. samspade

    samspade Member

    Joined:
    Feb 26, 2017
    Posts:
    2,056
    sign returns -1, 0, or 1 depending upon whether the number you give it is negative, 0, or positive (respectively). Since you prevent the number from being 0 (by saying if (hsp != 0) the only values it can return are 1 or -1. My guess is that you've scaled your sprite to a different value somewhere - for example you've stretched it to a different size in the room editor or you have written code, perhaps in the create event, that says image_xscale = 3. Your image_xscale = sign(hsp) line then overwrites that.
     
  4. BruhTheStatement

    BruhTheStatement Member

    Joined:
    May 20, 2019
    Posts:
    3
    Thank you Samspade. that was my problem then. I stretched my sprite in the Room Editor.
     
  5. BruhTheStatement

    BruhTheStatement Member

    Joined:
    May 20, 2019
    Posts:
    3
    Also, Quick Question. What is the Recommended size for a Sprite So I can make a proper Platformer?
     
  6. samspade

    samspade Member

    Joined:
    Feb 26, 2017
    Posts:
    2,056
    There's no right answer to that question. It depends on the resolution of everything else and what you're going for.
     

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