Jump to content

Whats the best way to make a settings menu?


Ninjadoodle
 Share

Recommended Posts

Hi @enpu / Panda people :)

Just wondering what the best way to approach a settings menu would be ?

Basically I have a little settings button (cog), in the top right of my level. When you click the button, the settings menu shows (screen goes black and shows some buttons).

I am creating the settings menu in a separate container over the top of the stage.

Is it a good idea to create the settings menu class on the settings button click and destroy it when the back button is pressed, or is it better to create it as the start of the stage and just show/hide it?

Thanks for any feedback!

Link to comment
Share on other sites

How to use classes and when to create new instance and when not really depends on a situation, so there is no really one right answer to that.

The only thing that you should look for, is that you are not generating too much garbage, because that can cause performance issues.

Is JavaScript garbage collection familiar thing to you?

 

Link to comment
Share on other sites

You are not making mistakes here. In this case both ways probably work just as well, meaning the best way would be the one that looks best for you. A good rule of thumb would be to avoid creating new instances as much as possible.

About garbage collection..

Basically when you create object in JavaScript (like new instance of class) and store it into variable, then if at some point there is no way to access that object anymore or you overwrite the variable with another object, that previous object becomes garbage because it can't be used anymore.

Then from time to time JavaScript cleans all the garbage from memory, and if there is a lots of garbage, it can cause small pause in your game.

Note that this is really an issue only when there is so much garbage that the pause becomes noticeable.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

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