Skip to content

equivilant of Phaser 3 Graphics.lineBetween ? #2313

Answered by eonarheim
airtonix asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @airtonix

Great question! A 1-face'd polygon does work. There isn't a dedicated line graphics primitive object similar to the Polygon (yet).

There are a couple options open to you to draw a line:

  1. Quickest & highest quality line: It is possible to drop to the excalibur graphics context and perform drawing

    const game = new ex.Engine({...})
    
    // draw using an actor
    const lineActor = new ex.Actor({
      pos: ex.vec(0, 0),
    });
    lineActor.graphics.localBounds = ex.BoundingBox.fromDimension(200, 200, ex.Vector.Zero);
    lineActor.graphics.onPostDraw = (ctx: ex.ExcaliburGraphicsContext) => {
      ctx.drawLine(ex.vec(0, 0), ex.vec(200, 200), ex.Color.Green, 10);
    }
    game.add(lineActor);
    
    game.start();
  2. B…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@eonarheim
Comment options

@airtonix
Comment options

Answer selected by airtonix
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