im almost done with my game but i have two problems.
- when the laser hits and enemy it doesn’t disappear instead it keeps going through enemies until its out of the screen.
-i tried to add a removemovieclip to it but when i did it it removed the laser that you cant even shot no more.hehe
2)when i move forward the stars scroll fine but when that one reaches the end of the end the other stars that is suppose to be respawn .respawns at the same spot i had the other one previously. i dont know if i am explaining this the right way.
this is the code on the on the spaceship:
onClipEvent (load) {
moveSpeed = 15;
_root.laser._visible = false;
laserCounter = 1;
_root.missile._visible = false;
missileCounter = 1;
scrollx = _root.mainGround.ground._width/3;
scrollStart = false;
maxLasers = 4;
maxMissile = 1;
depthCounter = 1;
depthCounters = 10;
enemie**** = 0;
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.SPACE) and (laserCounter<=maxLasers)) {
laserCounter++;
_root.laser.duplicateMovieClip("laser"+depthCounter, depthCounter);
_root["laser"+depthCounter]._visible = true;
depthCounter++;
if (depthCounter>maxLasers) {
depthCounter = 1;
}
}
if (Key.isDown(Key.CONTROL) and (missileCounter<=maxMissile)) {
missileCounter++;
_root.missile.duplicateMovieClip("missile"+depthCounters, depthCounters);
_root["missile"+depthCounters]._visible = true;
depthCounters++;
if (depthCounters>maxMissile) {
depthCounters = 10;
}
}
if (Key.isDown(Key.RIGHT)) {
if (this._x<scrollx) {
this._x += moveSpeed;
} else {
scrollStart = true;
}
} else if (Key.isDown(Key.LEFT) and this._x>30) {
this._x -= moveSpeed;
}
if (Key.isDown(Key.DOWN) and this._y<280) {
this._y += moveSpeed;
} else if (Key.isDown(Key.UP) and this._y>15) {
this._y -= moveSpeed;
}
}
onClipEvent (keyUp) {
if (Key.getCode() == Key.RIGHT) {
scrollStart = false;
}
}
this is the code on the laser:
onClipEvent (load) {
laserMoveSpeed = 20;
this._x = _root.spaceship._x-15;
this._y = _root.spaceship._y+31;
}
onClipEvent (enterFrame) {
if (this._name<>"laser") {
this._x += laserMoveSpeed;
if (this._x>750) {
_root.spaceship.laserCounter--;
this.removeMovieClip();
}
for (i=1; i<=_root.numEnemy; i++) {
if (this.hitTest(_root["enemy"+i]) and _root["enemy"+i].hitFlag == false) {
_root.score += 100;
_root.spaceship.enemie****++;
if (_root.spaceship.enemie****>=20) {
_root.spaceship.enemie**** = 0;
_root.newLevel();
}
_root["enemy"+i].hitFlag = true;
_root["enemy"+i].gotoAndPlay(2);
}
}
}
}
this is the code on the star:
NOTE: the movie is 700x350 resolution running at 20fps.
onClipEvent (load) {
ground.duplicateMovieClip("ground2", 100);
ground2._x = ground._x+ground._width;
groundStartx = this._x;
groundSpeed=15;
}
onClipEvent (enterFrame) {
if (_root.spaceship.scrollStart){
this._x-=groundSpeed;
if (this._x<= (groundStartx-ground._width)){
this._x=groundStartx-groundSpeed;
}
}
}