Jump to content

Phaser 3 debug property in physics not drawing debug layer


the-simian
 Share

Recommended Posts

Hello, I wanted to post here and ask about setting the game so you can debug physics.

Firstly: I am doing what I see in a lot of the examples, which is setting the debug property in the game config.

I've added a snippet of my config. I'm not 100% sure why, but this doesn't draw anything.

I did, with some looking around,  figure out how to draw a layer over the tilemap itself, but I really need to also draw over the player as well. plus those lines indicating velocity seem useful. The code that does correctly draw over the tilemap I have also included.

My guess is that I am doing something obviously incorrect. I seem to recall that for an older version of Phaser I needed a plugin to make the debug layer work correctly. Is that still true? If so what's the 'most correct' one to include? Could something be interfering? I do have an animation on my player sprite, and there's a background layer too, but disabling the background still did not help.

Thank you for any help!

//If i include this in my create() method I get some desirable results
this.map.renderDebug(this.debugGraphics, {
      tileColor: null,
      collidingTileColor: new Phaser.Display.Color(243, 134, 48, 128), 
      faceColor: new Phaser.Display.Color(40, 39, 37, 255) 
    });
/// This is my game config, it doesn't seem to do anything when I set debug: true

const config = {
  type: Phaser.AUTO,
  width: constants.WIDTH,
  height: constants.HEIGHT,
  physics: {
    default: 'arcade',
    arcade: {
      gravity: { y: 400 },
      debug: true //does nothing.
    }
  },
  scene: [StartScene, GameScene],
  pixelArt: true,
  antialias: false,
  callbacks: {
    postBoot: game => {
      game.renderer.addPipeline('Custom', new CustomPipeline(game));
    }
  }
};

const game = new Phaser.Game(config);
Link to comment
Share on other sites

Ok i did some experimenting, and I was able to figure out that the debug would only draw for the first scene in set in a list of scenes. I am not sure why, but i'm happily debugging now

change 

scene: [StartScene, GameScene],

to

scene: [GameScene],

and that works just fine.

Link to comment
Share on other sites

So sorry samme, I left that out. In the create method I also have create the map and the debugGraphics:
The debugGraphics draws on top of my tilemap, and it indicates the parts you can collide with. It seems to be working on, and since I removed them ultiple scenes, so does the Arcade physics debug - so everything works now. I am not sure why the arcade physics debug did not work for every scene, not just the first scene

this.map = this.make.tilemap({ key: 'map' });
this.debugGraphics = this.add.graphics();
 
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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