Rotating an image in-place

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.
Post Reply
Bannana97
Citizen
Posts: 77
Joined: Wed May 16, 2012 2:49 pm

Rotating an image in-place

Post by Bannana97 »

I am not the best with math yet... and feel like I am cluttering the forums with posts now, lol. But I am having a problem and have tried a lot to fix it:
Issue.png
Issue.png (16.92 KiB) Viewed 2305 times
Issue2.png
Issue2.png (10.55 KiB) Viewed 2305 times
See the red box, between the terrain? That's where the character should also be. When the rectangle is up-right, it seems to correctly place the user's avatar.
However, it's when the rectangle isn't up-right / angled / that I have the problem. Here's the source.

Code: Select all

love.graphics.draw(uiImageFile, object.Body:getX()-math.ceil(part.Size.x / 2), object.Body:getY()-math.ceil(part.Size.y / 2), [b]math.pi * object.Body:getAngle()[/b])
I've tried a lot of different things, for example math.deg(body:getAngle()) and the such, but no luck. I want the avatar to remain in the box at all times, so what functions can I use? Thanks!
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Rotating an image in-place

Post by Robin »

Have you tried not multiplying object.Body:getAngle() by anything?
Help us help you: attach a .love.
Bannana97
Citizen
Posts: 77
Joined: Wed May 16, 2012 2:49 pm

Re: Rotating an image in-place

Post by Bannana97 »

Indeed, the image rotates around the box still. I want the avatar to remain upright in the box at all times. :ultrashocked:
Automatik
Citizen
Posts: 57
Joined: Sun Feb 17, 2013 7:05 pm

Re: Rotating an image in-place

Post by Automatik »

Use the origin parameters:

Code: Select all

love.graphics.draw(
    uiImageFile,
    object.Body:getX(),
    object.Body:getY(), 
    object.Body:getAngle(),
    math.ceil(part.Size.x / 2),
    math.ceil(part.Size.y / 2)
)
Post Reply

Who is online

Users browsing this forum: Semrush [Bot] and 86 guests