Skip to content

Commit e3869ff

Browse files
committed
* 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
1 parent e705509 commit e3869ff

6 files changed

Lines changed: 102 additions & 4 deletions

File tree

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@ Version 1.0.2
4848
* Added 'collideWorldBounds' to Emitter.makeParticles function.
4949
* Added Emitter.angularDrag
5050
* Changed Emitter.bounce from a number to a Point, so now set its x/y properties to control different amounts of bounce per axis.
51-
51+
* Fixed a bug in the AnimationManager where useNumericIndex was always set to true
52+
* Added in lots of Particle examples
53+
* Added in the start of a Breakout game
54+
* Added in the start of a Platformer game
5255

5356
Version 1.0.1
5457

examples/games/breakout.php

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
<?php
2+
$title = "Breakout";
3+
require('../head.php');
4+
?>
5+
6+
<script type="text/javascript">
7+
8+
(function () {
9+
10+
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { preload: preload, create: create, update: update, render: render });
11+
12+
function preload() {
13+
14+
game.load.atlas('breakout', 'assets/sprites/breakout.png', 'assets/sprites/breakout.json');
15+
16+
}
17+
18+
var ball;
19+
var paddle;
20+
var bricks;
21+
var ballOnPaddle = true;
22+
23+
function create() {
24+
25+
var brick;
26+
bricks = game.add.group();
27+
28+
for (var y = 0; y < 4; y++)
29+
{
30+
for (var x = 0; x < 15; x++)
31+
{
32+
brick = bricks.create(120 + (x * 36), 100 + (y * 52), 'breakout', 'brick_' + (y+1) + '_1.png');
33+
brick.body.bounce.setTo(1, 1);
34+
brick.body.immovable = true;
35+
}
36+
}
37+
38+
ball = game.add.sprite(game.world.centerX, 534, 'breakout', 'ball_1.png');
39+
ball.body.collideWorldBounds = true;
40+
ball.body.bounce.setTo(1, 1);
41+
ball.animations.add('spin', [ 'ball_1.png', 'ball_2.png', 'ball_3.png', 'ball_4.png', 'ball_5.png' ], 50, true, false);
42+
43+
paddle = game.add.sprite(game.world.centerX, 550, 'breakout', 'paddle_big.png');
44+
paddle.body.collideWorldBounds = true;
45+
paddle.body.bounce.setTo(1, 1);
46+
paddle.body.immovable = true;
47+
48+
game.input.onDown.add(releaseBall, this);
49+
50+
}
51+
52+
function update () {
53+
54+
paddle.x = game.input.x;
55+
56+
if (ballOnPaddle)
57+
{
58+
ball.x = paddle.x + 16;
59+
}
60+
else
61+
{
62+
game.physics.collide(paddle, ball);
63+
game.physics.collide(ball, bricks, ballHitBrick, null, this);
64+
}
65+
66+
}
67+
68+
function releaseBall () {
69+
70+
ballOnPaddle = false;
71+
ball.body.velocity.y = -300;
72+
ball.body.velocity.x = -75;
73+
ball.animations.play('spin');
74+
75+
}
76+
77+
function ballHitBrick (_ball, _brick) {
78+
79+
_brick.kill();
80+
81+
}
82+
83+
function render () {
84+
}
85+
86+
})();
87+
</script>
88+
89+
<?php
90+
require('../foot.php');
91+
?>

phaser-logo-small.png

176 KB
Loading

src/Phaser.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*/
44
var Phaser = Phaser || {
55

6-
VERSION: '1.0.1',
6+
VERSION: '1.0.2',
77
GAMES: [],
88
AUTO: 0,
99
CANVAS: 1,

src/animation/AnimationManager.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,9 @@ Phaser.AnimationManager.prototype = {
5959

6060
frames = frames || null;
6161
frameRate = frameRate || 60;
62-
loop = loop || false;
63-
useNumericIndex = useNumericIndex || true;
62+
63+
if (typeof loop == 'undefined') { loop = false; }
64+
if (typeof useNumericIndex == 'undefined') { useNumericIndex = true; }
6465

6566
if (this._frameData == null)
6667
{
@@ -111,6 +112,8 @@ Phaser.AnimationManager.prototype = {
111112
*/
112113
validateFrames: function (frames, useNumericIndex) {
113114

115+
if (typeof useNumericIndex == 'undefined') { useNumericIndex = true; }
116+
114117
for (var i = 0; i < frames.length; i++)
115118
{
116119
if (useNumericIndex == true)

src/animation/Parser.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ Phaser.Animation.Parser = {
164164

165165
for (var key in frames)
166166
{
167+
console.log(key);
167168
var uuid = game.rnd.uuid();
168169

169170
newFrame = data.addFrame(new Phaser.Animation.Frame(

0 commit comments

Comments
 (0)