Hi guys,
My first post here and hopefully the first of many!
The code is actionscript 2.0 using Flash version10
Basically i’m trying to make a space invaders-esqe game and having a problem or two along the way.
Here is the code for the enemy:
enemy.onEnterFrame = function() {
//omitted movement code (not relevent);
}
if (enemy.hitTest(bullet)) {
_root.enemy._alpha=20;
}
else _root.enemy._alpha=100;
}
Using this basic hitTest function just get it working, so I can build on it. When I fire the bullet it doesn’t detect any hit at all. I can’t work out what is wrong!
The following code is for the firing of the bullet:
gunEmplacement.onEnterFrame = function() {
//omitted movement code (not relevent);
if(Key.isDown(40)){
_root.attachMovie('bullet', 'bullet'+bulletNum,+1,1);
_root['bullet'+bulletNum]._x = gunEmplacement._x + gunEmplacement._width/2 - _root['bullet'+bulletNum]._width/2;
_root['bullet'+bulletNum]._y = gunEmplacement._y;
_root['bullet'+bulletNum].onEnterFrame = function(){
this._y -= 8;
if(this._y < 0 * this._height){
this.removeMovieClip();
}
}
}
That is the code for how many bullet gets generated and is the one that is meant to hit the enemy ship. What is wrong with the code I have wrote and why won’t it recognise a hit? Is it because of the attachmovie?