height (property)

Get the height of the sprite in pixels.


Get the pixel height of the sprite.

let mySprite: Sprite = null

let yPixels = mySprite.height
let yPixels = mySprite.height


  • a number that is the current height of the sprite in pixels.

Sprite sizes

The sprite size matches the size of the image it contains. The size of the sprite only changes when it’s image changes. The sprite height is also the same as the difference between the top and bottom sides.

let mySprite: Sprite = null

let height = mySprite.bottom - mySprite.top


Create an image that is 16 pixels wide. Make a sprite that has this image. Let the sprite say how wide it is.

namespace SpriteKind {
    export const Example = SpriteKind.create()
let blockImage = image.create(16, 16)
let mySprite: Sprite = null
mySprite = sprites.create(blockImage, SpriteKind.Example)
mySprite.say("I'm " + mySprite.height + " pixels high") 

See also

width, top, bottom