parwaniprakash Posted June 7, 2014 Share Posted June 7, 2014 Hello everyone, I am using latest phaser script and I stuck at one point. I am creating a small game in which different nodes(circle) are adding by lines. but If I add a background image then the line are not showing between nodes. For background image I have use this code :- function preload(){ game.load.image('background', 'img/back1.png');} function create() { game.add.tileSprite(0, 0, game.stage.bounds.width, game.cache.getImage('background').height, 'background');} if I use this code for line draw it is not showing :- function update() { graphic.moveTo(500,100); graphic.lineTo(500,500); } Please help me out. Thanks Link to comment Share on other sites More sharing options...
parwaniprakash Posted June 7, 2014 Author Share Posted June 7, 2014 This is the code I am using... var game = new Phaser.Game(1000, 700, Phaser.CANVAS, '', { preload: preload, create: create, update: update }); var sprite = null; var graphic = null; function preload() { game.load.image('background', 'img/back1.png'); } function create() { graphic = game.add.graphics(0, 0); game.add.tileSprite(0, 0, game.stage.bounds.width, game.cache.getImage('background').height, 'background'); graphic.lineStyle(10, 0xFF0000, 11); } function update() { graphic.moveTo(500,100); graphic.lineTo(500,500); } Link to comment Share on other sites More sharing options...
XekeDeath Posted June 7, 2014 Share Posted June 7, 2014 Add the graphics object after the tilesprite.Your line is behind your background image. Link to comment Share on other sites More sharing options...
parwaniprakash Posted June 7, 2014 Author Share Posted June 7, 2014 okk.. got it.. Thanks for your support.. Thanks a lot Link to comment Share on other sites More sharing options...
Recommended Posts