elsioneto Posted March 17, 2014 Share Posted March 17, 2014 Does anyone there could make an overlap with ninja physics? In the documentation there is an 'overlap' method but it reacts as an normal collision. I'm seeing that there is a problem with the P2 overlap method too. Any ideas there? Link to comment Share on other sites More sharing options...
Robert O'Rourke Posted March 17, 2014 Share Posted March 17, 2014 Do you have an example from the code you're trying? I got overlap detection working but not the process callback. Link to comment Share on other sites More sharing options...
elsioneto Posted March 17, 2014 Author Share Posted March 17, 2014 Yes, sure have Here it is the code// creating the objects and enabling physicsobjects.p1 = app.game.add.sprite(300,200,'p1');objects.p2 = app.game.add.sprite(380,200,'p2');game.physics.ninja.enable(objects.p1);game.physics.ninja.enable(objects.p2);objects.p1.inputEnabled = true;game.camera.follow(objects.p1);And in the update function// checking collisiongame.physics.ninja.overlap(objects.p1, objects.p2, callback))That's it. I've already tried to modify some of the example projects, but got nothing. Thanks for the reply (: Link to comment Share on other sites More sharing options...
Robert O'Rourke Posted March 18, 2014 Share Posted March 18, 2014 Hi again, What does your callback function look like? You might need to provide all the arguments for the overlap function eg:function update( game ) { // the 4th argument can be an extra callback to decide whether onOverlap should be called depending on if it returns true or false // the last argument is what 'this' inside the onOverlap callback is set to eg. 'this' or 'game' game.physics.ninja.overlap( objects.p1, objects.p2, onOverlap, null, game );}function onOverlap( p1, p2 ) { // p1 is the first sprite passed in // p2 is the second // example picking up a medikit p1.health += 10; p2.kill();} Link to comment Share on other sites More sharing options...
elsioneto Posted March 18, 2014 Author Share Posted March 18, 2014 Yes, i'm doing just like this... And still, i`m getting a collision behaviour here's my callback obj.callback = function(a, { emitter.x = (a.x+b.x)/2 emitter.y = (a.y+b.y)/2 emitter.start(true, 2000, null, 50); }I'm colliding with a tile set. Does that should be a problem? Link to comment Share on other sites More sharing options...
Robert O'Rourke Posted March 18, 2014 Share Posted March 18, 2014 Hmm. A tileset could well behave differently but I thought you were just checking for overlapping of the 2 sprites? Do you want the sprites to move through the tiles? I know there's a fair bit of a todo list relating to the ninja physics engine. One thing you could try is to enabling a basic type of body for the objects eg. what happens when you use the following?:game.physics.ninja.enableBody( objects.p1 );game.physics.ninja.enableBody( objects.p2 ); yovo 1 Link to comment Share on other sites More sharing options...
Recommended Posts