Since I started to redesing my game, the platformes started to act weird.
If I jump from to high or from an other object, my character falls through.
Here is my character's AS:
onClipEvent (load) {
fall = false;
_name = "circle";
jump = 0;
speed = 8;
jumpheight = 10;
maxfall = -54;
}
onClipEvent (enterFrame) {
xmin = getBounds(_root).xMin;
xmax = getBounds(_root).xMax;
ymin = getBounds(_root).yMin;
ymax = getBounds(_root).yMax;
if (Key.isDown(87) && fall == false && jump == undefined) {
fall = true;
jump = jumpheight;
}
if (jump<>undefined) {
if (jump>maxfall) {
jump--;
}
_y -= jump;
}
}
onClipEvent (enterFrame) {
if (Key.isDown(65)) {
_x -= speed;
}
if (Key.isDown(68)) {
_x += speed;
}
}
Here is the platforme's AS:
onClipEvent (load) {
activated = false;
down = false;
}
onClipEvent (enterFrame) {
_root.report.text = Math.round(_root.circle.yMax)+" "+Math.round(yMin);
xmin = getBounds(_root).xMin;
xmax = getBounds(_root).xMax;
ymin = getBounds(_root).yMin;
ymax = getBounds(_root).yMax;
if (_root.circle.xMax>xMin && _root.circle.xMin<xMax && _root.circle.yMax<yMin) {
if (_root.circle.yMax-_root.circle.jump*2 >yMin) {
_root.circle._y = ymin-_root.circle._height/2;
_root.circle.jump = undefined;
_root.circle.fall = false;
activated = true;
}
}
if (Math.round(_root.circle.yMax)>Math.ro und(yMin)) {
if (hitTest(_root.circle) && _root.circle.xmax<xmin) {
_root.circle._x -= _root.circle.speed;
}
if (hitTest(_root.circle) && _root.circle.xmin>xmax) {
_root.circle._x += _root.circle.speed;
}
if (hitTest(_root.circle) && _root.circle.ymin>ymax && _root.circle.jump>-1) {
_root.circle.jump = -1*(_root.circle.jump);
}
}
if (activated == true && not hitTest(_root.circle) && _root.circle.jump == undefined) {
_root.circle.jump = 0;
activated = false;
}
if (hitTest(_root.circle) && _root.circle.ymax>ymin && _root.circle.jump<>undefined && _root.circle._y<_y) {
_root.circle._y = ymin-_root.circle._height/2;
_root.circle.jump = undefined;
_root.circle.fall = false;
activated = true;
}
if (_root.circle.ymax-_root.circle.jump>y min && _root.circle.xMin<xMax && _root.circle.xMax>xMin && _root.circle.jump<>undefined && _root.circle._y<_y) {
_root.circle._y = ymin-_root.circle._height/2;
_root.circle.jump = undefined;
_root.circle.fall = false;
activated = true;
}
}
And here is the elevator's AS:
onClipEvent (load) {
activated = false;
down = false;
}
onClipEvent (enterFrame) {
_root.report.text = Math.round(_root.circle.yMax)+" "+Math.round(yMin);
xmin = getBounds(_root).xMin;
xmax = getBounds(_root).xMax;
ymin = getBounds(_root).yMin;
ymax = getBounds(_root).yMax;
if (_root.circle.xMax>xMin && _root.circle.xMin<xMax && _root.circle.yMax<yMin) {
if (_root.circle.yMax-_root.circle.jump*2 >yMin) {
_root.circle._y = ymin-_root.circle._height/2;
_root.circle.jump = undefined;
_root.circle.fall = false;
activated = true;
}
}
if (Math.round(_root.circle.yMax)>Math.ro und(yMin)) {
if (hitTest(_root.circle) && _root.circle.xmax<xmin) {
_root.circle._x -= _root.circle.speed;
}
if (hitTest(_root.circle) && _root.circle.xmin>xmax) {
_root.circle._x += _root.circle.speed;
}
if (hitTest(_root.circle) && _root.circle.ymin>ymax && _root.circle.jump>-1) {
_root.circle.jump = -1*(_root.circle.jump);
}
}
if (activated == true && not hitTest(_root.circle) && _root.circle.jump == undefined) {
_root.circle.jump = 0;
activated = false;
}
if (hitTest(_root.circle) && _root.circle.ymax>ymin && _root.circle.jump<>undefined && _root.circle._y<_y) {
_root.circle._y = ymin-_root.circle._height/2;
_root.circle.jump = undefined;
_root.circle.fall = false;
activated = true;
}
if (_root.circle.ymax-_root.circle.jump>y min && _root.circle.xMin<xMax && _root.circle.xMax>xMin && _root.circle.jump<>undefined && _root.circle._y<_y) {
_root.circle._y = ymin-_root.circle._height/2;
_root.circle.jump = undefined;
_root.circle.fall = false;
activated = true;
}
}
onClipEvent (mouseDown) {
startDrag("", true);
}
onClipEvent (mouseUp) {
stopDrag();
}
Could anyone figure out the problem 'cause I can't see ...
Come here to see the working demo version of the game.