Nikow Posted March 30, 2015 Share Posted March 30, 2015 Hi ! I'm working on a speed runner game and i'm trying to do it with P2, but it's more hard than Arcade physics for me.. I have this:game.physics.p2.gravity.y = 800;bat = batGroup.create(posNewBat, 550, 'bat1');game.physics.p2.enable(bat,false);bat.body.setRectangle(600,260);bat.body.velocity.x = -500;But i need to apply my gravity to me hero and not bat... I don't know why with P2 ç__ç ? Thanks, Link to comment Share on other sites More sharing options...
valueerror Posted March 30, 2015 Share Posted March 30, 2015 you've set the global gravity.. you can now use the gravityScale setting to configure how much the global gravity affects the specific bodies.. Link to comment Share on other sites More sharing options...
Nikow Posted March 31, 2015 Author Share Posted March 31, 2015 Can i set the gravity just for a sprite ?? And not the global scene ? Link to comment Share on other sites More sharing options...
ZoomBox Posted March 31, 2015 Share Posted March 31, 2015 Actually I think you have to enable gravity in your world ( game.physics.p2.gravity.y = 600; for example)and then tell the game which object will be static or not. Look at the examples ! http://phaser.io/examples/v2/p2-physics/platformer-material Link to comment Share on other sites More sharing options...
Nikow Posted March 31, 2015 Author Share Posted March 31, 2015 Actually I think you have to enable gravity in your world ( game.physics.p2.gravity.y = 600; for example)and then tell the game which object will be static or not. Look at the examples ! http://phaser.io/examples/v2/p2-physics/platformer-materialI know this exemple !My prob is : my 'bat' sprite are moving on x axis...For now, my bat move on x but when hero sprite is falling on it, bat is falling too ... Link to comment Share on other sites More sharing options...
ZoomBox Posted March 31, 2015 Share Posted March 31, 2015 If bat.body.kinematic = true; then bat shouldn't move when the player hits it.And bat.body.velocity.x = 200; will allow you to move it horizontally. Link to comment Share on other sites More sharing options...
Nikow Posted March 31, 2015 Author Share Posted March 31, 2015 If bat.body.kinematic = true; then bat shouldn't move when the player hits it.And bat.body.velocity.x = 200; will allow you to move it horizontally.Oh ! I forget to look about kinematic ! Thank you again ZoomBox ! Link to comment Share on other sites More sharing options...
Recommended Posts