Skip to content

Redrawing line after mouse move #2562

Answered by tenpaMk2
KrzyZyb asked this question in Q&A
Discussion options

You must be logged in to vote

Hi, @KrzyZyb .
I have created a similar logic, but maybe it does not match perfectly your case.
See my bowman example: tap-ui.ts .

constructor(private engine: Engine) {
  this.eventPubSuber = new Actor();

  let dragUI: ScreenElement;

  engine.input.pointers.primary.on("down", (event: PointerEvent): void => {
    if (dragUI) dragUI.kill(); // if you right-click, this process is needed.

    dragUI = new ScreenElement({
      pos: event.screenPos,
    });
    engine.add(dragUI);

    engine.input.pointers.primary.on("move", (event: PointerEvent): void => {
      const canvas = new Canvas({
        width: engine.drawWidth,
        height: 32, // must be 2^n
        draw: (ctx: CanvasRender…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@KrzyZyb
Comment options

Answer selected by KrzyZyb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants