Jump to content

Set group Height


Recommended Posts

Do anyone knows how to set the height of a group ?


this.upperContainer = this.add.group();

this.upperContainer.height = 500;



/// Outputs zero 0


If I change the  x or y the group moves properly in the canvas, but I want to change the height and width

so I can add objects into that group that make calculations according to the height and width of this group container.



any ideas?

Link to comment
Share on other sites

group.height actually uses a setter function that tries to scale the group from its previous height value, which it gets by checking the bounds of all the children in the group. If the group's height is 0, which it would be if it's empty, then it would remain 0. Add something with non-zero bounds to the group and try it again.


Are you trying to change the height value without side effects? If it's purely application-level record keeping I'd add a different member variable to your group instead of touching something the framework uses.

Link to comment
Share on other sites

oh I see.. so the group size will be as big or as small as the objects take space inside of it.

I see.. 


FYI: I did add some objects inside the group and then printed the height again.. it is now > 0 

I kinda wanted to add objects inside the group using the group height and width. Like adding a sprite just in the center of the group, not the canvas. 

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.

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