Jump to content

Phaser.Graphics.lineTo Not Working


swissnetizen
 Share

Recommended Posts

I've got this problem with Phaser.Graphics; I'm trying to draw a line; however, it simply doesn't show up on the screen. I'm using v2.2.2

My code:

// Nothing shows upvar g = game.add.graphics(0, 0);// Without doing this, lineTo will throw "this.currentPath is null"g.moveTo(0, 0);g.lineStyle(5, 0xFFFFFF, 1);g.lineTo(50, 50);// I see a white circle (outlined)g.circle(50, 50, 50);

I'm really not sure how to fix this.

I'm also curious about the performance issues (if any) with Phaser.Graphics.

Link to comment
Share on other sites

Just a small mistake (perhaps  you use another framework where the drawing command is just circle?)  It should be drawCircle. All of the shape methods in Phaser's graphics are prefaced with 'draw'.  http://docs.phaser.io/Phaser.Graphics.html.

 

You do always need to start your first line by manually defining a moveTo.  If I remember correctly, subsequent ones start from the last's end point.

 

I'm not sure about performance - it's never had a noticeable impact on my stuff but I don't really do anything that intensive.

var g = game.add.graphics(0, 0);g.lineStyle(5, 0xFFFFFF, 1);  g.moveTo(0, 0);g.lineTo(50, 50);g.drawCircle(50, 50, 50);
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...