Skip to content

Commit 6ce1dff

Browse files
committed
Rendering position fix
1 parent 51da597 commit 6ce1dff

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

packages/glhf-demo/.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
src/*.js
2+
src/*.js.map

packages/glhf-demo/src/system/IdleSystem.ts

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ export default class IdleSystem extends System {
4646
console.log('IsIdle', entity.id);
4747

4848
if (component.properties.status === StateStatus.FINISHED) {
49+
console.log('IsIdle finished and removed');
4950
entity.removeComponent(IsIdle);
5051
return;
5152
}

packages/glhf-demo/src/system/RenderSystem.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ export default class RenderSystem extends System {
4040
}
4141

4242
const animationFrame = animation.frames[component.properties.animationTick];
43+
const hitboxOffset = animation.hitboxOffset;
44+
45+
const destPositionX = hitboxOffset?.x ? position.properties.x - hitboxOffset.x : position.properties.x;
46+
const destPositionY = hitboxOffset?.y ? position.properties.y - hitboxOffset.y : position.properties.y;
4347

4448
if (!animationFrame) {
4549
throw new Error(`Cannot find animation frame ${component.properties.animationTick} for "${component.properties.animationStateName}".`);
@@ -54,8 +58,8 @@ export default class RenderSystem extends System {
5458
animationFrame.width,
5559
animationFrame.height,
5660
// dest
57-
position.properties.x,
58-
position.properties.y,
61+
destPositionX,
62+
destPositionY,
5963
animationFrame.width,
6064
animationFrame.height
6165
);

0 commit comments

Comments
 (0)