I was wondering how to make two boxes, lets say, fall on to each other and then fall off if the movie clip get removed. Ive already got the gravity working. any help would be much apreciated. Im looking for eather code or a tutorial. im AS2 im not looking for an engine just something like âMusic in Motionâ Heres my code
for falling box <re> class Box extends MovieClip { var velocity = 0; var gravity = .5; var friction = .01; function onLoad() { this._x = Math.random()*600 + 50; this._y = -100; } function onEnterFrame() { velocity += gravity; velocity -= friction*velocity; _y += velocity; if (_y>_root.floor._y) { _y = _root.floor._y; velocity *= -.4; gotoAndPlay("BoxDie" } } } </pre> and for my hero <re> class hero extends MovieClip { var velocity = 0; var gravity = 1; var friction = .01; var jumping = false; var jump = 5; var boxTimer = 0; function onEnterFrame() {
boxTimer += 1;
if (boxTimer>20) { boxTimer = 0; _root.attachMovie("Box","Box"+_root.getNextHighestDepth(),_root.getNextHighestDepth()); } if (Key.isDown(Key.LEFT)) { this._x -= 10; this._xscale = 100; } if (Key.isDown(Key.RIGHT)) { this._x += 10; this._xscale = -100;
<re> class hero extends MovieClip { var velocity = 0; var gravity = 1; var friction = .01; var jumping = false; var jump = 5; var boxTimer = 0; var falling:Boolean; function onEnterFrame() {