Jump to content

Bitmap Text button background


Recommended Posts



I use a Bitmap Text as a button.

By enabling interactive property it is quite easy to handle clicks, but only on characters.

Is there a way to make the whole text area clickable ?


I tried to add it to a container and listen for the container click, but the result is the same : The event is triggered on a text click only. Clicking between two characters of a word does not do anything.


In a perfect world, I would like my BitmapText background to be transparent in order not to cover the scene background details.

Do I ask too much ?

Link to comment
Share on other sites

Thank you for the tip !


I tried it and it works perfectly.

I was looking for a dynamic way to make the Sprite exactly the same size as the BitmapText's one and found Stephan's panda.js fiddler page (of an inestimable value)


Then I rewrite my BitmapText button like this :

var txtButton = new game.BitmapText("My Label is clickable", { font: 'myAwesomeFont' });txtButton.position.set(0, 0);txtButton.hitArea = new game.PIXI.Rectangle(0, 0, txtButton.width, txtButton.height);txtButton.addTo(myContainer);

I still have some strange padding issue at the bottom, but I wrote less lines for the same results.


Thank again, PixelPicoSean for driving me to a good solution.

Link to comment
Share on other sites

  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

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