Jump to content

Error with static property [p2 Physics body]


BunBunBun
 Share

Recommended Posts

I try to make the object is "static" by the following code:

sprite.body.mass = 0;

or

sprite.body.static = true;

why the sprite is going to the upper left corner? x and y of the sprite are NaN after this line.

 

I want to create static polygon and check out the collision with dynamic circle.

 

 

all codes are based on \examples\p2 physics\load polygon 1.js

function create() {   game.physics.startSystem(Phaser.Physics.P2JS);   contra = game.add.sprite(400, 400, 'contra2');   ball = game.add.sprite(380,100, 'ball');   game.physics.p2.enable(contra, true);   game.physics.p2.enable(ball, true);   ball.body.addCircle(8.5);   ball.body.moveDown(200);   contra.body.clearShapes();   contra.body.loadPolygon('physicsData', 'contra2');      contra.body.mass = 0;}

 

Link to comment
Share on other sites

  • 8 months later...
 Share

  • Recently Browsing   0 members

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