Hello,
I can place the following code on a movieclip:
And it'll work fine, however if I place it like this on a frame in the movieclip:PHP Code:onClipEvent(load) {
gravity = 0.2;
yspeed = 0;
speed = 2;
}
onClipEvent(enterFrame) {
if(flipped) {
this._xscale = -this._xscale;
flipped = false;
}
if(this._x >= 763 or this._x <= 37) {
flipped = true;
speed = -speed;
}
if(!_parent.bricks.hitTest(_x+_width/2, _y+_height/4, true)) {
_x += speed;
}
yspeed += gravity;
while(_parent.bricks.hitTest(_x, _y+_height/2, true)) {
_y--;
yspeed = 0;
jumping = 0;
}
if((!_parent.bricks.hitTest(_x, _y+_height/2+1, true)) or (yspeed<0)) {
_y += yspeed;
} else {
yspeed = 0;
jumping = 0;
}
}
It doesn't workPHP Code:this.onLoad = function() {
gravity = 0.2;
yspeed = 0;
speed = 2;
}
this.onEnterFrame = function() {
if(flipped) {
this._xscale = -this._xscale;
flipped = false;
}
if(this._x >= 763 or this._x <= 37) {
flipped = true;
speed = -speed;
}
if(!_parent.bricks.hitTest(_x+_width/2, _y+_height/4, true)) {
_x += speed;
}
yspeed += gravity;
while(_parent.bricks.hitTest(_x, _y+_height/2, true)) {
_y--;
yspeed = 0;
jumping = 0;
}
if((!_parent.bricks.hitTest(_x, _y+_height/2+1, true)) or (yspeed<0)) {
_y += yspeed;
} else {
yspeed = 0;
jumping = 0;
}
}
Any help would be greatly appreciated since this is for a school project due in a week...![]()





Reply With Quote