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.
Name | Type | Default | Description |
---|---|---|---|
path | string | "" | The path to the image. |
scaleX | number | 1 | The width of the sprite. |
scaleY | number | 1 | 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
- Source
(readonly) properties
The entity that this component is attached to.
- Inherited From
- Source
width
Width of the sprite in meters.