Jump to content

P2 gravity Prob !


Nikow
 Share

Recommended Posts

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

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

I 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

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

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...