I'm creating an asteroids game and in my main class I'm having some trouble handling the bullets that the ship fires.

All of the bullets are of the "Bullet" class and are stored in an array called "bullets" in the main class. When bullets exit the screen, removeBullet(bulletID) in the main class is called.

private function removeBullet(id:int)
    {
        removeChild(bullets[id]);
        bullets.splice(id);
    }

In my Bullet class I have an enterFrame listener that traces "stillHere". So as soon as a bullet is added to the main stage using addChild, "stillHere" starts popping up in my output panel.

My problem is that even after I call the removeBullet, "stillHere" keeps popping up in the output panel, which tells me that the object which I tried to delete is still sticking around somewhere in the memory.

What can I do to get rid of it completely?

没有正确的解决方案

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top