Massemassimo Posted May 14, 2014 Share Posted May 14, 2014 Hey, since sprite.scale.setTo takes factors instead of a target pixel amount, I was looking for another way to change the size. Since I didn't find anything about that in the phaser doc and phaser.sprite derives from the pixi.js sprite, I checked the pixi doc and found sprite.width() and .height(). Sadly for sprite.width(x); typescript tells me I "cannot invoke an expression whose type lacks a call signature." Is this a type definition file problem? How could I change the definitions file to make it work? Link to comment Share on other sites More sharing options...
Heppell08 Posted May 14, 2014 Share Posted May 14, 2014 I'm sure there is a setSize method or something similar.sprite.body.setSize(width, height, offsetX, offsetY); Link to comment Share on other sites More sharing options...
rich Posted May 14, 2014 Share Posted May 14, 2014 sprite.width = 300;(or whatever width you need) This will automatically adjust the scale values to accommodate the width given. Massemassimo and kass 2 Link to comment Share on other sites More sharing options...
Massemassimo Posted May 15, 2014 Author Share Posted May 15, 2014 Thanks!! Is there a reasoning behind it not being in the docs? Or just "wasn't added yet"? Link to comment Share on other sites More sharing options...
rich Posted May 15, 2014 Share Posted May 15, 2014 None of the Pixi level properties are in the docs at the moment. Still trying to find a way to easily add them (as they use YUIdoc syntax and we use jsdoc) Massemassimo 1 Link to comment Share on other sites More sharing options...
Rocco Posted May 15, 2014 Share Posted May 15, 2014 sorry for hijacking the thread, but it also has to do with sprite.width. i'm missing a way to get the image dimenstion values, like:var image_width = sprite.width();Is it possible somehow? Link to comment Share on other sites More sharing options...
rich Posted May 16, 2014 Share Posted May 16, 2014 If you haven't changed it, then just Sprite.width and Sprite.height will give you the FRAME dimensions (as the Sprite may just be a frame in a texture atlas or sprite sheet). Link to comment Share on other sites More sharing options...
Rocco Posted May 17, 2014 Share Posted May 17, 2014 That's true, thank you, I thought I would have tried this way. Link to comment Share on other sites More sharing options...
Recommended Posts