Jump to content

Convert Bitmap Text into a Button ?


rolandino
 Share

Recommended Posts

I have a sneaky feeling that there's an example for this somewhere and I've just missed it. Apologies if that's the case. This is what I'd like to do:

Create some bitmap text:

this.levelText = this.game.add.bitmapText(0, t_sb_y+70, 'myfont', '', 18);

this.add(this.levelText);

this.levelText.setText(Globals['level'].toString());

And turn it into a Phaser Button.

Or, just detect when it's been clicked on ....

Any suggestions anyone?

Thanks,

R

Link to comment
Share on other sites

Same way you would an image such as this.

this.levelText = this.game.add.bitmapText(0, t_sb_y+70, 'myfont', '', 18);this.add(this.levelText);this.levelText.setText(Globals['level'].toString());this.levelText.inputEnabled = true;this.levelText.events.onInputDown.add(listener, this);function listener() {  console.log('clicked');}

Or you could align the BitmapText with a Phaser.Button like this thread discusses.

http://www.html5gamedevs.com/topic/7837-how-do-i-align-text-with-a-sprite/?hl=text

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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