I have attached the fla. At the moment the bg moves when the arrow keys are pressed and the hero jumps. But what I would like to know is how to make it so that the ball lands on anything in the platform movieclip.
Here is the actionscript:
Code:
onClipEvent (load) {
speed = 4;
isJumping = false;
jumpSpeed = 0;
startY = _root.bg._y;
}
onClipEvent (enterFrame) {
if (isJumping) {
_y += jumpSpeed;
jumpSpeed += 1;
if (_y>=startY) {
_y = startY;
isJumping = false;
speed = 6;
}
} else {
if (Key.isDown(Key.SPACE)) {
isJumping = true;
jumpSpeed = -20;
speed = 6;
}
}
if (Key.isDown(Key.LEFT)) {
_root.bg._x += speed;
_xscale = -100;
}
if (Key.isDown(Key.RIGHT)) {
_root.bg._x -= speed;
_xscale = 100;
}
}