Motion helper functions added to the ArcadePhysics class.

This commit is contained in:
Richard Davey
2013-09-04 16:12:58 +01:00
parent 128bdccd79
commit 10bc22b717
4 changed files with 518 additions and 49 deletions
+7 -11
View File
@@ -25,17 +25,15 @@
function create() {
// game.world.setSize(2000, 2000);
aliens = [];
for (var i = 0; i < 10; i++)
for (var i = 0; i < 50; i++)
{
var s = game.add.sprite(game.world.randomX, game.world.randomY, 'baddie');
s.name = 'alien' + s;
s.body.collideWorldBounds = true;
s.body.bounce.setTo(1, 1);
s.body.velocity.setTo(10 + Math.random() * 10, 10 + Math.random() * 10);
s.body.velocity.setTo(10 + Math.random() * 40, 10 + Math.random() * 40);
aliens.push(s);
}
@@ -47,13 +45,6 @@
function update() {
// total = game.physics.overlap(ship);
for (var i = 0; i < aliens.length; i++)
{
game.physics.separate(ship.body, aliens[i].body);
}
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
{
ship.body.velocity.x -= 2;
@@ -72,6 +63,9 @@
ship.body.velocity.y += 2;
}
game.physics.collideGroup(aliens);
// total = game.physics.overlap(ship);
}
function render() {
@@ -79,6 +73,8 @@
game.debug.renderQuadTree(game.physics.quadTree);
game.debug.renderRectangle(ship.body.bounds);
// game.debug.renderText('total: ' + total.length, 32, 50);
game.debug.renderText('up: ' + ship.body.touching.up, 32, 70);
game.debug.renderText('down: ' + ship.body.touching.down, 32, 90);
game.debug.renderText('left: ' + ship.body.touching.left, 32, 110);