Constructor
new Sprite(image, width, height)
Create a new sprite.
Parameters:
Name | Type | Description |
---|---|---|
image | HTMLImageElement | Image to use for drawing |
width | number | Width of image |
height | number | Height of image |
- Source
Members
height
Get the height of the sprite.
- Source
image
Get the image for the sprite.
- Source
width
Get the width of the sprite.
- Source
Methods
draw(ctx, pos, size)
Draw the sprite.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
ctx | CanvasRenderingContext2D | ||
pos | Vec2 | Position/offset to draw sprite at | |
size | Vec2 | | null | Custom size of drawn sprite (or null to use default) |
- Source
update(elapsed)
Update the sprite.
Parameters:
Name | Type | Description |
---|---|---|
elapsed | number | Time since last update cycle in seconds |
- Source