Josepho Posted January 30, 2014 Share Posted January 30, 2014 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"); console.log(this.PROTA_BODY_EYES); console.log(this.PROTA_BODY_EYES.width); 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 Quote Link to comment Share on other sites More sharing options...
Sebi Posted January 31, 2014 Share Posted January 31, 2014 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"); console.log(JSON.stringify(this.PROTA_BODY_EYES)); console.log(this.PROTA_BODY_EYES.width); Then you will see that the first console.log too had the 100 width at the time the log happened. Quote Link to comment Share on other sites More sharing options...
Josepho Posted January 31, 2014 Author Share Posted January 31, 2014 Many thanks! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.