Hello guys,
I have an explosion class with 15 image in it. How do I clear the array of images after it is used since simply removing the object doesn't solve the heap space error after using the explosion a few time.
Thank You
public NukeExplosion ()
{
//initialize the array of blue explosion pictures
nukeExplosion = new GreenfootImage[15];
//filling the array with pictures
for (int i = 1; i <= 15; i++)
{
nukeExplosion[i - 1] = new GreenfootImage ("nukeExplosion/" + i + ".png");
}
}
/**
* Act - do whatever the NukeExplosion wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
//add one to the act counter every act
actCounter ++;
//if statement that changes the picture every 5 act
if (actCounter == 5)
{
//set act acounter to zero
actCounter = 0;
//set image of explosion
setImage(nukeExplosion[curIndex]);
//if statement that adds to the curIndex if it isn't at 14
if (!(curIndex == 14))
{
curIndex++;
}
}
//if curIndex is 14 then it removes the explosion
if (curIndex == 14)
{
SpaceWorld m = (SpaceWorld)getWorld();
m.removeObject(this);
}
}
