mirror of
https://github.com/wassname/phaser.git
synced 2026-08-14 12:40:17 +08:00
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:
+14
-2
@@ -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)');
|
||||
}
|
||||
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user