Page 1 of 1

Flipping Sprite Sheet Animation Shrinks Image

Posted: Thu Sep 15, 2022 12:17 am
by Sammm
Hello!

I'm trying to make a player animation, but the spritesheet only faces one way. In order to flip the animation, I tried doing

Code: Select all

player.anim:draw(player.spritesheet, player.body:getX(), player.body:getY(), nil, 5, 1, -1)
(notice the last two parameters), but the image just looks shrunken and smashed down, as seen from the image.
Screenshot 2022-09-14 8.16.44 PM.png
Screenshot 2022-09-14 8.16.44 PM.png (1.55 KiB) Viewed 1191 times
How can I prevent this and flip the image/animation normally?

Thanks!

Re: Flipping Sprite Sheet Animation Shrinks Image

Posted: Thu Sep 15, 2022 10:13 am
by ReFreezed
You gotta at least show the code for the :draw() function. There is no such thing as a "spritesheet" object in LÖVE or Lua, so there's no way for us to know what the problem is without seeing more of the code.

Re: Flipping Sprite Sheet Animation Shrinks Image

Posted: Thu Sep 15, 2022 11:23 am
by pgimeno
Why is that 5 there?

I don't know the signature of player.anim:draw, but if it's similar to love.graphics.draw, angle should be 0 rather than nil, and then the scale should come next. It looks like you're using 5 for horizontal scale, 1 for vertical scale, and -1 for origin X. That would explain the weird aspect of your image, I suppose.

Re: Flipping Sprite Sheet Animation Shrinks Image

Posted: Thu Sep 15, 2022 3:31 pm
by Sammm
Pgimeno, thanks you solved it. The tutorial I watched said that you only needed to fill in 1 scale parameter, which works most of the time, but I guess if you put in parameters after the scale parameter, it messes things up. I filled both the sx and sy parameters and now it works. Thanks!