Jump to content

Destroy does not remove prototype


jjwallace
 Share

Recommended Posts

I have a fish game and i add fish and remove them using destroy.

The game gets slower as more and more fish are eaten and removed and added again.

Is there a way to destroy the prototype and everything inside?

I checked memory leaks and it seems its the CPU that is having trouble not memory

Link to comment
Share on other sites

Im not an expert on this, so im also interested to know what is going on. Maybe its the destroy function call itself that builds up processing time (if there are alot of fish, lot of garbage collection)? Are there any functions you apply to each fish right before they are destroyed / just after they are added to the game? 

This topic contains some more info related to your case:

 

 

Link to comment
Share on other sites

So what i found is that after my fish is eaten (alive=false) he falls to the bottom and off the screen (active=false) so i found even after deleteing the sprite the object is being push farther and farther along the Y.  This causes the drawable area or something larger and larger and so i was able to stop the prototype from making these calculations.  I still wana destroy it if i can.  I tried setting it to null but it hates that.

Link to comment
Share on other sites

Is there any reason that you want to destroy fish object? Normally to reduce cost of spawning new object you create group of fish objects, set them all to dead state. When you need to spawn new fish just call: https://photonstorm.github.io/phaser-ce/Phaser.Group.html#getFirstDead set x,y coordinates, etc and make fish alive again. With this way you will only need as many fish objects as maximum you want on screen at once. Creating new sprite cost resources, try to avoid it if possible.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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