-
[RESOLVED] How to gradually move to mouse location?
Well, I got some code here that will move the player to the mouses x/y location, but I want to gradually move them to this location so it doesnt look like their teleporting
Code:
//check left mouse button is down
if(Key.IsDown(1)){
//move player to mouse location
_root.player._x = _root._xmouse;
_root.player._y = _root._ymouse;
}
-
.
Hi,
You could use a simple built in tween like so (or similar)
PHP Code:
import mx.transitions.*;
var target:MovieClip = _root.player;
onMouseDown = function ()
{
//if (Key.isDown(1))
//{
//trace("left mouse click");
var tweenX = new Tween(target, "_x", None.easeNone, target._x, _root._xmouse, 0.5, true);
var tweenY = new Tween(target, "_y", None.easeNone, target._y, _root._ymouse, 0.5, true);
//}
};
I'm not sure if the key(1) is necessary as you only have one key really, the right click brings up the menu, and it won't work with a mac as it has virtually no left click, so maybe leave the commented parts commented or remove them
-
Thanks, that works pretty well to what I wanted
and I'll just remove the comments, thanks again
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|