View Full Version : Click and Play game...

08-21-2002, 08:34 AM
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?


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 ?

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.

function newPos() {
_root.myXPos = this._x;
_root.myYPos = this._y;

call function when you click

on (release) {
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.

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

08-21-2002, 11:23 AM
hit the tutorials button
u will find what u want and more