Hey, man!
Consider using
AnAL, also, I'd suggest using the same image for both directions, left and right, and flipping along the X axis according to a “flip” variable. Consider the draw mnemonic (If you use AnAL, you'll pass the same parameters to the draw() function):
Code: Select all
love.graphics.draw( drawable, x, y, r, sx, sy, ox, oy )
Where the “sx” and “sy” parameters define the image scale. You should be able to flip your image along the X axis by passing the following (signed) integers:
sx = 1 (facing right)
sx = -1 (facing left)
The same applies for the “sy” parameter, but this will flip your image along the Y axis.
Something like this should do (pseudo code):
Code: Select all
function player:update(dt)
if love.keyboard.isDown("right") then
self.imageFlipX = 1
self.imageOffsetX = 0 --image x axis remains the same
elseif love.keyboard.isDown("left") then
self.imageFlipX = -1
self.imageOffsetX = imageWidth --image x axis has been flipped!
end
end
Please note that you'll also need to define an offset value along the X axis when the image is flipped (usually, "self.imageOffsetX" will be defined as the width of your image).
Code: Select all
function player:draw()
love.graphics.draw( drawable, self.positionX, self.positionY, self.rotation, self.imageFlipX, self.imageFlipY, self.imageOffsetX, self.imageOffsetY )
end