View Full Version : stop moving?
fried
January 28th, 2003, 12:15 PM
How do I get an object to only move between two points if Iam moving it with the key arrows? The object moves right out the screen.
kode
January 28th, 2003, 12:34 PM
use an if statement
if (this._x > maxX) {
this._x = maxX
}
if (this._x < minX) {
this._x = minX
}
if (this._y > maxX) {
this._y = maxX
}
if (this._y < minX) {
this._y = minX
}
replace maxX minX maxY and minY with your values
or add a variable
maxX = whatever
minX = whatever
maxY = whatever
minY = whatever
so it should be something like this:
onClipEvent (load) {
maxX = whatever
minX = whatever
maxY = whatever
minY = whatever
}
onClipEvent (enterFrame) {
if (this._x > maxX) this._x = maxX
if (this._x < minX) this._x = minX
if (this._y > maxX) this._y = maxX
if (this._y < minX) this._y = minX
}
hope it helps :beam:
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.