## Rotating an image in-place

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Bannana97
Citizen
Posts: 77
Joined: Wed May 16, 2012 2:49 pm

### Rotating an image in-place

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 (16.92 KiB) Viewed 973 times
Issue2.png (10.55 KiB) Viewed 973 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!
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

### Re: Rotating an image in-place

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

### Re: Rotating an image in-place

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

### Re: Rotating an image in-place

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

### Who is online

Users browsing this forum: No registered users and 29 guests