im wondering how to point an arrow toward the mouse by rotating around another object like this:
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
Rotating around an object [Solved]
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Rotating around an object [Solved]
Last edited by lilfinn on Fri May 02, 2014 4:07 am, edited 1 time in total.
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: Rotating around an object
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.
Re: Rotating around an object
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?
Re: Rotating around an object
You can do it using ox and oy. First draw the circle as usual. Then draw the arrow like this:
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.
Code: Select all
love.graphics.draw(arrowImage, x,y,angle, 1,1,ox,oy)
Check out my blog on gamedev
Re: Rotating around an object
Thank you very much, after you explained the offset it made perfect sense.
Thank you again
Thank you again
Who is online
Users browsing this forum: Semrush [Bot] and 7 guests