Improve animation handling
This commit is contained in:
1 parent
9441e09d07
commit
74a77fa281
8 files changed
+84
-40
No files matched your search
@@ -0,0 +1,19 @@
|
||||
import { createAnimation, playAnimation } from "#/engine/Animation.ts";
|
||||
import { useEntity } from "#/engine/Entity.ts";
|
||||
import { fromSrc, type Sprite } from "#/lib/Sprite.ts";
|
||||
|
||||
const sprite: Sprite = await fromSrc("./assets/portal.png", 3, 1);
|
||||
|
||||
const { animate } = useEntity(import.meta, {
|
||||
animation: createAnimation(sprite, 400, 0),
|
||||
});
|
||||
|
||||
animate((entity, ctx, delta) => {
|
||||
playAnimation(
|
||||
ctx,
|
||||
entity.animation,
|
||||
entity.position.x,
|
||||
entity.position.y,
|
||||
delta,
|
||||
);
|
||||
});
|
||||
Reference in new issue
Block a user