Denolth
Sailing
|
Sea, instead of changing the speed, you can just change the character's x and y. If the character walking speed is 10, it will the following: If you don't want the character to go to the left, on the boundarie, add this: onClipEvent(enterFrame) {
if(this.hitTest(_root.player)) {
_root.player._x += 10;
}
} If you don't want the character to go to the right, just change the + symbol to -, like this: onClipEvent(enterFrame) {
if(this.hitTest(_root.player)) {
_root.player._x -= 10;
}
} Now, if you don't want the character to go up, add this: onClipEvent(enterFrame) {
if(this.hitTest(_root.player)) {
_root.player._y += 10;
}
} But if you don't want it to go down, just change the symbols: onClipEvent(enterFrame) {
if(this.hitTest(_root.player)) {
_root.player._y -= 10;
}
} This code should be added to the boundaries. If you can avoid changing the speed, do it. This way, the speed will always be 10 and the character won't be able to go where it shouldn't.
|