Issue with Flipping Sprite
Posted: Thu Mar 22, 2018 11:41 pm
Hello,
My character's sprites all face right, and I don't want to have to create a separate sheet with left-facing sprites. I tried doing this:
It only kind of works. The sprite flips, but jolts forward, like so:
Here's what the update function looks like
(full implementation not shown; just what controls left/right movement):
Is it because I'm drawing to a canvas (512x288)?
How do I keep it from doing this (preferably without removing the canvas)?
My character's sprites all face right, and I don't want to have to create a separate sheet with left-facing sprites. I tried doing this:
Code: Select all
function Player:draw()
love.graphics.draw(self.image, self.x, self.y, 0, self.direction, 1) -- self.direction = -1 when the player presses 'left'
end
(full implementation not shown; just what controls left/right movement):
Code: Select all
function Player:update(dt)
if love.keyboard.isDown('left') then
self.x = self.x - (dt * self.xSpeed) -- self.xSpeed = 150
self.direction = -1
end
if love.keyboard.isDown('right') then
self.x = self.x + (dt * self.xSpeed)
self.direction = 1
end
end
How do I keep it from doing this (preferably without removing the canvas)?