Hi everyone,
does a function exist, which groups some images to one group so that I then can easily rotate all images together with the same origin?
At the moment I'm manipulating the offset parameter for each image.. but this is really time consuming.
Any idea how to speed up this process?
Thanks a lot!
Here a screenshot from a rocket (consisting of multiple images) I am trying to rotate:
Rotate grouped images
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- Sheepolution
- Party member
- Posts: 264
- Joined: Mon Mar 04, 2013 9:31 am
- Location: The Netherlands
- Contact:
Re: Rotate grouped images
You can use a canvas for this
Code: Select all
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
Re: Rotate grouped images
zugende wrote:same origin
Code: Select all
love.graphics.translate(origin.x, origin.y)
love.graphics.rotate(rotation)
love.graphics.translate(-origin.x, -origin.y)
drawImages()
Re: Rotate grouped images
Ahh nice! Thank you both. Canvas is the one I was looking for.
Re: Rotate grouped images
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.zugende wrote:Ahh nice! Thank you both. Canvas is the one I was looking for.
Re: Rotate grouped images
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.
Press A or D for acceleration.
Thanks a lot!
zugende
- Attachments
-
- rocket_test.love
- (8.39 KiB) Downloaded 87 times
Re: Rotate grouped images
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).zugende wrote: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.
Press A or D for acceleration.
Thanks a lot!
zugende
Who is online
Users browsing this forum: Ahrefs [Bot] and 3 guests