Wahooiy Posted May 4, 2016 Share Posted May 4, 2016 I am currently using P2JS to handle collisions within a platform game I am making. There are objects within the objects layer in my level that I want to be able to interact with (Standing over it, press button, do action). How can I create a collision overlap function like in Arcade physics? Link to comment Share on other sites More sharing options...
TheProdigy22 Posted May 4, 2016 Share Posted May 4, 2016 Like a collision callback function? Link to comment Share on other sites More sharing options...
Wahooiy Posted May 4, 2016 Author Share Posted May 4, 2016 Not necessarily, I want to be able to say: if button pressed if colliding with object Link to comment Share on other sites More sharing options...
TheProdigy22 Posted May 4, 2016 Share Posted May 4, 2016 So it would look like this in arcade? if(game.input.keyboard.isDown(Phaser.KeyCode.SPACE)) { if(sprite.body.touching.down === true) { //Something here } } Only with a certain object, right? (code above is for a jump) If so, this might be what you're looking for: http://phaser.io/docs/2.4.7/Phaser.Physics.P2.Body.html#collides Link to comment Share on other sites More sharing options...
Wahooiy Posted May 5, 2016 Author Share Posted May 5, 2016 Not really no. I'd like a P2 Version of the arcade.overlap. I'm not sure how to create a P2 collision group and then test if the player is overlapping it. Link to comment Share on other sites More sharing options...
game-dev-monkey Posted May 5, 2016 Share Posted May 5, 2016 I think this thread might help you - Particularly the part about in regard to sensors Link to comment Share on other sites More sharing options...
Recommended Posts