hello,
i have a problem in rotating the shot of the enemy (there are some).
I elaborated on the problem.
i have my class of the enemy. i have the class for his shot. and some lines on the TimeLine.
i need to do that every enemy will have is own shot rotation. and when i checked with the trace command happen what i wanted to happen (evey enemy have is own rotation of shot)… but its not work.
this is the code on the timeLine:
var enemy:MovieClip;
var enemyArray:Array = [];
enemySpawn = function(numEnemies){
for(i=1;i<=numEnemies;i++){
enemy = attachMovie("enemy", "enemy"+i, i);
enemy1._x = 939;
enemy1._y = 299;
enemy2._x = 619;
enemy2._y = 278;
enemyArray.push(enemy);
}
}
enemySpawn(2);
this is the code of the class of the shot of the enemy:
class ShotEN extends MovieClip
{
var i:Number;
var enemyArray:Array;
var radians:Number;
var speed:Number;
var ang:Number;
var xSpeed:Number;
var ySpeed:Number;
function onLoad(){
enemyArray = _root.enemyArray;
radians = Math.PI/180;
speed = 25;
for(i = 0; i < enemyArray.length; i++){
trace(enemyArray*);
trace(enemyArray*.numToRot);
ang = (enemyArray*.gun._rotation - enemyArray*.numToRot)*radians; //look at this line i think in this the main problem
xSpeed = Math.cos(ang)*speed;
ySpeed = Math.sin(ang)*speed;
this._y = enemyArray*._y -10;
}
}
function onEnterFrame(){
_x += xSpeed;
_y += ySpeed;
}
}
and in the class of the enemy i do a Variable called “numToRot” and do that when the enemy pos is right the value of the variable is 0 and when its left its -180. so when the enemy turn left the shot too.
i hope you understand me.
Thanks to everyone who helps!