gLT4FM
07-15-2007, 11:54 AM
Hello,
I need some help with my flash game. Its kind of based on "space invaders" except the hittest isn't working properly. I need it to 'gotoandplay' the explosion clip on the UFO when the bullet hits it. The code that isn't working is on the bullet MC. I wouldn't usually ask for help but this is a main piece of assessment and it's due in two days.
OK, so basically down the bottom of the game is a tank controlled by the left and right arrow buttons. When space is pressed a bullet moves upwards until it hits the top of the screen, then where it is duplicated. Towards the top a UFO moves across the screen from left to right the re-appears on the left and moves back across.
The tank is a MC
The UFO is a MC
The Bullet is a MC
Tank code:
onClipEvent(enterFrame){
if(Key.isDown(Key.RIGHT)){
this._x += 15;
this._xscale = 100;
}
if(Key.isDown (Key.LEFT)) {
this._x -=15;
this._xscale = -100;
}
}
onClipEvent(enterFrame){
_root.bullet._x=this._x;
_root.bullet._y=this._y;
}
UFO code:
onClipEvent (load) {
this._y=random;
this._x=0;
}
onClipEvent (enterFrame){
this._x= this._x+25;
}
onClipEvent (enterFrame){
if (this._x> 800){
this._x=0;
this._y= random (450);
}
}
Bullet Code:
onClipEvent ( keyUp ){
if ( Key.getCode (Key.SPACE)){shooting=false;
}
}
onClipEvent ( enterFrame){
if (Key.isDown (Key.SPACE) and !shooting){
shooting=true;
count+=1;
if ( count >=50){
count=1;
}
duplicateMovieClip (this,"b" + count,10+count);
}
if ( this._y < 0 ) {
removeMovieClip (this);
}
this._y-=20;
}
onClipEvent (enterFrame){
if (this.hitTest (_root.alien) ==true) {
_root.alien.gotoAndStop(2);
unloadMovie (_root.alien);
unloadMovie (this);
_root.score = _root.n += 100;
}
}
Please help.
I need some help with my flash game. Its kind of based on "space invaders" except the hittest isn't working properly. I need it to 'gotoandplay' the explosion clip on the UFO when the bullet hits it. The code that isn't working is on the bullet MC. I wouldn't usually ask for help but this is a main piece of assessment and it's due in two days.
OK, so basically down the bottom of the game is a tank controlled by the left and right arrow buttons. When space is pressed a bullet moves upwards until it hits the top of the screen, then where it is duplicated. Towards the top a UFO moves across the screen from left to right the re-appears on the left and moves back across.
The tank is a MC
The UFO is a MC
The Bullet is a MC
Tank code:
onClipEvent(enterFrame){
if(Key.isDown(Key.RIGHT)){
this._x += 15;
this._xscale = 100;
}
if(Key.isDown (Key.LEFT)) {
this._x -=15;
this._xscale = -100;
}
}
onClipEvent(enterFrame){
_root.bullet._x=this._x;
_root.bullet._y=this._y;
}
UFO code:
onClipEvent (load) {
this._y=random;
this._x=0;
}
onClipEvent (enterFrame){
this._x= this._x+25;
}
onClipEvent (enterFrame){
if (this._x> 800){
this._x=0;
this._y= random (450);
}
}
Bullet Code:
onClipEvent ( keyUp ){
if ( Key.getCode (Key.SPACE)){shooting=false;
}
}
onClipEvent ( enterFrame){
if (Key.isDown (Key.SPACE) and !shooting){
shooting=true;
count+=1;
if ( count >=50){
count=1;
}
duplicateMovieClip (this,"b" + count,10+count);
}
if ( this._y < 0 ) {
removeMovieClip (this);
}
this._y-=20;
}
onClipEvent (enterFrame){
if (this.hitTest (_root.alien) ==true) {
_root.alien.gotoAndStop(2);
unloadMovie (_root.alien);
unloadMovie (this);
_root.score = _root.n += 100;
}
}
Please help.