SpritePartition

Partitioned (clipped) area of a sprite for drawing.

Constructor

new SpritePartition(sprite, bounds)

Create a new sprite partition.
Parameters:
NameTypeDescription
spriteSpriteSprite to clip from
boundsBoundsBounds of clipped area

Members

height

Get the height of the sprite.

width

Get the width of the sprite.

Methods

copy() → {SpritePartition}

Get a copy of the sprite partition.
Returns:
Copied sprite partition
Type: 
SpritePartition

draw(ctx, pos, size)

Draw the sprite.
Parameters:
NameTypeDefaultDescription
ctxCanvasRenderingContext2D
posVec2Position/offset to draw sprite at
sizeVec2 | nullnullCustom size of drawn sprite (or null to use default)

update(elapsed)

Update the sprite.
Parameters:
NameTypeDescription
elapsednumberTime since last update cycle in seconds