Jump to content

Strange line behavior


DNL
 Share

Recommended Posts

Hello,

I'm working with the drawing API to create graphics and I just found a glitch when creating lines that contain points very near between them.

For example, this line gets extended outside the screen:

var line= this.game.add.graphics(0, 0);
line.lineStyle(2,0xFF0000);
line.moveTo(206,363);
line.lineTo(205,421);
line.lineTo(205,416);

How I can solve this issue?

I should tell that I get an Array of coordinates so I cannot choose the points. Only I can do is to modify them somehow without losing the image that create.

Link to comment
Share on other sites

  • 2 weeks later...

Hello,

Finally I discover why that " glitch". In reallity it is the join of trazing lines. I saw the same error using the native line method from javascript:

  c=document.getElementById("myCanvas");
  ctx=c.getContext("2d");
  ctx.beginPath();
  ctx.lineWidth= 10;
  ctx.strokeStyle= "#FF0000";
  ctx.moveTo(180,155);
  ctx.lineTo(128,147);
  ctx.lineTo(343,312);
  ctx.stroke();

However, It can get fixed adding this lines to make the join union rounded:

ctx.lineJoin = ctx.lineCap = 'round';

Knowing that, how I can use these couple of methods (linejoin, lineCap) with the framework phaser?

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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