Jump to content

[SOLVED] Get button dimensions including children?


GiniWren
 Share

Recommended Posts

Hey there --

For UI menus in my game, I have created a texture-less button that has a fake 9-patch image (really Phaser Group prototype extension) as a background and a Phaser Text object as its children. This creates buttons where the 9-patch background can be animated to change the button size without changing its scale. I have added instances those buttons as a Phaser Group that aligns them in a vertical column, using the buttons' heights for spacing.

The issue is, the children of the button don't affect the button's width/height or bounds, so the grid aligns them by the default texture dimensions: 32x32.

This minimal codepen roughly illustrates what I'm seeing/trying to do: https://codepen.io/giniwren/pen/xzvqMr

I found some old threads that suggest this is expected behavior, and I understand why, but the workarounds discussed are disruptive (e.g., using a group instead of a button means changing how all the events are attached to the button throughout the entire project).

Has there been a clean solution since then? Ideally in a way that lets me check dimensions the same way as the any other children added to the alignment group?

Thanks for any help on this one!

Link to comment
Share on other sites

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.

Guest
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.

Loading...
 Share

  • Recently Browsing   0 members

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