SimonLdj Posted March 6, 2015 Share Posted March 6, 2015 Hi, I'm trying basically to combine those two examplesp2 tilemap: http://examples.phaser.io/_site/view_full.html?d=p2%20physics&f=tilemap.js&t=tilemapand tilemaps paint tiles: http://examples.phaser.io/_site/view_full.html?d=tilemaps&f=paint+tiles.js&t=paint%20tiles My problem is updating the collision for the new tiles.I call game.physics.p2.convertTilemap(map, layer);first time in create() and again in update() (only if user clicked the map) once I call convertTilemap the second time I get this exception: Uncaught TypeError: Cannot set property 'body' of null Phaser.Physics.P2.Body.destroy Phaser.Physics.P2.clearTilemapLayerBodies Phaser.Physics.P2.convertTilemap updateTilemap update Phaser.StateManager.update Phaser.Game.updateLogic Phaser.Game.update Phaser.RequestAnimationFrame.updateRAF Phaser.RequestAnimationFrame.start._onLoopAs I understand the problem is my p2 body don't have a sprite (a p2.Body represent one of the tiles), than calling this.sprite.body = null;throws the exception. Is any p2.Body should have a sprite? If yes, why my don't have one. if no, isn't that a bug? Am I doing something wrong? Thank you! Link to comment Share on other sites More sharing options...
SimonLdj Posted March 8, 2015 Author Share Posted March 8, 2015 I also noticed just calling clearTilemapLayerBodies right after convertTilemap like this game.physics.p2.convertTilemap(map, layer); game.physics.p2.clearTilemapLayerBodies(map, layer);throws same exception... Any ideas anyone? Link to comment Share on other sites More sharing options...
Recommended Posts