Jump to content

yegorf1
 Share

Recommended Posts

Some info here: http://www.rgraph.net/blog/2013/january/html5-canvas-dashed-lines.html

    function create() {        bmd = game.add.bitmapData(800,600);                bmd.ctx.beginPath();        bmd.ctx.lineWidth = "4";        bmd.ctx.strokeStyle = 'white';        bmd.ctx.setLineDash([2,3]);        bmd.ctx.moveTo(10, 10);        bmd.ctx.lineTo(400 , 400);        bmd.ctx.stroke();        bmd.ctx.closePath();        sprite = game.add.sprite(0, 0, bmd);     }
Link to comment
Share on other sites

I tried your code, but have issues.

So, this is my code:

var WINDOW_WIDTH =  window.innerWidth || document.documentElement.clientWidth ||                    document.getElementsByTagName('body')[0].clientWidth,    WINDOW_HEIGHT = window.innerHeight || document.documentElement.clientHeight ||                     document.getElementsByTagName('body')[0].clientHeight;function convertX(x) {	return WINDOW_WIDTH * x;}function convertY(y) {	return WINDOW_HEIGHT * y;}///bmd = this.game.add.bitmapData(800,600);        bmd.ctx.beginPath();bmd.ctx.lineWidth = "2";bmd.ctx.strokeStyle = 'white';bmd.ctx.setLineDash([5, 6]);bmd.ctx.moveTo(0, convertY(0.5));bmd.ctx.lineTo(convertX(1), convertY(0.5));bmd.ctx.stroke();bmd.ctx.closePath();this.game.add.sprite(0, 0, bmd);

But line isn't needed lenght, as you can see here.

 

Any ideas?

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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