I have run into a problem: The ground I am using in my game has a BRUSH ground. But my code I have only supports boxes! I have the code applied to the main person…
onClipEvent (load) {
y = jump=0;
_root.point=0;
death=false;
_root.hp=100;
speed = 5;
hold=0;
control=false;
move=1;
}
onClipEvent (enterFrame) {
xmax = this.getBounds(_root).xMax;
xmin = this.getBounds(_root).xMin;
ymax = this.getBounds(_root).yMax;
if (Key.isDown(Key.RIGHT) && !_root.ground.hitTest(xmax+speed, _y, true) and move==1 and death==false and !control) {
_xscale=100;
gotoAndStop (2);
_root.ground._x -= speed;
}
if (Key.isDown(Key.LEFT) && !_root.ground.hitTest(xmin-speed, _y, true) and move==1and death==false and !control) {
_xscale=-100;
_root.ground._x += speed;
gotoAndStop (2);
}
if (_root.ground.hitTest(_x, ymax-(y/2), true)) {
jump = true;
y = 0;
} else {
y -= 1;
jump = false;
}
if (jump && Key.isDown(Key.SPACE)and death==false) {
if (Key.isDown(Key.CONTROL)) {
}
gotoAndStop(1);
y = 13;
}
if (!Key.isDown(Key.LEFT) and !Key.isDown(Key.RIGHT)and death==false and !control) {
gotoAndStop (1);
}
_root.ground._y += y;
if (Key.isDown(Key.CONTROL)and death==false) {
control=true;
move=0;
gotoAndStop (3);
} else {
control=false;
move=1;
}
if (Key.isDown(Key.DOWN) and jump and death==false) {
gotoAndStop (4);
if (Key.isDown(Key.SHIFT)) {
gotoAndStop (5);
}
move=0;
} else {
move=1;
}
if (_root.hp<=0) {
_root.hp=0;
gotoAndStop (6);
_xscale=100;
}
}
Any ideas?