Sprite

new Sprite()

A Sprite Component is responsible for rendering a sprite to the screen. Any Image (supported by the browser) can be used as a sprite.

Properties
NameTypeDefaultDescription
pathstring""

The path to the image.

scaleXnumber1

The width of the sprite.

scaleYnumber1

The height of the sprite.

Example
// Create a sprite component
let sprite = new Sprite("path/to/image.png",10,10);

// Add the sprite component to an entity
entity.addComponent(sprite);

Extends

Members

blendMode

Blend mode of the object

Inherited From

filter

The filter applied to the object

Inherited From

height

Height of the sprite in meters.

path :string

The Path to the image. Note: While hosting the game on a server, the path must be relative to the server.

Type:
  • string

path :string

The path to the image to display. Note: While hosting the game on a server, this might give errors thus use path with hhtps:// or http://

Type:
  • string

(readonly) properties

The entity that this component is attached to.

Inherited From

width

Width of the sprite in meters.