Jump to content

Making text stick to a button / using the 'parent' property


Recommended Posts


I wanted to create draggable buttons with some bitmaptext on them.


I ended up with this:

// the buttonvar button = this.game.add.button(x, y, "button", 0);button.input.enableDrag(false, false);// an intermediary group, just to be able to set the draggable 'button' as parentvar group = new Phaser.Group(this.game, button);// the text that i want to stick to the buttonvar text = new Phaser.BitmapText(this.game, 2, 2, "main-font", "text!!");group.add(text);

Is there a more clever way to do this? For instance, the text has a 'parent' property that I can set directly, skipping the group.

text.parent = button; 

I suppose that's from PIXI.GameObjectContainer. Presently, setting it as above works. Is there a safe way to use it, or some other way to use sprites/images/"gameobjectcontainers" as parents directly?


Link to comment
Share on other sites

  • 2 weeks later...

  • Recently Browsing   0 members

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