Game Lab Documentation

sprite.getScaledHeight()

Category:Sprites

The scaled height of the sprite's current image in pixels. If no image or animation are set, it’s the scaled height of the placeholder rectangle.

The sprite.scale property can be used to scale a sprite larger or smaller and keep the height to width ratio constant. For some games or animations you may need to know the actual height of the scaled sprite in pixels.

Examples

var sprite = createSprite(200, 200);
sprite.scale=0.75;
drawSprites();
console.log(sprite.width);
console.log(sprite.height);
console.log(sprite.getScaledWidth());
console.log(sprite.getScaledHeight());

Syntax

sprite.getScaledHeight()

Returns

The scaled height of the sprite.

Tips

  • If sprite is scaled, sprite.width and sprite.height are not changed. Use getScaledWidth() and getScaledHeight() instead.
  • If setCollider() is called for a sprite before it is scaled, the collider is not scaled. But if a sprite is first scaled and then the collider set, the scale is also applied to the collider.

Found a bug in the documentation? Let us know at support@code.org.