Skip to content

Commit

Permalink
actionHandle on Pixi
Browse files Browse the repository at this point in the history
  • Loading branch information
wighawag committed Aug 22, 2023
1 parent 2710221 commit c3e3892
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions web/src/lib/render/PIXICanvas.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@
events: app.renderer.events, // the interaction module is important for wheel to work properly when renderer.view is placed or scaled
});
const actionHandler = new ActionHandler();
viewport.on('clicked', (ev) => {
actionHandler.onCell(Math.floor(ev.world.x), Math.floor(ev.world.y));
});
// add the viewport to the stage
app.stage.addChild(viewport);
Expand All @@ -54,10 +59,10 @@
window.addEventListener('resize', onResize);
// add a red box
const sprite = viewport.addChild(new Sprite(Texture.WHITE));
sprite.tint = 0xff0000;
sprite.width = sprite.height = 1;
sprite.position.set(0, 0);
// const sprite = viewport.addChild(new Sprite(Texture.WHITE));
// sprite.tint = 0xff0000;
// sprite.width = sprite.height = 1;
// sprite.position.set(0, 0);
});
</script>

Expand Down

0 comments on commit c3e3892

Please sign in to comment.