Improve animation handling

This commit is contained in:
kolaflash
2026-01-17 14:52:42 +01:00
parent 9441e09d07
commit 74a77fa281
8 changed files with 84 additions and 40 deletions
+3 -4
View File
@@ -1,18 +1,17 @@
import charIdle from "#/assets/char-idle.png";
import { createAnimation, playAnimation } from "#/engine/Animation.ts";
import { useEntity } from "#/engine/Entity.ts";
import { animateSprite, createAnimation } from "#/lib/Animation.ts";
import { fromSrc, type Sprite } from "#/lib/Sprite.ts";
const idle: Sprite = await fromSrc(charIdle, 2, 4);
const { animate, process } = useEntity(import.meta, {
animation: createAnimation(2, 500),
animation: createAnimation(idle, 500, 2),
});
animate((entity, ctx, delta) => {
animateSprite(
playAnimation(
ctx,
idle,
entity.animation,
entity.position.x,
entity.position.y,