Page 2 of 2

Re: Going forward and backward with a caracter

Posted: Sat Aug 10, 2013 8:38 pm
by raidho36
Just pass another sprite to drawing function. Duh.

Re: Going forward and backward with a caracter

Posted: Mon Aug 12, 2013 10:39 pm
by Solitaire
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

Posted: Tue Aug 13, 2013 1:46 am
by raidho36
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 )