Jump to content

What code do you put in the init() function?


toto88x
 Share

Recommended Posts

Hi,

I know about the preload, create and update function in Phaser. But I only really recently learned about the init function. And now I'm wondering: when am I supposed to use it?

What code should I put in the init function? Setting the physics engine? Scaling the game? Adding a background color? Something else?

So far I put all of this at the beginning of the create function. Is that a bad idea? will using the init function instead have any advantage?

Thanks!

Link to comment
Share on other sites

I wouldn't worry about "best practices" right now? If you haven't found a situation where one state needs to pass information to another state that's not via global variables... then sounds like you don't really need an init function. Or maybe you put it in and everything's still fine.

Nothing's a bad idea if your game works. Shipping is a feature ahead of best practices.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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