trueicecold Posted October 4, 2014 Share Posted October 4, 2014 I'm trying to make a simple button with text on it. I could see the group resizes to the size of it's sprite image children, which is great. Now, I want text centered inside the group.However, when I position the sprite image/text, they get the world coordinates, rather than the group starting point...this.new_game = this.add.group();this.button = this.add.sprite(0, 0, "button_bg");this.text = this.add.text(0, 0, "New Game", {font:"20px",fill:"#ffffff",align:"center"});this.new_game.add(this.button);this.new_game.add(this.text);How do I fix this? Thanks! Link to comment Share on other sites More sharing options...
powerfear Posted October 4, 2014 Share Posted October 4, 2014 this.new_game = this.add.group();this.button = this.add.sprite(0, 0, "button_bg", null, this.new_game);this.text = this.add.text(0, 0, "New Game", {font:"20px",fill:"#ffffff",align:"center"}, this.new_game); orthis.new_game = this.add.group();this.button = this.make.sprite(0, 0, "button_bg");this.text = this.make.text(0, 0, "New Game", {font:"20px",fill:"#ffffff",align:"center"});this.new_game.add(this.button);this.new_game.add(this.text); I think both of those ways should work, but I didn't test. Link to comment Share on other sites More sharing options...
trueicecold Posted October 5, 2014 Author Share Posted October 5, 2014 powerfear, so "make" just creates it, and it associates with the first parent who adds it, and add actually adds it, but you have the chance of changing its parent? That's really awesome, thanks! Link to comment Share on other sites More sharing options...
Recommended Posts