New polygon collision object examples and Body scale fixes.

This commit is contained in:
photonstorm
2014-01-31 10:34:18 +00:00
parent 45b6d5a741
commit 27fc447928
28 changed files with 2080 additions and 1295 deletions
+12 -11
View File
@@ -29,16 +29,10 @@ function create() {
// Basically this sets EVERY SINGLE tile to fully collide on all faces
map.setCollisionByExclusion([7, 32, 35, 36, 47]);
layer.debug = true;
// layer.debug = true;
layer.resizeWorld();
sprite = game.add.sprite(450, 80, 'phaser');
sprite.anchor.setTo(0.5, 0.5);
game.camera.follow(sprite);
// game.camera.deadzone = new Phaser.Rectangle(160, 160, layer.renderWidth-320, layer.renderHeight-320);
cursors = game.input.keyboard.createCursorKeys();
emitter = game.add.emitter(0, 0, 200);
@@ -49,15 +43,18 @@ function create() {
emitter.gravity = 150;
emitter.bounce.setTo(0.5, 0.5);
game.input.onDown.add(particleBurst, this);
sprite = game.add.sprite(200, 70, 'phaser');
sprite.anchor.setTo(0.5, 0.5);
game.camera.follow(sprite);
}
function particleBurst() {
emitter.x = game.input.worldX;
emitter.y = game.input.worldY;
emitter.start(true, 4000, null, 10);
emitter.x = sprite.x;
emitter.y = sprite.y;
emitter.start(true, 2000, null, 1);
}
@@ -72,21 +69,25 @@ function update() {
if (cursors.up.isDown)
{
sprite.body.velocity.y = -150;
particleBurst();
}
else if (cursors.down.isDown)
{
sprite.body.velocity.y = 150;
particleBurst();
}
if (cursors.left.isDown)
{
sprite.body.velocity.x = -150;
sprite.scale.x = -1;
particleBurst();
}
else if (cursors.right.isDown)
{
sprite.body.velocity.x = 150;
sprite.scale.x = 1;
particleBurst();
}
}