Jump to content

Still Visible with no ' game.debug.geom ' ?


vmars316
 Share

Recommended Posts

Hello & Thanks ,
In code below :
Runs fine as is .
But I would like to run it without  game.debug.geom(rectA, '#ff0000');  .
If I do , then  rectA  is not visible . 
How can I run it with no  game.debug.geom(rectA, '#ff0000');  and rectA is still visible ?

Quote

var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'vm-rectangle-intersects', { create: create, update: update, render: render });
var rectA;
function create() {
    game.stage.backgroundColor = '#0000ff';
    rectA = new Phaser.Rectangle(0, 0, 64, 64);
    var style = { font: "bold 24px Arial", fill: "#ffffff"};
    xText = game.add.text(0, 0,"xPoint = ", style);  
    yText = game.add.text(160, 0,"yPoint = ", style);  
}
function update() {
    if (game.input.mousePointer.isDown)
    {
       rectA.x = game.input.activePointer.x;
       rectA.y = game.input.activePointer.y;
       xText.text = 'xPoint = ' + rectA.x;
       yText.text = 'yPoint = ' + rectA.y;
       }   
}
function render() {
    game.debug.geom(rectA, '#ff0000');
}


Thanks

Link to comment
Share on other sites

1- Remove the render() code
2- Create a rectangle from the Graphics class like the code below

game.stage.backgroundColor = '#0000ff';
rectA = game.add.graphics(0, 0);
rectA.beginFill(0xff0000);
rectA.drawRect(0,0,64,64);
var style = { font: "bold 24px Arial", fill: "#ffffff"};
xText = game.add.text(0, 0,"xPoint = ", style);  
yText = game.add.text(160, 0,"yPoint = ", style);  

3- Keep the update() as it is

This should work :)

Edited by Batzi
Formatting the post
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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