So I have this script…
I want to put the following clip [toad] inside a NEW movie clip…
so I tried
TOAD = _root.castle[“toad”+k]
^The code failed to work, The character, would just stand there doing nothing…
Whats wrong with, my “target path”?
num = 3;
numA = 8;
distance = 450;
fire = false;
money=250
enemies=5
onEnterFrame = function () {
for (k=0; k<num; k++) {
for (k=0; k<numA; k++) {
TOAD = _root["toad"+k];
ENEMY = _root["enemy"+k];
Xmouse = _root.ENEMY._x;
Ymouse = _root.ENEMY._y;
gunX = _root.TOAD._x;
gunY = _root.TOAD._y;
angle = Math.atan2(Ymouse-gunY, Xmouse-gunX)/(Math.PI/180);
if (Math.sqrt((Xmouse-gunX)*(Xmouse-gunX)+(Ymouse-gunY)*(Ymouse-gunY))<distance) {
fire = true;
}
if (Math.sqrt((Xmouse-gunX)*(Xmouse-gunX)+(Ymouse-gunY)*(Ymouse-gunY))>distance) {
fire = false;
}
if (fire == true) {
_root.TOAD.gun._rotation = angle;
_root.TOAD.gun.gotoAndStop(2);
_root.TOAD.gun.spray.play();
}
if (fire == false) {
_root.TOAD.gun.gotoAndStop(1);
_root.TOAD.gun._rotation = 180;
}
}
}
};