Jump to content

Set group Height


omarojo
 Share

Recommended Posts

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

 

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

this.upperContainer.height = 500;

console.log(this.upperContainer.height);

 

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

 Share

  • Recently Browsing   0 members

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