View Full Version : MC to follow the mouse
buzza_gts
10-23-2002, 01:10 AM
How do you make a MC follow the mouse, but only when the mouse is over the MC.
THX:D :D :D
snapple
10-23-2002, 01:41 AM
buzza_gts,
Put this on an MC with instance name 'ball' - shoudl work, put the fps to 30.
onClipEvent (enterFrame) {
if(_root.ball.hitTest(_root._xmouse, _root._ymouse, True)) {
_root.ball._x = _root.ball._x + (_root._xmouse-_root.ball._x)/10;
_root.ball._y = _root.ball._y + (_root._ymouse-_root.ball._y)/10;
}
}
//the lower the number, in this case /10, the faster the ball reacts to your cursor
Regards, snapple :)
buzza_gts
10-23-2002, 02:44 AM
Thanks for that, got it working.
Just one more question about this line.
if (_root.ball.hitTest(_root._xmouse, _root._ymouse, True))
Is it saying if the x & y of mouse are on ball that equals true, so you could make the hitTest area anouther object and the MC wont move unless the mouse is over that "other" area.
Cheers
snapple
10-23-2002, 02:58 AM
buzza_gts,
You got it bud !;) - i get worried when i see so many people from Australia on here, kinda reminds me to go to bed
Regards, snapple :)
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.