Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 07-02-2012, 01:00 AM   #1
vexxy
Registered User
 
Join Date: Jun 2012
Posts: 2
Default Character Movement to mouseclick?

I was wondering how I would setup a file to animate a movieclip to move to wherever the mouse was clicked, like a person walking to the clicked position BUT I want to be able to make it stop if it encounters a wall, and then not be able to move through that wall. I have basic experience in flash, and I know my way around, but I have no clue how I would go about doing this.
Thanks!
vexxy is offline   Reply With Quote
Old 07-05-2012, 03:31 PM   #2
MAGG0T
Member
 
Join Date: Mar 2012
Posts: 64
Default

1st Frame
Code:
movePlayer = function () {
this.dx = (this.targx-this._x)*.1;
this.dy = (this.targy-this._y)*.1;
this._x += this.dx;
this._y += this.dy;
};

setTarget = function () {
this.targx = _root._xmouse;
this.targy = _root._ymouse;

};
Player.targx = 10;
Player.targy = 10;
Player.onEnterFrame = movePlayer;
Player.onMouseDown = setTarget;
Create a MovieClip with the Instance name of Player
Done!

I made a quick example here : http://sound4-ls.webs.com/Player.swf
MAGG0T is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT. The time now is 06:50 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.