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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

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