Basically, I have a character walking inside a rectangle, and should be able to walk only inside that area. I set up four points of shapeFlag hitTests (left, up, right, down), so if the left hitTest returns False, the speed for walkLeft and runLeft is set to 0. Same goes to other directions.
But what I don't understand is that it works fine with walking, but he can still run beyond the boundaries! I traced the runLeft speed both on keypress and hitTest, and they return two different values WTF!?
===HITTEST CODE===
//Not Hitting Right
if (!_root.mcGround.hitTest(this._x+4, this._y, true)){
_root.walkRight = 0;
_root.runRight = 0;
trace("right");
}else{
_root.walkRight = 3.25;
_root.runRight = 9;
}
//Not Hitting Left
if (!_root.mcGround.hitTest(this._x-4, this._y, true)){
_root.walkLeft = 0;
_root.runLeft = 0;
trace("left");
}else{
_root.walkLeft = 3.25;
_root.runLeft = 9;
}
//Not Hitting Down
if (!_root.mcGround.hitTest(this._x, this._y+4, true)){
_root.walkDown = 0;
_root.runDown = 0;
trace("down");
}else{
_root.walkDown = 2;
_root.runDown = 2.5;
}
//Not Hitting Up
if (!_root.mcGround.hitTest(this._x, this._y-4, true)){
_root.walkUp = 0;
_root.runUp = 0;
trace("up");
}else{
_root.walkUp = 2;
_root.runUp = 2.5;
}
====