PDA

View Full Version : Enemies disappear randomly



leetleet
August 13th, 2007, 12:57 PM
One the first frame of 'enemyOne' movieclip, I have:


var o = 0;
var i = 0;
var j = 0;
function enemyOneShoot () {
initObject = new Object();
initObject._x = _x;
initObject._y = _y;
var aim = Math.atan2(_root.tank._y - initObject._y, _root.tank._x - initObject._x) * 180 / Math.PI + 90;
oh++;
initObject._rotation = aim;
_root.attachMovie("enemyOnebullet","enemyOnebullet"+o,o,initObject);
};
function shootinterval() {
setInterval(enemyOneShoot,1000);
};
shootinterval();

The problem is... some of the enemies randomly disappear when i click the mouse, or 'enemyOne' movieclip doesn't go to frame 2 and is just gone, and some are just working fine. What's going on?

BradLee
August 13th, 2007, 01:43 PM
I don't think this part of your code is what's causing your enemies to disappear.

Your bullet code doesn't like right either though...

Why are you doing this:

oh++;And then using the variable o when creating bullets?

_root.attachMovie("enemyOnebullet","enemyOnebullet"+o,o,initObject);Shouldn't "oh++;" be "o++;"?

Hope that helps... good luck!

leetleet
August 14th, 2007, 08:22 AM
Haha, I just noticed the typo. Anyway, there is something seriously wrong. When I test the movie (ctrl+enter), the enemies would shoot with the code above and there would be the glitchy disappearing, but when I open up the .swf that was exported, the enemies don't shoot at all. I've noticed a difference between testing the movie and opening the exported .swf a few times now. I wonder if anyone is having the same problems... :(

BradLee
August 14th, 2007, 10:37 AM
You are probably going to have to upload the fla, or at least post some more code to look at before anybody can help you further.