Jump to content

Line is not showing if background image is placed in Phaser


parwaniprakash
 Share

Recommended Posts

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

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

 Share

  • Recently Browsing   0 members

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