Jump to content

Problem getting the dimension of a BaseTexture


Recommended Posts

Hi there!


Im very noobish, im trying to make something that in first instance should be easy, but Im not able to do it, a odd behaviour is spoted instead. Im trying to get the dimensions of a basetexture..


I have a code like this:


    this.PROTA_BODY_EYES = PIXI.BaseTexture.fromImage("pqsAsset/prota/prota_ojos-fs8.png");
First console log, shows the info of the baseTexture correctly, with the correct width and height in its info, in this case is height = 280 width = 320
But, the second console log displays 100
Why is this? I am making something wrong?
I made some forum research and I found something about a IE error, I suppose I doesnt have nothing to do with this cause im using chrome :S
Help, please
Link to comment
Share on other sites

Because the image has not been loaded yet. 100 is the default width in PIXI.

The first one is a reference to the object itself, the second one is a reference to the current width value.


As the image is loaded, the first console.log will show you the properties of the obj which are updated, while the second one still points to the 100 value.


If you would do something like:



this.PROTA_BODY_EYES = PIXI.BaseTexture.fromImage("pqsAsset/prota/prota_ojos-fs8.png");
Then you will see that the first console.log too had the 100 width at the time the log happened.
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...