Dead Pool Posted September 17, 2016 Share Posted September 17, 2016 How to set background color and text for a button in Phaser? Or it is possible only using Sprites? Link to comment Share on other sites More sharing options...
squilibob Posted September 18, 2016 Share Posted September 18, 2016 You can create the button as a graphics object and create text on top of it, put them in a group and then add click handlers to that group var buttonelement = []; buttonelement.push(game.add.graphics(0, 0)); buttonelement.push(game.add.text(0, 0, text, textstyle)); buttonelement[0].beginFill(color, 1); buttonelement[0].drawRoundedRect(x,y,width,height); buttonelement[0].endFill(); group.addMultiple(buttonelement); group.x = x; group.y = y; group.onChildInputOver.add(this.onOver, game); group.onChildInputOut.add(this.onOut, game); group.onChildInputDown.add(this.onClick, game); samme 1 Link to comment Share on other sites More sharing options...
Recommended Posts