Skip to content

Commit

Permalink
Rendering position fix
Browse files Browse the repository at this point in the history
  • Loading branch information
serbanghita committed Mar 22, 2024
1 parent 51da597 commit 6ce1dff
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 2 additions & 0 deletions packages/glhf-demo/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
src/*.js
src/*.js.map
1 change: 1 addition & 0 deletions packages/glhf-demo/src/system/IdleSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export default class IdleSystem extends System {
console.log('IsIdle', entity.id);

if (component.properties.status === StateStatus.FINISHED) {
console.log('IsIdle finished and removed');
entity.removeComponent(IsIdle);
return;
}
Expand Down
8 changes: 6 additions & 2 deletions packages/glhf-demo/src/system/RenderSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ export default class RenderSystem extends System {
}

const animationFrame = animation.frames[component.properties.animationTick];
const hitboxOffset = animation.hitboxOffset;

const destPositionX = hitboxOffset?.x ? position.properties.x - hitboxOffset.x : position.properties.x;
const destPositionY = hitboxOffset?.y ? position.properties.y - hitboxOffset.y : position.properties.y;

if (!animationFrame) {
throw new Error(`Cannot find animation frame ${component.properties.animationTick} for "${component.properties.animationStateName}".`);
Expand All @@ -54,8 +58,8 @@ export default class RenderSystem extends System {
animationFrame.width,
animationFrame.height,
// dest
position.properties.x,
position.properties.y,
destPositionX,
destPositionY,
animationFrame.width,
animationFrame.height
);
Expand Down

0 comments on commit 6ce1dff

Please sign in to comment.