swissnetizen Posted March 11, 2015 Share Posted March 11, 2015 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.2My 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 More sharing options...
spencerTL Posted March 12, 2015 Share Posted March 12, 2015 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 More sharing options...
swissnetizen Posted March 12, 2015 Author Share Posted March 12, 2015 Yeah, I was prefacing them with a moveTo, I just didn't realise that the lineStyle had to be before moveTo.The circle one was an example from my head. I didn't really pay attention to it.Thanks! Link to comment Share on other sites More sharing options...
Recommended Posts