Get Dimensions of Sprite? (SOLVED)

Hi, all-- for the life of me I can’t find anything in the docs about how to retrieve the width or height of a sprite. Anybody got any ideas?

Thanks!
Bryan

2 Likes
    print(go.get("#sprite", "size"))
    print(go.get("#sprite", "size.x"))
    print(go.get("#sprite", "size.y"))

For the Defold logo that comes with blank projects

DEBUG:SCRIPT: vmath.vector3(128, 128, 1)
DEBUG:SCRIPT: 128
DEBUG:SCRIPT: 128

7 Likes

Oh my God…if they just had ‘size’ on the ‘Property’ tab of a sprite object, I could’ve saved hours of my life. :slight_smile:

There’s ‘Position’ and ‘Rotation’, etc…but no ‘Size’-- of course, I should have guessed that would be the name of the property…weird that it’s not there, though…

Thanks!
Bryan

1 Like

You cannot change the size of a sprite from the editor or at run-time since it is a read-only property. You can however change the scale.

1 Like

Yeah, I was just trying to read the dimensions…

Bryan

1 Like