View Full Version : how to make an object move to specific place ?
patricktheking
May 29th, 2004, 06:11 PM
K ... I have a game and when my guy walks over a certain mc i want a certain object thats already on the screen to move 2 a specific point, like 56,13 or something.. Ive read the turtorials for how 2 do it but nothing for that.......
onClipEvent (enterFrame) {
if(_root.car.hitTest(_root.finishline)){
?
} else {
play();
}
}
i need some command to put there to make a specific MC move to a certain spot.... any help....
Adam
May 29th, 2004, 06:39 PM
Voetsjoeba's code will work perfect for you:
in a frame put this:
MovieClip.prototype.easeXY = function(x, y) {
this.onEnterFrame = function() {
this._x = x-(x-this._x)/1.1;
this._y = y-(y-this._y)/1.1;
if (this._x>x-1 && this._x<X+1 this._y &&>y-1 && this._y<Y+1) p {<> this._x = x;
this._y = y;
delete this.onEnterFrame;
}
};
};
and then in yout hitTest use this:
onClipEvent (enterFrame) {
if(_root.car.hitTest(_root.finishline)){
_root.whateverMCYouWantToMove.easeXY(56, 13)
} else {
play();
}
}
K ... I have a game and when my guy walks over a certain mc i want a certain object thats already on the screen to move 2 a specific point, like 56,13 or something.. Ive read the turtorials for how 2 do it but nothing for that.......
onClipEvent (enterFrame) {
if(_root.car.hitTest(_root.finishline)){
?
} else {
play();
}
}
i need some command to put there to make a specific MC move to a certain spot.... any help....
patricktheking
May 29th, 2004, 07:16 PM
Dude theres a mistake somewhere there... somewhere.... as
there is an error....
heres the error it gives me
Scene=Scene 1, Layer=Layer 6, Frame=6: Line 7: ')' expected
if (this._x>x-1 && this._xy-1 && this._y this._x = x;
Scene=Scene 1, Layer=Layer 6, Frame=6: Line 12: Unexpected '}' encountered
};
this is wat i added to the frame just to show u..
MovieClip.prototype.easeXY = function(x, y) {
this.onEnterFrame = function() {
this._x = x-(x-this._x)/1.1;
this._y = y-(y-this._y)/1.1;
if (this._x>x-1 && this._xy-1 && this._y this._x = x;
this._y = y;
delete this.onEnterFrame;
}
};
};
wats wrong
pom
May 29th, 2004, 07:57 PM
The if statement is totally messed up :
MovieClip.prototype.easeXY = function(x, y) {
this.onEnterFrame = function() {
this._x = x-(x-this._x)/1.1;
this._y = y-(y-this._y)/1.1;
if (Math.abs (this._x - x) < 1 && Math.abs (this._y - y) < 1) {
this._x = x;
this._y = y;
delete this.onEnterFrame;
}
};
};
Adam
May 29th, 2004, 08:02 PM
wow...yeah something got lost when I copied and pasted:
MovieClip.prototype.easeXY = function(x, y) {
this.onEnterFrame = function() {
this._x = x-(x-this._x)/1.1;
this._y = y-(y-this._y)/1.1;
if (this._x>x-1 && this._x<x+1 && this._y>y-1 && this._y<y+1) {
this._x = x;
this._y = y;
delete this.onEnterFrame;
}
};
};
**edit..everytime I copy and paste this..it cuts part of it out....any ideas why? this code is still wrong, but I can't paste it in to make it stay right, I paste it and then when I post it...it cuts some out...the attached txt file is right, but I can't post it here?
Weird,
Adam
patricktheking
May 29th, 2004, 08:34 PM
thanks
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.