How to get size of spine game object?

Hi,

I’m trying to get the display width and height of a spine game object created with this code:

let boy = this.add.spine(0, 0, 'boy', 'standing', true);

boy.x and boy.y are valid. But boy.width and boy.height (or boy.displayWidth and boy.displayHeight) are undefined.

You guys have any suggestions?
Your help is much appreciated!

Hi @megame,
Try boy.skeletonData.height and boy.skeletonData.width .
You can see all spine properties with console.log(boy).

Regards.

1 Like

I think I solved my problem by looking at the spine plugin source code.
It doesn’t have width, height properties. Instead it has a getBounds() function.
But getBounds() return actual size of the texture, so I have to multiply the size with scale value:

let boyWidth = boy.getBounds().size.x * boy.scaleX;

Little note here is: size.x, not size.width. Because that’s how the spine plugin was written.
Hope this is useful for someone.

Thank you @jjcapellan.