Jump to content

Question about Physics Object


mwatt
 Share

Recommended Posts

I want to create a shutdown function for my game so that I can reclaim any memory for objects allocated in create of the game state.   I gather that I should go through and call destroy on my sprites, sounds and other resources in the shutdown function and that the state manager will automagically invoke shutdown for me when the state is abandoned.

 

But I'm not sure what to do about the physics object.  The Phaser documentation lists a destroy method, and goes on to say that it is not usually used when switching states.  I don't understand why.  I call physics.startSystem in my game state create function.  If I were to switch to my menu state and then come back to the game state, would not the create method fire again and create another physics object? 

 

Is the answer that the first one will get garbage collected anyway?  Perhaps destroy is unnecessary on the physics object because there will be no hanging resources to collect like there are for sprites, etc. (and I am guessing that caching is the reason why destroy ought to be called for these, but if someone knows a better or more correct reason, I'd like to hear about it).

 

 

 

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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