Skip to content

Commit

Permalink
docs: Update ex.Animation.fromSpriteSheet jsdoc
Browse files Browse the repository at this point in the history
  • Loading branch information
eonarheim committed Nov 16, 2024
1 parent 872132d commit 625a42d
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/engine/Graphics/Animation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,27 +210,27 @@ export class Animation extends Graphic implements HasTick {
*
* const anim = Animation.fromSpriteSheet(spriteSheet, range(0, 5), 200, AnimationStrategy.Loop);
* ```
* @param spriteSheet
* @param frameIndices
* @param durationPerFrameMs
* @param strategy
* @param spriteSheet ex.SpriteSheet
* @param spriteSheetIndex 0 based index from left to right, top down (row major order) of the ex.SpriteSheet
* @param durationPerFrameMs duration per frame in milliseconds
* @param strategy Optional strategy, default AnimationStrategy.Loop
*/
public static fromSpriteSheet(
spriteSheet: SpriteSheet,
frameIndices: number[],
spriteSheetIndex: number[],
durationPerFrameMs: number,
strategy: AnimationStrategy = AnimationStrategy.Loop
): Animation {
const maxIndex = spriteSheet.sprites.length - 1;
const invalidIndices = frameIndices.filter((index) => index < 0 || index > maxIndex);
const invalidIndices = spriteSheetIndex.filter((index) => index < 0 || index > maxIndex);
if (invalidIndices.length) {
Animation._LOGGER.warn(
`Indices into SpriteSheet were provided that don\'t exist: ${invalidIndices.join(',')} no frame will be shown`
);
}
return new Animation({
frames: spriteSheet.sprites
.filter((_, index) => frameIndices.indexOf(index) > -1)
.filter((_, index) => spriteSheetIndex.indexOf(index) > -1)
.map((f) => ({
graphic: f,
duration: durationPerFrameMs
Expand Down

0 comments on commit 625a42d

Please sign in to comment.