my code. When you press space it’s suppose to attach the bullet MC and make it move in the direction its facing. I’ve beed playing with this code for a half hour now, so i think it’s tie to ask. Again I know there’s a quick solution.
Here it is:
onClipEvent (load) {
this.shooting = false;
}
onClipEvent (enterFrame) {
if (this.shooting == true) {
for (counter=0; counter<10; counter++) {
attachMovie("bullet", "bullet"+counter, 0);
_root["bullet"+counter]._x = _root.main._x;
_root["bullet"+counter]._y = _root.main._y;
_root["bullet"+counter]._rotation = _root.main._rotation;
var speed = 40;
if (_root["bullet"+counter]._rotation<0) {
_root["bullet"+counter].xmove = ((speed)*Math.sin(Math.PI/180*(360+_root["bullet"+counter]._rotation)));
_root["bullet"+counter].ymove = ((-speed)*Math.cos(Math.PI/180*(360+_root["bullet"+counter]._rotation)));
} else {
_root["bullet"+counter].xmove = ((speed)*Math.sin(Math.PI/180*(_root["bullet"+counter]._rotation)));
_root["bullet"+counter].ymove = ((-speed)*Math.cos(Math.PI/180*(_root["bullet"+counter]._rotation)));
}
_root["bullet"+counter].onEnterFrame = function() {
_root["bullet"+counter]._x -= _root["bullet"+counter].xmove;
_root["bullet"+counter]._y -= _root["bullet"+counter].ymove;
};
}
}
if (Key.isDown(Key.SPACE)) {
this.shooting = true;
}
}