00:00
00:00
Newgrounds Background Image Theme

Whraen just joined the crew!

We need you on the team, too.

Support Newgrounds and get tons of perks for just $2.99!

Create a Free Account and then..

Become a Supporter!

movement towards mouse

684 Views | 3 Replies
New Topic Respond to this Topic

movement towards mouse 2002-03-21 11:52:53


I know how to get a movieclip rotate towards the mouse:

onClipEvent (enterFrame) {
// Get the distance between current position and mouse
diffx = _x - _root._xmouse;
diffy = _y - _root._ymouse;
// Set rotation
_rotation=(Math.atan2(diffy, diffx)*(180/Math.PI))-90;
}

But my problem is how do I make it go only 120 degrees, where up is the center.

Can somebody help, please???

here is a help drawing.

movement towards mouse

Response to movement towards mouse 2002-03-25 07:39:23


can nobody help????

Response to movement towards mouse 2002-03-25 11:31:08


At 3/25/02 07:39 AM, TheDon2000 wrote: can nobody help????

simple just use IF statements .. say if math.abs(0-_rotation) > 120 make sure the code doesn't execute and put your roatation code block into the else.

Response to movement towards mouse 2002-03-25 11:33:41


At 3/25/02 07:39 AM, TheDon2000 wrote: can nobody help????

simple just use IF statements to limit the code block from executing. say if math.abs(0-_rotation) {
} else {
//your rotation code block
}