Rotating around an object [Solved]

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
lilfinn
Prole
Posts: 10
Joined: Thu Jul 18, 2013 5:58 am

Rotating around an object [Solved]

Post by lilfinn »

im wondering how to point an arrow toward the mouse by rotating around another object like this:

Image

where the arrow is pointing in the direction of the mouse. Is there a way to change the point an object rotates around?

Thanks in advance
Last edited by lilfinn on Fri May 02, 2014 4:07 am, edited 1 time in total.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Rotating around an object

Post by bartbes »

It depends what the object is. If it's an image, you can use the ox and oy parameters to set the point around which it rotates.
lilfinn
Prole
Posts: 10
Joined: Thu Jul 18, 2013 5:58 am

Re: Rotating around an object

Post by lilfinn »

thanks for the quick reply.The object is an image and i tried using the ox and oy parameters but all that does is offset the origin, the arrow still just rotates around itself instead of the around the circle. any idea on how i can achieve what im looking for?
User avatar
micha
Inner party member
Posts: 1083
Joined: Wed Sep 26, 2012 5:13 pm

Re: Rotating around an object

Post by micha »

You can do it using ox and oy. First draw the circle as usual. Then draw the arrow like this:

Code: Select all

love.graphics.draw(arrowImage, x,y,angle, 1,1,ox,oy)
For x and y, insert the center of the circle (that would be the drawing coordinates plus half of the diameter) for angle insert whatever angle and for ox and oy insert a point that is outside the arrow-image. If for example, the arrow image has a size of 16x16 pixels and the arrow is pointing upwards, select as a drawing origin (8,50). This is the point inside the image, that will be aligned with the center of the circle.
lilfinn
Prole
Posts: 10
Joined: Thu Jul 18, 2013 5:58 am

Re: Rotating around an object

Post by lilfinn »

Thank you very much, after you explained the offset it made perfect sense.
Thank you again
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot] and 6 guests