Jump to content

p2 physics changing drawing point


Bmac
 Share

Recommended Posts

Hello, I am new to the forum so first thank you for welcoming me. 

Okay, so here is my question. I am working with Phaser's p2 physics, and to start I wanted to just make a ground with a character falling onto the ground. However, I ran into a problem. Using the code below: 

var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update });function preload() {	game.load.image('sky', 'assets/sky.png');	game.load.image('ground', 'assets/platform.png');}function create() {	game.physics.startSystem(Phaser.Physics.P2JS);	game.physics.p2.gravity.y = 100;	game.add.sprite(0, 0, 'sky');	platforms = game.add.group();	platforms.enableBody = true;	platforms.physicsBodyType = Phaser.Physics.P2;	var ground = platforms.create(0, game.world.height - 64, 'ground');	ground.scale.setTo(2, 2);	//game.physics.p2.enable(ground);	//ground.body.static = true;}function update() {}

I get this: 

 

post-17526-0-82220100-1448260639.png

 

Which is great! However, you can see that I have the line that enables ground for the p2 system commented out. When I uncomment this line and the one below it, I get this:

 

post-17526-0-97530900-1448260778.png

 

Which is super weird! However, I can fix the problem by changing my code where I create the ground to this. 

var ground = platforms.create(game.world.width/2, game.world.height - 32, 'ground');

This to me implies that enabling the variable for the p2 physics system changes the drawing point system somehow. If anyone can explain to me why this is happening, it would be greatly appreciated. 

Thank you

post-17526-0-38501100-1448260248.png

post-17526-0-69647100-1448260486.png

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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