Costume
An image a sprite (or the stage) can wear. Each sprite owns a list of costumes and shows one at a time; switching costumes is how a sprite changes its appearance or animates.
The Costume engine class. Most members are available as free functions; this page documents the underlying API for advanced use.
center
Section titled “center”Costume.center: { x: number; y: number }The point inside the costume that lines up with the sprite’s position.
Since 1.0.0
height
Section titled “height”Costume.height: numberThe costume’s drawn height in pixels, after scaling is applied.
Since 1.0.0
Costume.img: HTMLImageElementThe loaded image element that holds this costume’s picture.
Since 1.0.0
isBitmap
Section titled “isBitmap”Costume.isBitmap: booleanWhether this costume is a bitmap image (true) rather than an SVG (false).
Since 1.0.0
Costume.name: stringThe name used to identify and switch to this costume.
Since 1.0.0
resolution
Section titled “resolution”Costume.resolution: 2 | 1How many image pixels map to each costume pixel (2 for most bitmaps, 1 for SVGs).
Since 1.0.0
Costume.scale: numberHow much the costume’s image is scaled when drawn.
Since 1.0.0
Costume.url: stringThe source URL where this costume’s image is loaded from.
Since 1.0.0
Costume.width: numberThe costume’s drawn width in pixels, after scaling is applied.
Since 1.0.0