Created: January 2011
Last Updated: January 2011
Original Author: Tony Huynh
When switching screens, all currently managed resources (i.e. all objects currently managed by one of FlatRedBall's manager classes) must be destroyed (i.e. removed from the managers); if you do not handle this, then you will get a run-time error upon the attempt to switch screens. Before switching screens, you must do the following:
Call the Destroy() method of the current screen
Manually remove objects from managers if they were manually assigned to FlatRedBall managers. Objects that were not manually added to managers (i.e. created through Glue) will be handled by the generated code, so you need only to call its Destroy() method before switching screens. Remark (on best practices): It is a best practice to put the code to remove a manually managed object from its managers in the object's CustomDestroy() (or Destroy() ) method. This way, only its Destroy() method needs to be called before switching screens. After destroying an object, it is also a good defensive programming technique to set the value of the object to null to ensure that it is not used anymore.
All that remains is to use the MoveToScreen() method to switch screens.