function love.load()
x = 300
y = 100
angle = 0
canvas = love.graphics.newCanvas(140, 200)
end
function love.update(dt)
if love.keyboard.isDown("up") then
y = y - 400 * dt
elseif love.keyboard.isDown("down") then
y = y + 400 * dt
end
angle = angle + dt
end
function love.draw()
love.graphics.setCanvas(canvas)
love.graphics.clear()
love.graphics.rectangle("fill", 0, 0, 20, 200)
love.graphics.rectangle("fill", 120, 0, 20, 200)
love.graphics.setCanvas()
love.graphics.draw(canvas, x, y, angle, 1, 1, canvas:getWidth()/2, canvas:getHeight()/2)
end
s-ol wrote:
I would still urge you to learn the transforms API, it is a very essential part of graphics programming and useful for a lot of different things.
Lets take the attached love file as example. Eventually I want the rocket to rotate together with the "fire" - would you suggest doing this with canvas or the transform API?
s-ol wrote:
I would still urge you to learn the transforms API, it is a very essential part of graphics programming and useful for a lot of different things.
Lets take the attached love file as example. Eventually I want the rocket to rotate together with the "fire" - would you suggest doing this with canvas or the transform API?
Press A or D for acceleration.
Thanks a lot!
zugende
Theres no reason to use the canvas when you are going to clear and redraw it every frame (except for some very rare cases in which a Canvas has another advantage, but that won't be the case here).