Jump to content

PIXI.Container, setting width bugs?


ansien123
 Share

Recommended Posts

If you take a look at the code it may make a bit more sense:

https://github.com/pixijs/pixi.js/blob/master/src/core/display/Container.js#L35-L63

First, `_width` is not actually used, it is something that was left over from an old iteration and should always be `undefined` in v4. The reason you see it showing up is because of two things. One, it is actually set by the setter here, which adds the property. That line should not be there since it is a useless (and potentially harmful) operation. Two, when you log an object to the console the properties you inspect are not the values of that object at the time you logged it. Instead they are the properties at the time you clicked the "exapand" arrow to view them. Only at that interaction does Chrome evaluate the property values and display them, which is how you get 500, because before you click it your code sets it.

Second, you can see that changing the width modifies the scale of a container here. A container's "size" is just the size of its children added together, and their size acocunts for the parent's scale. When a container has no children, or no children of any particular size then it is of height/width 0. When at height/width 0, there is no scale to change.

Hopefully that helps clear it up.

Link to comment
Share on other sites

1 minute ago, xerver said:

If you take a look at the code it may make a bit more sense:

https://github.com/pixijs/pixi.js/blob/master/src/core/display/Container.js#L35-L63

First, `_width` is not actually used, it is something that was left over from an old iteration and should always be `undefined` in v4. The reason you see it showing up is because of two things. One, it is actually set by the setter here, which adds the property. That line should not be there since it is a useless (and potentially harmful) operation. Two, when you log an object to the console the properties you inspect are not the values of that object at the time you logged it. Instead they are the properties at the time you clicked the "exapand" arrow to view them. Only at that interaction does Chrome evaluate the property values and display them, which is how you get 500, because before you click it your code sets it.

Second, you can see that changing the width modifies the scale of a container here. A container's "size" is just the size of its children added together, and their size acocunts for the parent's scale. When a container has no children, or no children of any particular size then it is of height/width 0. When at height/width 0, there is no scale to change.

Hopefully that helps clear it up.

 

Ah okay... That explains so much. Thanks so much for the quick help guys, you're awesome!

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