I’ve been going crazy trying to figure out whats wrong :h: .
barrier.onEnterFrame = function() {
with (_root.tank) {
if (Key.isDown(Key.DOWN)) {
_y += 1;
}
if (Key.isDown(Key.UP)) {
_y -= 1;
}
if (Key.isDown(Key.LEFT)) {
_x -= 1;
}
if (Key.isDown(Key.RIGHT)) {
_x += 1;
}
if (this.hitTest(getBounds(_root).xMax, _y, true)) {
_x -= 1;
}
if (this.hitTest(getBounds(_root).xMin, _y, true)) {
_x += 1;
}
if (this.hitTest(_x, getBounds(_root).yMax, true)) {
_y -= 1;
}
if (this.hitTest(_x, getBounds(_root).yMin, true)) {
_y += 1;
}
}
};
There’s the code. I’ll attach the fla too. It just doesn’t work right, like if you go diagonal you can go through the wall. Or if you come down from the top of the wall you go through it, sometimes even the bottom wall.
Could someone help me, point me in the right direction with links or source, or maybe even remake it in a better way? PLease?