image

Tommy Leung from Ourcade writes: "It is common for buttons to have text in them. But like most GameObjects in Phaser, the basic button cannot have children. This means you have to manipulate buttons and text separately. In this article, we will show you how to use a Container to group them.

Phaser doesn't come with buttons but making a basic one is easy.

One issue with the basic button is that text can't be added to the button as a child. Phaser is designed to have a flat hierarchy so you can't add children like you might be used to in Flash, cocos2d, or other game frameworks.

Instead, Phaser has a Container type that is designed to group multiple GameObjects.

Those coming from Flash or Unity have probably created nodes called “container” to group things for simpler to manage animations."

Read More