Skip to content

Commit

Permalink
Final body / physics / bounds fixes. Also updated various examples, o…
Browse files Browse the repository at this point in the history
…ptimised Sprite core loop and enhanced the Invaders example.
  • Loading branch information
photonstorm committed Oct 30, 2013
1 parent 3de6290 commit 24c809d
Show file tree
Hide file tree
Showing 9 changed files with 383 additions and 197 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,15 @@ Change Log
Version 1.1.2

* New: You'll now find a complete Basic project Template in the resources/Project Templates folder. Will add more complex ones soon.
* New: Phaser.Button now has the ability to set over/out/up/down sound effects so they play automatically based on those events.
* Updated: Fixed a few final bugs in the Sprite body and bounds calculations, in turn this resolved the Tilemap collision issues in the 1.1 release.
* Updated: Finished documentation for the Phaser.Button class.
* Fixed issue 135 - Added typeof checks into most ArcadePhysics functions to avoid errors with zero values.
* Fixed issue 136 - distanceTo using worldX/Y instead of x/y.
* Added init method to plugins, to be called as they are added to the PluginManager (thanks beeglebug)
* If you pause an Animation, when you next play it it'll resume (un-pause itself).
* Started work on fixing the body / camera / tilemap issue - pretty much sorted now I think, more tests needed.


* New: Physics.Body now has a center property (issue 142, thanks MikeMnD)
* Updated: Fixed the Invaders game sample and enhanced it, also fixed lots of "cursor key moves the page" examples.


Version 1.1.1 - October 26th 2013
Expand Down
2 changes: 1 addition & 1 deletion examples/camera/basic follow.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,6 @@ function render() {
game.debug.renderSpriteCoords(player, 32, 200);
game.debug.renderSpriteCoords(fixed, 600, 200);

game.debug.renderSpriteCoords(game.world._container, 32, 400);
// game.debug.renderSpriteCoords(game.world._container, 32, 400);

}
48 changes: 29 additions & 19 deletions examples/games/invaders.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,23 @@ function preload() {
game.load.image('bullet', 'assets/misc/bullet0.png');
game.load.image('alien', 'assets/sprites/space-baddie.png');
game.load.image('ship', 'assets/sprites/shmup-ship.png');
game.load.spritesheet('kaboom', 'assets/games/tanks/explosion.png', 64, 64, 23);
game.load.image('starfield', 'assets/misc/starfield.jpg');

}

var player;
var aliens;
var bullets;
var bulletTime = 0;
var cursors;
var fireButton;
var explosions;

function create() {

s = game.add.tileSprite(0, 0, 800, 600, 'starfield');

player = game.add.sprite(400, 500, 'ship');
player.anchor.setTo(0.5, 0.5);

Expand All @@ -33,21 +40,29 @@ function create() {
aliens.x = 100;
aliens.y = 50;

bullets = game.add.group(null, 'bullets');
// Our bullet group
bullets = game.add.group();
bullets.createMultiple(30, 'bullet');
bullets.setAll('anchor.x', 0.5);
bullets.setAll('anchor.y', 1);
bullets.setAll('outOfBoundsKill', true);

// Explosion pool
explosions = game.add.group();

for (var i = 0; i < 10; i++)
{
var b = bullets.create(0, 0, 'bullet');
b.name = 'bullet' + i;
b.exists = false;
b.visible = false;
b.anchor.setTo(0.5, 1);
b.events.onOutOfBounds.add(resetBullet, this);
var explosionAnimation = explosions.create(0, 0, 'kaboom', [0], false);
explosionAnimation.anchor.setTo(0.5, 0.5);
explosionAnimation.animations.add('kaboom');
}

var tween = game.add.tween(aliens).to({x: 200}, 3000, Phaser.Easing.Linear.None, true, 0, 1000, true);
tween.onComplete.add(descend, this);

cursors = game.input.keyboard.createCursorKeys();
fireButton = game.input.keyboard.addKey(Phaser.Keyboard.SPACEBAR);

}


Expand All @@ -60,16 +75,16 @@ function update() {
player.body.velocity.x = 0;
player.body.velocity.y = 0;

if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
if (cursors.left.isDown)
{
player.body.velocity.x = -200;
}
else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
else if (cursors.right.isDown)
{
player.body.velocity.x = 200;
}

if (game.input.keyboard.isDown(Phaser.Keyboard.SPACEBAR))
if (fireButton.isDown)
{
fireBullet();
}
Expand Down Expand Up @@ -104,16 +119,11 @@ function collisionHandler (bullet, alien) {
bullet.kill();
alien.kill();

}

function render () {

// aliens.forEach(renderBounds, this);

game.debug.renderQuadTree(game.physics.quadTree);
var explosionAnimation = explosions.getFirstDead();
explosionAnimation.reset(alien.body.x, alien.body.y);
explosionAnimation.play('kaboom', 30, false, true);

}

function renderBounds(s) {
game.debug.renderSpriteBounds(s, 'rgba(0,0,255,0.4)', true);
function render () {
}
1 change: 1 addition & 0 deletions resources/Project Templates/Basic/Boot.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
BasicGame = {};

BasicGame.Boot = function (game) {

Expand Down
1 change: 1 addition & 0 deletions resources/Project Templates/Basic/Game.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

BasicGame.Game = function (game) {

// Honestly, just about anything could go here.
Expand Down
1 change: 1 addition & 0 deletions resources/Project Templates/Basic/MainMenu.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

BasicGame.MainMenu = function (game) {

this.music = null;
Expand Down
Loading

0 comments on commit 24c809d

Please sign in to comment.