all groups > flash actionscript > april 2005 >
You're in the

flash actionscript

group:

Mouse contolling movie clip rotation


Mouse contolling movie clip rotation ThePeasantKing
4/2/2005 4:37:23 PM
flash actionscript:
Okay, i'm making a game like grand theft auto but where the sticks are main
characters and run around shooting everything. I have most of the game made but
i not sure how to make my main characters head and arms move with the mouse.
I'm tring to make it so that is the mouse moves left then the head and arms
will move left and so on. The legs i know how to do because those are going to
move with w,a,s,d but i can't figure out how to do the mouse controls.

My first attemp made the head and arms come off the legs and not rotate with
the mouse they just followed the mouse so i need some help. Any help is
appreciated, Thanks.

P.S. if you need a visual on what i am trying to do here is a link.
http://img229.exs.cx/my.php?loc=img229&image=srpg2csdemo2zv.swf
Re: Mouse contolling movie clip rotation davidprovost
4/3/2005 1:40:27 AM
Im making the same kind of game. Right now its around 400 lines of code. To get
the main characters body (head and arms) to follow the mouse, make sure they
are in the same mc, and add this code the your main timeline:
_global.radiansToDegrees = function(radians) { return (radians/Math.PI)*180;
}; MovieClip.prototype.rotateTowardsMouse = function() { var point =
{x:this._x, y:this._y}; this._parent.localToGlobal(point); var deltaX =
_root._xmouse-point.x; var deltaY = _root._ymouse-point.y; var rotationRadian
= Math.atan2(deltaY, deltaX); var rotationAngle =
radiansToDegrees(rotationRadian); this._rotation = rotationAngle; };
man_mc.body_mc.onEnterFrame = rotateTowardsMouse; How many lines of code is ur
game so far? Im trying to get mine so you can hope in and outta cars, drive
them around and stuff, but its kinda hard. lol
Re: Mouse contolling movie clip rotation ThePeasantKing
4/3/2005 5:19:26 AM
Heh, funny. I have a band director who's name is Mark Provost. Do you happen to
know him?

Well, anyway, thanks for the help. I think i can help you out with car thing.
I recently got a game called stick rpg downloaded so i can see the actionscript
so i can probably find the code for the car with not too much searching. Let me
know how you game develops.
Re: Mouse contolling movie clip rotation davidprovost
4/3/2005 5:29:13 AM
Re: Mouse contolling movie clip rotation ThePeasantKing
4/3/2005 6:19:24 AM
Lol, that pretty funny. Well, anyway i got the action scrip from the sothink
swf decompiler but it isn't free. I send you the huge file with all the MC and
actionscript for it though. Oh, and here is the car actionscript.

You will need to make the car an MC and make 4 frames for it. One make the car
pointing up and name the frame up and the left, right, down. I included the
sounds for the actionscript but you might have to edit out the "black" thing,
not sure what that is.

// [onClipEvent of sprite 124 in frame 2]
on (keyPress "c")
{
if (_root.item_car == 1 || _root.item_car == 2)
{
if (_root.driving == 0)
{
_root.SFXignition.start(0.250000, 1);
} // end if
_root.black.gotoAndPlay(1);
if (_root.driving == 0)
{
_root.driving = 1;
}
else if (_root.driving == 1)
{
_root.driving = 0;
} // end if
} // end if
}
on (keyPress "C")
{
if (_root.item_car == 1 || _root.item_car == 2)
{
if (_root.driving == 0)
{
_root.SFXignition.start(0.250000, 1);
} // end if
_root.black.gotoAndPlay(1);
if (_root.driving == 0)
{
_root.driving = 1;
}
else if (_root.driving == 1)
{
_root.driving = 0;
} // end if
} // end if
}

Here is the link to download the sounds for the actionscript:
http://files.filehosting.org/kp20473.zip
Here is the link to download both cars:
http://files.filehosting.org/ny20482.zip
-Just copy and paste

Re: Mouse contolling movie clip rotation davidprovost
4/3/2005 6:24:55 PM
yea send it! were did u get it from? I could host it at my site (www.assaultskateboards.com) once I have it. As long as Xgen studios is down with it.
Re: Mouse contolling movie clip rotation ThePeasantKing
4/3/2005 9:05:34 PM
AddThis Social Bookmark Button