Going forward and backward with a caracter

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: Going forward and backward with a caracter

Post by raidho36 »

Just pass another sprite to drawing function. Duh.
Solitaire
Prole
Posts: 12
Joined: Mon Jul 29, 2013 1:50 am

Re: Going forward and backward with a caracter

Post 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
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: Going forward and backward with a caracter

Post 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 )
Post Reply

Who is online

Users browsing this forum: Amazon [Bot], Google [Bot] and 3 guests