Heppell08 Posted March 14, 2014 Share Posted March 14, 2014 So what is the syntax for tilemap collision? I've hunted the Ninja and p2 and assume that tilemap still runs the arcade physics system. Now i have this:this.physics.arcade.collide(player, layer);Can someone correct me or point me in the right direction? Link to comment Share on other sites More sharing options...
Heppell08 Posted March 14, 2014 Author Share Posted March 14, 2014 The next problem i have is the sprite.body.x position coming back with this error for me:Uncaught TypeError: Cannot read property 'position' of null Is there any reason why the sprite position is throwing me out? Which physics is best to use for tilemap?Can i use multiple physics systems at once? I was hoping to use p2 physics on the player? Link to comment Share on other sites More sharing options...
Heppell08 Posted March 14, 2014 Author Share Posted March 14, 2014 Some iteration on this then from NINJA tilemap example...var slopeMap = { '32': 1, '77': 1, '95': 2, '36': 3, '137': 3, '140': 2 };// Whats being sloped, whats these numbers for?Then whats going on here: for (var i = 0; i < tiles.length; i++) { sprite1.body.circle.collideCircleVsTile(tiles[i].tile); }I get the premise but there is very minimal comment on this in the example. Any help? Link to comment Share on other sites More sharing options...
valueerror Posted March 14, 2014 Share Posted March 14, 2014 if you use p2 on the player everything that should collide with the player needs p2 too.. but if it makes sense somehow you could use p2 for some collisions and arcade for others that do not need to collide with each other...you probably forgot to enable the physics body? hard to tell with so little code... game.physics.p2.enable(player); Link to comment Share on other sites More sharing options...
valueerror Posted March 14, 2014 Share Posted March 14, 2014 i could provide an example with p2 tilemap layers,collisiongroups and collision callbacks... if you need it.. Link to comment Share on other sites More sharing options...
Heppell08 Posted March 14, 2014 Author Share Posted March 14, 2014 I got the 2 physics systems working now. I was looking at the examples and working on the code at the same time. Heres is what i have done... this.physics.startSystem(Phaser.Physics.ARCADE);this.physics.startSystem(Phaser.Physics.P2JS);// then this.physics.p2.gravity.y = +500; this.physics.p2.defaultRestitution = 0.8;this.physics.enable(player);this.physics.p2.enable(player);this.physics.arcade.collide(player, layer);With this in my setPlayer() functionthis.physics.enable(player);Took some doing but i eventually got it. Just working out the gravity in p2 and testing the jumps and stuff out. Thanks for the reply Link to comment Share on other sites More sharing options...
rich Posted March 15, 2014 Share Posted March 15, 2014 If you have a look at the phaser-examples repository I just uploaded an example of how to use p2 with a tilemap. Link to comment Share on other sites More sharing options...
Heppell08 Posted March 15, 2014 Author Share Posted March 15, 2014 I'll check that now. Thanks Rich! Link to comment Share on other sites More sharing options...
Recommended Posts