Skip to content

Commit 86f6ddc

Browse files
committed
Two new particle examples and a group animation example. Also fixed CocoonJS sound issue and Cache sound locked bug.
1 parent 3b87ce9 commit 86f6ddc

15 files changed

Lines changed: 228 additions & 13 deletions

File tree

README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,16 @@ Version 1.1.4 - "Kandor" - In development
4646

4747
Significant API changes:
4848

49-
* Loader.tileset has a new method signature. Please use the new format: load.tileset(key, url, tileWidth, tileHeight, tileMargin, tileSpacing, rows, columns, total).
49+
* Loader.tileset has been removed as it's no longer required, this was as part of the Tilemap system overhaul.
5050
* TilemapLayers are now created via the Tilemap object itself: map.createLayer(x, y, width, height, tileset, layer, group) and no longer via the GameObjectFactory.
5151
* Tilemap.createFromObjects can now turn a bunch of Tiled objects into Sprites in one single call, and copies across all properties as well.
5252
* Tween.onStartCallback and onCompleteCallback have been removed to avoid confusion. You should use the onStart, onLoop and onComplete events instead.
5353

5454

5555
New features:
5656

57-
* Gamepad API support has been added with lots of new examples showing how to use it (thanks Karl Macklin)
58-
* Phaser.Game constructor can now be passed a single object containing game settings + Stage settings, useful for advanced configurations.
57+
* Gamepad API support has been added with lots of new examples (thanks Karl Macklin)
58+
* Phaser.Game constructor can now be passed a single object containing all of your game settings + Stage settings. Useful for advanced configurations.
5959
* The width/height given to Phaser.Game can now be percentages, i.e. "100%" will set the width to the maximum window innerWidth.
6060
* Added a stage.fullScreenScaleMode property to determine scaling when fullscreen (thanks oysterCrusher)
6161
* Added support for margin and spacing around a frame in Loader.spritesheet.
@@ -83,6 +83,9 @@ New Examples:
8383
* Tweens - Example showing how to use the tween events, onStart, onLoop and onComplete.
8484
* Display - Pixi Render Texture. A Phaser conversion of the Pixi.js Render Texture example.
8585
* Input - 5 new examples showing how to use the Gamepad API (thanks Karl Macklin)
86+
* Animation - Group Creation, showing how to create animations across all Group children in one call.
87+
* Particles - Rain by Jens Anders Bakke.
88+
* Particles - Snow by Jens Anders Bakke.
8689

8790

8891
Updates:
@@ -128,7 +131,8 @@ Bug Fixes:
128131
* Canvas.addToDOM is now more robust when applying the overflowHidden style.
129132
* Fixed Pixi.StripShader which should stop the weird TileSprite GPU issues some were reporting (thanks GoodboyDigital)
130133
* Patched desyrel.xml so it doesn't contain any zero width/height characters, as they broke Firefox 25.
131-
134+
* Cache.addSound now implements a locked attribute (thanks haden)
135+
* Sound now checks for CocoonJS during playback to avoid readyState clash (thanks haden)
132136

133137

134138
You can view the Change Log for all previous versions at https://github.com/photonstorm/phaser/changelog.md

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "phaser",
3-
"version": "1.1.3",
3+
"version": "1.1.4",
44
"homepage": "http://phaser.io",
55
"authors": [
66
"photonstorm <rich@photonstorm.com>"

examples/_site/examples.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
"file": "change+texture+on+click.js",
55
"title": "change texture on click"
66
},
7+
{
8+
"file": "group+creation.js",
9+
"title": "group creation"
10+
},
711
{
812
"file": "local+json+object.js",
913
"title": "local json object"
@@ -542,10 +546,18 @@
542546
"file": "no+rotation.js",
543547
"title": "no rotation"
544548
},
549+
{
550+
"file": "rain.js",
551+
"title": "rain"
552+
},
545553
{
546554
"file": "random+sprite.js",
547555
"title": "random sprite"
548556
},
557+
{
558+
"file": "snow.js",
559+
"title": "snow"
560+
},
549561
{
550562
"file": "when+particles+collide.js",
551563
"title": "when particles collide"
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
2+
var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create });
3+
4+
function preload() {
5+
6+
game.load.atlas('seacreatures', 'assets/sprites/seacreatures_json.png', 'assets/sprites/seacreatures_json.json');
7+
game.load.image('undersea', 'assets/pics/undersea.jpg');
8+
game.load.image('coral', 'assets/pics/seabed.png');
9+
10+
}
11+
12+
function create() {
13+
14+
game.add.sprite(0, 0, 'undersea');
15+
16+
// Here we create our group and populate it with 6 sprites
17+
var group = game.add.group();
18+
19+
for (var i = 0; i < 6; i++)
20+
{
21+
// They are evenly spaced out on the X coordinate, with a random Y coordinate
22+
sprite = group.create(120 * i, game.rnd.integerInRange(100, 400), 'seacreatures', 'octopus0000');
23+
}
24+
25+
// These are the frame names for the octopus animation. We use the generateFrames function to help create the array.
26+
var frameNames = Phaser.Animation.generateFrameNames('octopus', 0, 24, '', 4);
27+
28+
// Here is the important part. Group.callAll will call a method that exists on every child in the Group.
29+
// In this case we're saying: child.animations.add('swim', frameNames, 30, true, false)
30+
// The second parameter ('animations') is really important and is the context in which the method is called.
31+
// For animations the context is the Phaser.AnimationManager, which is linked to the child.animations property.
32+
// Everything after the 2nd parameter is just the usual values you'd pass to the animations.add method.
33+
group.callAll('animations.add', 'animations', 'swim', frameNames, 30, true, false);
34+
35+
// Here we just say 'play the swim animation', this time the 'play' method exists on the child itself, so we can set the context to null.
36+
group.callAll('play', null, 'swim');
37+
38+
game.add.sprite(0, 466, 'coral');
39+
40+
}

examples/assets/sprites/rain.png

1.4 KB
Loading
2.85 KB
Loading
21 KB
Loading

examples/groups/for each.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

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

4-
var baseAlphaIncSpeed= 0.006;
4+
var baseAlphaIncSpeed = 0.006;
55

66
function preload() {
77
game.load.spritesheet('item', 'assets/buttons/number-buttons-90x90.png', 90, 90);

examples/particles/rain.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// This example was created by Jens Anders Bakke
2+
3+
var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create });
4+
5+
function preload() {
6+
7+
game.load.spritesheet('rain', 'assets/sprites/rain.png', 17, 17);
8+
9+
}
10+
11+
function create() {
12+
13+
var emitter = game.add.emitter(game.world.centerX, 0, 400);
14+
emitter.width = game.world.width;
15+
// emitter.angle = 30; // uncomment to set an angle for the rain.
16+
17+
emitter.makeParticles('rain');
18+
emitter.maxParticleScale = 0.5;
19+
emitter.minParticleScale = 0.1;
20+
emitter.setYSpeed(300, 500);
21+
emitter.setXSpeed(-5, 5);
22+
emitter.minRotation = 0;
23+
emitter.maxRotation = 0;
24+
25+
emitter.start(false, 1600, 5, 0);
26+
27+
}

examples/particles/snow.js

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
// This example was created by Jens Anders Bakke
2+
3+
var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create });
4+
5+
function preload() {
6+
7+
game.load.spritesheet('snowflakes', 'assets/sprites/snowflakes.png', 17, 17);
8+
game.load.spritesheet('snowflakes_large', 'assets/sprites/snowflakes_large.png', 64, 64);
9+
10+
}
11+
12+
var max = 0;
13+
var front_emitter;
14+
var mid_emitter;
15+
var back_emitter;
16+
var update_interval = 4 * 60;
17+
var i = 0;
18+
19+
function create() {
20+
21+
back_emitter = game.add.emitter(game.world.centerX, -32, 600);
22+
back_emitter.makeParticles('snowflakes', [0, 1, 2, 3, 4, 5]);
23+
back_emitter.maxParticleScale = 0.6;
24+
back_emitter.minParticleScale = 0.2;
25+
back_emitter.setYSpeed(20, 100);
26+
back_emitter.gravity = 0;
27+
back_emitter.width = game.world.width * 1.5;
28+
back_emitter.minRotation = 0;
29+
back_emitter.maxRotation = 40;
30+
31+
32+
mid_emitter = game.add.emitter(game.world.centerX, -32, 250);
33+
mid_emitter.makeParticles('snowflakes', [0, 1, 2, 3, 4, 5]);
34+
mid_emitter.maxParticleScale = 1.2;
35+
mid_emitter.minParticleScale = 0.8;
36+
mid_emitter.setYSpeed(50, 150);
37+
mid_emitter.gravity = 0;
38+
mid_emitter.width = game.world.width * 1.5;
39+
mid_emitter.minRotation = 0;
40+
mid_emitter.maxRotation = 40;
41+
42+
43+
front_emitter = game.add.emitter(game.world.centerX, -32, 50);
44+
front_emitter.makeParticles('snowflakes_large', [0, 1, 2, 3, 4, 5]);
45+
front_emitter.maxParticleScale = 1;
46+
front_emitter.minParticleScale = 0.5;
47+
front_emitter.setYSpeed(100, 200);
48+
front_emitter.gravity = 0;
49+
front_emitter.width = game.world.width * 1.5;
50+
front_emitter.minRotation = 0;
51+
front_emitter.maxRotation = 40;
52+
53+
changeWindDirection();
54+
55+
back_emitter.start(false, 14000, 20);
56+
mid_emitter.start(false, 12000, 40);
57+
front_emitter.start(false, 6000, 1000);
58+
59+
}
60+
61+
function update() {
62+
63+
i++;
64+
65+
if (i === update_interval)
66+
{
67+
changeWindDirection();
68+
update_interval = Math.floor(Math.random() * 20) * 60; // 0 - 20sec @ 60fps
69+
i = 0;
70+
}
71+
72+
}
73+
74+
function changeWindDirection() {
75+
76+
var multi = Math.floor((max + 200) / 4),
77+
frag = (Math.floor(Math.random() * 100) - multi);
78+
max = max + frag;
79+
80+
if (max > 200) max = 150;
81+
if (max < -200) max = -150;
82+
83+
setXSpeed(back_emitter, max);
84+
setXSpeed(mid_emitter, max);
85+
setXSpeed(front_emitter, max);
86+
87+
}
88+
89+
function setXSpeed(emitter, max) {
90+
91+
emitter.setXSpeed(max - 20, max);
92+
emitter.forEachAlive(setParticleXSpeed, this, max);
93+
94+
}
95+
96+
function setParticleXSpeed(particle, max) {
97+
98+
particle.body.velocity.x = max - Math.floor(Math.random() * 30);
99+
100+
}

0 commit comments

Comments
 (0)