Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Getting a sprite's dimensions

in Questions Posts: 65

Hi,
I'm trying to get the dimensions of a Sprite for a project I'm creating. I have tried sprite.width and sprite.height, and that didn't work. Anyone know how to get them?

Tagged:

Comments

  • dave1707dave1707 Mod
    Posts: 5,821
    function setup()
        img=readImage("Planet Cute:Character Horn Girl")
        print(img.width)
        print(img.height)
    end
    
  • Posts: 195

    @niorg2606 you can also do this:

    function setup()
         local width,height=spriteSize("Planet Cute:Character Horn Girl")
         print(width)
         print(height)
    end
    

    Except, I would recommend what @dave1707 did because it's much more versatile.

  • dave1707dave1707 Mod
    edited March 10 Posts: 5,821

    As @CamelCoder pointed out, there's usually more than one way to do something. You'll find that out as you write more code. A lot of it comes down to your coding style.

Sign In or Register to comment.