yegorf1 Posted May 2, 2014 Share Posted May 2, 2014 Hi again!Is there any way to draw dotted line, except sprite and many small lines? Link to comment Share on other sites More sharing options...
Pedro Alpera Posted May 2, 2014 Share Posted May 2, 2014 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); } christianstrang and yegorf1 2 Link to comment Share on other sites More sharing options...
yegorf1 Posted May 2, 2014 Author Share Posted May 2, 2014 As I see, easier and faster to use sprite? Link to comment Share on other sites More sharing options...
Pedro Alpera Posted May 2, 2014 Share Posted May 2, 2014 It depends on what you want to build, you could use some kind of trail too: http://examples.phaser.io/_site/view_full.html?d=arcade%20physics&f=ship+trail.js&t=ship%20trail Link to comment Share on other sites More sharing options...
yegorf1 Posted May 2, 2014 Author Share Posted May 2, 2014 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 More sharing options...
yegorf1 Posted May 2, 2014 Author Share Posted May 2, 2014 Oh. Okay. I found mistake. Need change bmd = this.game.add.bitmapData(800,600);tobmd = this.game.add.bitmapData(WINDOW_WIDTH, WINDOW_HEIGHT); Link to comment Share on other sites More sharing options...
Recommended Posts