Jump to content

onBeginContact not dispatched


MaximeC
 Share

Recommended Posts

Hi,

 

I have refactored my code in order to use states and classes. I now have Boot, Preload, MainMenu and Game classes. The code is cleaner but the callback associated to the onBeginContact is not called anymore. Without classes, it was working as expected.

 

 

In the create of Boot.js, I set the physics engine:

this.game.physics.startSystem(Phaser.Physics.P2JS);

In the create of Game.js, I create my sprite and a tilemap:

...var map = this.game.add.tilemap('map');var layer = map.createLayer('Tile Layer 1');map.addTilesetImage('ground');map.addTilesetImage('star');        layer.resizeWorld();map.setCollisionBetween(1, 17);...this.ship = this.game.add.sprite(200, 200, 'ship');this.ship.animations.add('propulse', [1, 2, 3]);this.game.physics.p2.enable(this.ship, false);this.ship.body.addPolygon({}, 30, 35  ,  0, 35  ,  14, 5);this.ship.body.onBeginContact.add(this.hitWall, this);...

 

hitWall is not called. I have tried using a simple function but same issue. If you need more information, please ask.

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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