sprite.height

Category:Sprites

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

The default height is 100. All sprite properties can be both accessed and updated.

Examples

var sprite = createSprite(200,200);
console.log(sprite.height);
sprite.height = 50;
console.log(sprite.height);
drawSprites();

Syntax

sprite.height

Returns

The height of the sprite.

Tips

  • use sprite.scale to resize a sprite and keep the height to width ratio constant.
  • Sprites all have the same properties and you use the dot notation (combining the name of the sprite, followed by a dot, with the label of the property) to both access and update the property for that sprite.
  • Any changes to the properties of a sprite will not be seen until after drawSprites() is called.

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