sy (property)

Get or set the scaling factor for the height of a sprite.

Get

Get the height scale for the sprite.

let mySprite: Sprite = null

let xScale = mySprite.sy
xScale = mySprite.sy

Returns

  • a number that is the current scale for the height of the sprite.

Set

Set the height scale for the sprite.

let mySprite: Sprite = null

mySprite.sy = 2
mySprite.sy = 2

Parameter

  • value: the new height scale factor for the size of the sprite.

Examples

Stretch and shrink height

Scale a sprite’s height by 1 more size every second. Expand while it’s small and contract when it’s large.

let expand = 0
let mySprite = sprites.create(img`
    2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 
    2 7 7 7 7 7 7 7 7 7 7 7 7 7 7 2 
    2 7 7 7 7 7 7 7 7 7 7 7 7 7 7 2 
    2 7 7 7 7 7 7 7 7 7 7 7 7 7 7 2 
    2 7 7 7 7 7 7 7 7 7 7 7 7 7 7 2 
    2 7 7 7 7 7 7 7 7 7 7 7 7 7 7 2 
    2 7 7 7 7 7 7 7 7 7 7 7 7 7 7 2 
    2 7 7 7 7 7 7 7 7 7 7 7 7 7 7 2 
    2 7 7 7 7 7 7 7 7 7 7 7 7 7 7 2 
    2 7 7 7 7 7 7 7 7 7 7 7 7 7 7 2 
    2 7 7 7 7 7 7 7 7 7 7 7 7 7 7 2 
    2 7 7 7 7 7 7 7 7 7 7 7 7 7 7 2 
    2 7 7 7 7 7 7 7 7 7 7 7 7 7 7 2 
    2 7 7 7 7 7 7 7 7 7 7 7 7 7 7 2 
    2 7 7 7 7 7 7 7 7 7 7 7 7 7 7 2 
    2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 
    `, SpriteKind.Player)
game.onUpdateInterval(1000, function () {
    if (mySprite.sy == 1) {
        expand = 1
    } else if (mySprite.sy == 6) {
        expand = -1
    }
    mySprite.sy += expand
})

See also

sx, scale