Jump to content

Graphics class's width and height?


Eugenius
 Share

Recommended Posts

I found Graphics class has width and height  properties.

 

I thought they would work since it's from DisplayObjectContainer but seems not working.

 

I guessed it's because the Display Objects in the container are not sprites but vector graphics?

 

http://jsfiddle.net/BVWQp/4/

 

tried setting different values into width and height.

 

Although I use scale instead of size but it would be lovely to have such feature or update the documentation.

 

Thanks guys

Link to comment
Share on other sites

I found Graphics class has width and height  properties.

I thought they would work since it's from DisplayObjectContainer but seems not working.

It's not working because the width and height properties-functions of DisplayObjectContainer has been commented for some reasons: http://www.goodboydigital.com/pixijs/docs/files/src_pixi_display_DisplayObjectContainer.js.html#l32

They where using the local bounds of the DOC to calculate and modify the scale value.

 

I guessed it's because the Display Objects in the container are not sprites but vector graphics?

It's because a DisplayObject have no width and height. It's just like an infinite plane with some properties to help to interact with its children. If you add 4 sprites to a doc and modify the scale of the DOC, that will affect the scale of the 4 sprites. Or if you change the DOC position, that will also affect the 4 sprites position since every child position is relative to its parent.

The width and height properties of a sprite do not affect the DisplayObject, they affect the size of the texture linked to the DisplayObject.

 

Although I use scale instead of size but it would be lovely to have such feature or update the documentation.

Yes, the documentation needs an update. You could add an issue to https://github.com/GoodBoyDigital/pixi.js/issues

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