Fixed the Body collide issues and optimised the process at the same time. Now the QuadTree appears to work perfectly as a result. Bonus!

This commit is contained in:
Richard Davey
2013-09-08 01:24:59 +01:00
parent bb5d8ca170
commit fe6664eac7
7 changed files with 116 additions and 44 deletions
+14 -2
View File
@@ -24,17 +24,29 @@
function create() {
player = game.add.sprite(400, 300, 'ship');
player.alpha = 0.2;
player.body.collideWorldBounds = true;
player.body.bounce.setTo(1, 1);
// The body offset is from the ANCHOR point of the Sprite, not the top-left (or center, etc)
player.body.setSize(60, 60, 0, 0);
player.anchor.setTo(0.5, 0.5);
player.body.velocity.x = 100;
}
function update() {
// console.log(Math.floor(player.center.x), Math.floor(player.center.y));
player.angle++;
player.scale.x += 0.005;
player.scale.y += 0.005;
}
function render() {
game.debug.renderSpriteCorners(player,true,true);
game.debug.renderRectangle(player.body.bounds);
// game.debug.renderSpriteCorners(player,true,true);
game.debug.renderRectangle(player.body);
game.debug.renderPixel(400, 300, 'rgb(255,0,0)');
game.debug.renderPoint(player.center, 'rgb(255,254,0)');
}
})();