debug#renderShapeConvex fixed, fix in p2 physics body creation #446

This commit is contained in:
photonstorm
2014-02-19 15:43:05 +00:00
parent 1d3616f52c
commit aac31bdaa4
4 changed files with 112 additions and 97 deletions
+5 -1
View File
@@ -1,5 +1,6 @@
var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create, update: update, render: render });
// var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create, update: update, render: render });
var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update: update, render: render });
function preload() {
@@ -36,6 +37,7 @@ function create() {
cannon = game.add.sprite(50, 500, 'arrow');
cannon.name = 'ship';
cannon.physicsEnabled = true;
cannon.body.setCircle(32);
playerGroup = game.physics.createCollisionGroup();
bulletGroup = game.physics.createCollisionGroup();
@@ -129,4 +131,6 @@ function update() {
function render() {
game.debug.renderPhysicsBody(cannon.body);
}
+13 -11
View File
@@ -22,23 +22,25 @@ function create() {
game.stage.backgroundColor = '#2d2d2d';
map = game.add.tilemap('map');
// map = game.add.tilemap('map');
map.addTilesetImage('ground_1x1');
map.addTilesetImage('tiles2');
// map.addTilesetImage('ground_1x1');
// map.addTilesetImage('tiles2');
map.setCollisionBetween(1, 12);
// map.setCollisionBetween(1, 12);
layer = map.createLayer('Tile Layer 1');
// layer = map.createLayer('Tile Layer 1');
layer.resizeWorld();
// layer.resizeWorld();
dump = map.generateCollisionData(layer);
// dump = map.generateCollisionData(layer);
ship = game.add.sprite(200, 200, 'ship');
ship.physicsEnabled = true;
// We do this because our ship is shaped like a triangle, not a square :)
ship.body.addPolygon({}, 29, 23 , 0, 23 , 14, 1);
// ship.body.setCircle(32);
// ship.body.setCircle(32, 20, 20);
game.camera.follow(ship);
@@ -74,11 +76,11 @@ function update() {
function render() {
for (var i = 0, len = dump.length; i < len; i++)
{
// for (var i = 0, len = dump.length; i < len; i++)
// {
// game.debug.renderPhysicsBody(dump[i]);
}
// }
// game.debug.renderPhysicsBody(ship.body);
game.debug.renderPhysicsBody(ship.body);
}