### Author Topic: how to rotate a FlxSprite in a circle with an angle determined by the position o  (Read 1722 times)

#### ashutosh sharma

• New Member
• Posts: 3
• Karma: +0/-0
##### how to rotate a FlxSprite in a circle with an angle determined by the position o
« on: Sat, Sep 13, 2014 »
Hi Everyone...

I have been reading posts in the forum for last few months.. Thanks for all the help.

I have got myself into a big problem here, were i want to rotate a FlxSprite object in a circle(The object itself is a rectangle of 70*130), Now I want that object to rotate with an angle made by the center and the point where the mouse is placed within its radius. The code i Have used is like this..

And here am i trying to rotate the image

if (FlxG.mouse.pressed)
{
var mouse_pos:FlxPoint = new FlxPoint(FlxG.mouse.x, FlxG.mouse.y);
if (mouse_x>center.x && mouse_x < (center.x + width/2) && mouse_y < (center.y +height/2) &&mouse_y > center.y)
{

angularVelocity -= (FlxAngle.getAngle(getMidpoint(), arrow_end) -  FlxAngle.getAngle(getMidpoint(), mouse_pos));
}
arrow_end = mouse_pos;

}

Can anyone please help me with it because this code is not working, whenever i am placing the mouse in the area the object is rotating in a single direction and is not going to that point.

• Member
• Posts: 47
• Karma: +0/-0
##### Re: how to rotate a FlxSprite in a circle with an angle determined by the position o
« Reply #1 on: Sun, Sep 14, 2014 »
There is a FlxU.rotatePoint() method.
http://flixel.org/docs/org/flixel/FlxU.html#rotatePoint%28%29

It takes a pivot point, a point to be rotated, and angle, and returns the coordinates of the new location.

#### ashutosh sharma

• New Member
• Posts: 3
• Karma: +0/-0
##### Re: how to rotate a FlxSprite in a circle with an angle determined by the position o
« Reply #2 on: Mon, Sep 15, 2014 »
Thanks for helping..

But for that I need to know the exact point where the sprite is when the sprite is rotating.
The first time the Sprite rotates, its position changes so how will i get the current position of the sprite?