Going forward and backward with a caracter
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: Going forward and backward with a caracter
Just pass another sprite to drawing function. Duh.
Re: Going forward and backward with a caracter
Tss... the scaling doesn't work (or am I dumb ?)
Code: Select all
function love.keypressed(key)
if key == "left" then
love.graphics.scale (-1, 1)
end
end
function love.load()
x = 0
y = 0
bond = love.graphics.newImage("bond.png")
end
function love.update(dt)
if love.keyboard.isDown("right") then
x = x + 2
elseif love.keyboard.isDown("left") then
x = x - 2
end
end
function love.draw()
love.graphics.draw(bond, x, y)
end
Re: Going forward and backward with a caracter
Your whole graphics state is being reset before rendering every frame, so you'd have to keep a variable for that and apply that transformation every frame. Also note that this transformation would affect all subsequent drawing operations, so for the sake of simplicity, I really suggest using sprite scaling instead of love.graphics.* scaling.
Code: Select all
love.graphics.draw ( sprite, x, y, r, xscale, yscale )
Who is online
Users browsing this forum: Amazon [Bot], Google [Bot] and 3 guests