Jump to content

Question about properly cleaning up objects


ManBoy
 Share

Recommended Posts

MainMenu = function(){

    this.background;

};

MainMenu.prototype = 

{

    create:function()

    {

        console.log(this.background);

        if(!this.background)

        {

            this.background = this.add.image(0,0,'PreloadAtlas','Background_Cloud.png');

        }

        var playButton = this.add.button(this.world.centerX,this.world.centerY - 175,'GameAtlas',this.playButtonClick,this,'Play_Button-0002.png','Play_Button-0001.png');

        playButton.anchor.set(0.5);

    },

    shutdown:function()

    {

        //this.background.destroy();

        //this.background = null;

    },

    playButtonClick:function()

    {

        this.state.start('GamePlay',true);

    }

};

How do I properly clean up objects after each state? The reference of 'this.background' is still there, but is the image gone from memory?

I'm asking because if I need to destroy every display object and set it to null, I'm not planning to use any local variable (e.g: playButton) for display objects.

Sorry for newbish question.
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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