Jump to content

Possible memory leak on animation destroy after finish?


PRSoluções
 Share

Recommended Posts

Hi,

I think that i have a memory leak on animation. Every explosion i create 10 explosion objects, and after some time it is growing a lot, see (521 childrens):

https://www.dropbox.com/s/pq1hwyixvsunrnt/Screenshot%202016-04-22%2021.09.46.png?dl=0

My code to add animation is:

var effect6 = this.groups.underPlayer.create((o.x * GameApp.TILE_SIZE) + (GameApp.TILE_SIZE / 2), (o.y * GameApp.TILE_SIZE) + (GameApp.TILE_SIZE / 2), 'bombFlameSpritesheet001');
effect6.animations.add('default', [, 1, 2, 3, 4], 12);
effect6.anchor.set(0.5, 0.5);
effect6.play('default', 12, false, true);

I have defined TRUE to destroy on finish.

Link to comment
Share on other sites

Yes, im using:

var effect6 = this.groups.underPlayer.getFirstExists(false, true, (o.x * GameApp.TILE_SIZE) + (GameApp.TILE_SIZE / 2), (o.y * GameApp.TILE_SIZE) + (GameApp.TILE_SIZE / 2), 'bombFlameSpritesheet001');
effect6.animations.add('default', [, 1, 2, 3, 4], 12);
effect6.anchor.set(0.5, 0.5);
effect6.play('default', 12, false, true);

But i dont know if is a good practice.

Link to comment
Share on other sites

There's a difference between "kill", which is what the last argument to Sprite.play does, and "destroy", which is what your code snippet that you added does. "kill" makes it ready for being used again, while "destroy" removes it from the game entirely, never to be seen again.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...