View Full Version : Click and Play game...
Hi !
Maybe someone could help me?
How can i do this :
- The player is in an area, he click on a place in this area, and the hero go to this clicked area. (hmm..i hope you understand my poor english...)
Is it possible?
REMC
Ricod
08-21-2002, 08:49 AM
Funny, I was busy doing this right now ...
Anyway, u can use the on mouseDown or mouseUp to catch the click, and then using the _ymouse and _xmouse to get the x and y coordinates of the spot you clicked. It would look something like :
on(mouseDown) {
_root.targetX = _root._xmouse;
_root.targetY = _root._ymouse;
}
now u can compare these values to the x and y coordinates of your 'player'. If the players x is less than the targetX the _x needs to increase (else vice versa). Same thing for the _y. Do this gradually with a loop. To make a nice curve, u can use some functions ... ehr, my math sucks ... sumthing like instead of _x += 10 u would use the one with the degrading curve ... ehr, someone else can jump in here ?
christobal
08-21-2002, 09:00 AM
1 Attach an mc to yur mouse pos (like if you drag a clip but in this case an empty clip). Instance it as say maybe mouseClip . In mouseClip build a simple function that sets its x and y pos in variables.
like:
function newPos() {
_root.myXPos = this._x;
_root.myYPos = this._y;
}
call function when you click
on (release) {
newPos();
}
create two variables for the new x and new y positions
var myXPos;
var myYPos;
use a clip event on your man movie clip that sets its position in relation to the new x and y position variables.
like;
onClipEvent (enterFrame) {
this._x = myXPos;
this._y = myYPos;
}
that probably needs some fine tuning but basically that kind of thing should work fine if I understand you, don't forget to make sure you target the variables propeerly in relationship to where you have placed them
good luck
farafiro
08-21-2002, 11:23 AM
http://www.bit-101.com
hit the tutorials button
u will find what u want and more
|
vBulletin® v3.8.5, Copyright ©2000-2013, Jelsoft Enterprises Ltd.