Fishinghat
09-06-2004, 03:39 PM
Hi, I'm creating a space game that involves a hitTest, if an asteroid collides into the space ship game over, written the code, tested it, but doesn't seem to work.
Here's my asteroid code:
onClipEvent (load) {
this._y = (Math.random()*320)+3;
rockSpeed = (Math.random()*10)+1;
}
onClipEvent (enterFrame) {
if (this._x<8) {
rockSpeed = 10;
this._x += 10;
}
if (this._x > 530) {
rockSpeed = -10;
}
this._x += rockSpeed;
rotChoice = (Math.random()*2)+1;
if (rotChoice=1) {
this._rotation += 6;
} else if (rotChoice=2) {
this._rotation -= 6;
}
if(this.hitTest(_parent.motherShip)) {
gotoAndPlay("S4", 1);
}
}
Here's my asteroid code:
onClipEvent (load) {
this._y = (Math.random()*320)+3;
rockSpeed = (Math.random()*10)+1;
}
onClipEvent (enterFrame) {
if (this._x<8) {
rockSpeed = 10;
this._x += 10;
}
if (this._x > 530) {
rockSpeed = -10;
}
this._x += rockSpeed;
rotChoice = (Math.random()*2)+1;
if (rotChoice=1) {
this._rotation += 6;
} else if (rotChoice=2) {
this._rotation -= 6;
}
if(this.hitTest(_parent.motherShip)) {
gotoAndPlay("S4", 1);
}
}