Skip to content

Commit

Permalink
* Fixed a bug in the AnimationManager where useNumericIndex was alway…
Browse files Browse the repository at this point in the history
…s set to true

* Added in lots of Particle examples
* Added in the start of a Breakout game
* Added in the start of a Platformer game
  • Loading branch information
photonstorm committed Sep 16, 2013
1 parent e705509 commit e3869ff
Show file tree
Hide file tree
Showing 6 changed files with 102 additions and 4 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ Version 1.0.2
* Added 'collideWorldBounds' to Emitter.makeParticles function.
* Added Emitter.angularDrag
* Changed Emitter.bounce from a number to a Point, so now set its x/y properties to control different amounts of bounce per axis.

* Fixed a bug in the AnimationManager where useNumericIndex was always set to true
* Added in lots of Particle examples
* Added in the start of a Breakout game
* Added in the start of a Platformer game

Version 1.0.1

Expand Down
91 changes: 91 additions & 0 deletions examples/games/breakout.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<?php
$title = "Breakout";
require('../head.php');
?>

<script type="text/javascript">

(function () {

var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { preload: preload, create: create, update: update, render: render });

function preload() {

game.load.atlas('breakout', 'assets/sprites/breakout.png', 'assets/sprites/breakout.json');

}

var ball;
var paddle;
var bricks;
var ballOnPaddle = true;

function create() {

var brick;
bricks = game.add.group();

for (var y = 0; y < 4; y++)
{
for (var x = 0; x < 15; x++)
{
brick = bricks.create(120 + (x * 36), 100 + (y * 52), 'breakout', 'brick_' + (y+1) + '_1.png');
brick.body.bounce.setTo(1, 1);
brick.body.immovable = true;
}
}

ball = game.add.sprite(game.world.centerX, 534, 'breakout', 'ball_1.png');
ball.body.collideWorldBounds = true;
ball.body.bounce.setTo(1, 1);
ball.animations.add('spin', [ 'ball_1.png', 'ball_2.png', 'ball_3.png', 'ball_4.png', 'ball_5.png' ], 50, true, false);

paddle = game.add.sprite(game.world.centerX, 550, 'breakout', 'paddle_big.png');
paddle.body.collideWorldBounds = true;
paddle.body.bounce.setTo(1, 1);
paddle.body.immovable = true;

game.input.onDown.add(releaseBall, this);

}

function update () {

paddle.x = game.input.x;

if (ballOnPaddle)
{
ball.x = paddle.x + 16;
}
else
{
game.physics.collide(paddle, ball);
game.physics.collide(ball, bricks, ballHitBrick, null, this);
}

}

function releaseBall () {

ballOnPaddle = false;
ball.body.velocity.y = -300;
ball.body.velocity.x = -75;
ball.animations.play('spin');

}

function ballHitBrick (_ball, _brick) {

_brick.kill();

}

function render () {
}

})();
</script>

<?php
require('../foot.php');
?>
Binary file added phaser-logo-small.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/Phaser.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/
var Phaser = Phaser || {

VERSION: '1.0.1',
VERSION: '1.0.2',
GAMES: [],
AUTO: 0,
CANVAS: 1,
Expand Down
7 changes: 5 additions & 2 deletions src/animation/AnimationManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,9 @@ Phaser.AnimationManager.prototype = {

frames = frames || null;
frameRate = frameRate || 60;
loop = loop || false;
useNumericIndex = useNumericIndex || true;

if (typeof loop == 'undefined') { loop = false; }
if (typeof useNumericIndex == 'undefined') { useNumericIndex = true; }

if (this._frameData == null)
{
Expand Down Expand Up @@ -111,6 +112,8 @@ Phaser.AnimationManager.prototype = {
*/
validateFrames: function (frames, useNumericIndex) {

if (typeof useNumericIndex == 'undefined') { useNumericIndex = true; }

for (var i = 0; i < frames.length; i++)
{
if (useNumericIndex == true)
Expand Down
1 change: 1 addition & 0 deletions src/animation/Parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ Phaser.Animation.Parser = {

for (var key in frames)
{
console.log(key);
var uuid = game.rnd.uuid();

newFrame = data.addFrame(new Phaser.Animation.Frame(
Expand Down

0 comments on commit e3869ff

Please sign in to comment.