Jump to content

Game.debug.bodyInfo and console.log info do not match


dbseraph
 Share

Recommended Posts

I am trying to add a jump to my game, but for some reason the detection is not working.

 

post-10020-0-65938200-1407360455_thumb.j

 

As you can see in the image, the debug.bodyInfo (in-game) shows the blocked.down bool is true. I have my jump key to dump the blocked object to console, and as shown it still says blocked.down is false.

 

The blocked.down does show correctly in console when the sprite is at the very bottom of the screen, which is why the "JUMPING!" line fired once. The sprite landed on the platform above it, but wouldn't jump after that.

 

The layer is a tilemap,  set as so:

 

this.bg = this.add.tilemap('level');this.bg.addTilesetImage('level_sheet', 'tiles');this.layer = this.bg.createLayer('layer_1');this.bg.setCollisionByExclusion([12], true, this.layer);

This is the jump code:

 

// jump    if (this.input.keyboard.justPressed(jump)) {      if (this.player.body.blocked.down) {        this.player.body.velocity.y = -600;        console.log("JUMPING!");      }      console.log(this.player.body.blocked);    }

Any help is appreciated!

Link to comment
Share on other sites

That is actually what I originally tried, following a phaser example. But as you can see in the image, body.touching.down is also reading false. It reads false consistently however. body.blocking down reads true in the game.debug output.

Link to comment
Share on other sites

  • 2 years later...
 Share

  • Recently Browsing   0 members

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