Skip to content

Commit 5526a73

Browse files
committed
Warning: This version has a new ArcadePhysics handler in it. Don't upgrade if you need this for live game code, wait until we go to master. Otherwise, this commit contains lots of new physics demos and a new updateMotion and Body class to try and fix, once and for all, the physics issues with applied forces.
1 parent 902ffee commit 5526a73

17 files changed

Lines changed: 1167 additions & 136 deletions

File tree

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,13 @@ New Examples:
8484
* Physics - Bounce accelerator (use the keyboard) by Patrick OReilly.
8585
* Physics - Bounce knock (use the keyboard) by Patrick OReilly.
8686
* Physics - Snake (use the keyboard to control the snake like creature) by Patrick OReilly and Richard Davey.
87+
* Physics - Launcher - Angry Birds style ball launcher demo by Patrick OReilly.
88+
* Physics - Launcher Follow - throw the sprite anywhere in the world by Patrick OReilly.
89+
* Physics - Launcher Follow World - an advanced version of the Launcher Follow example by Patrick OReilly.
8790
* Input - Touch Joystick example showing how to use the clay.io virtual game controller (thanks gabehollombe)
8891
* Games - Matching Pairs by Patrick OReilly.
92+
* Games - Simon Says by Patrick OReilly.
93+
* Games - Wabbits by Patrick OReilly.
8994
* Tweens - Example showing how to use the tween events, onStart, onLoop and onComplete.
9095
* Display - Pixi Render Texture. A Phaser conversion of the Pixi.js Render Texture example.
9196
* Input - 5 new examples showing how to use the Gamepad API (thanks Karl Macklin)
@@ -128,7 +133,7 @@ Bug Fixes:
128133
* Fixed Group.scale so you can now scale a Group directly.
129134
* Removed World.scale as it was preventing Group.scale from working - you can still scale the world, but you'll need to factor in Input changes yourself.
130135
* Moved 'dirty' flag for Tilemap to a per-layer flag. Fixes #242
131-
* Group.length now returns the number of children in the Group regardless of their exists/alive state, or 0 if the Group is has no children.
136+
* Group.length now returns the number of children in the Group regardless of their exists/alive state, or 0 if the Group has no children.
132137
* Switch Camera.setBoundsToWorld to match world.bounds instead of world (thanks cocoademon)
133138
* Fixed an issue where passing null as the Group parent wouldn't set it to game.world as it should have (thanks tito100)
134139
* Fixed Pixi bug (#425) incorrect width property for multi-line BitmapText (thanks jcd-as)
@@ -143,6 +148,7 @@ Bug Fixes:
143148
* Buttons now clear previously set frames correctly if you call setFrames.
144149
* Sounds will now loop correctly if they are paused and resumed (thanks haden)
145150
* InputHandler.checkBoundsRect and checkBoundsSprite now take into account if the Sprite is fixedToCamera or not.
151+
* Removed the frame property from TileSprites as it cannot use them, it tiles the whole image only, not just a section of it.
146152

147153

148154
You can view the Change Log for all previous versions at https://github.com/photonstorm/phaser/changelog.md
@@ -343,3 +349,5 @@ Phaser is released under the [MIT License](http://opensource.org/licenses/MIT).
343349

344350
[1]: https://github.com/photonstorm/phaser/issues
345351
[phaser]: https://github.com/photonstorm/phaser
352+
353+
[![Analytics](https://ga-beacon.appspot.com/UA-44006568-2/phaser/index)](https://github.com/igrigorik/ga-beacon)

examples/_site/examples.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,13 +254,21 @@
254254
"file": "matching+pairs.js",
255255
"title": "matching pairs"
256256
},
257+
{
258+
"file": "simon.js",
259+
"title": "simon"
260+
},
257261
{
258262
"file": "starstruck.js",
259263
"title": "starstruck"
260264
},
261265
{
262266
"file": "tanks.js",
263267
"title": "tanks"
268+
},
269+
{
270+
"file": "wabbits.js",
271+
"title": "wabbits"
264272
}
265273
],
266274
"geometry": [
@@ -608,6 +616,18 @@
608616
"file": "framerate+independence.js",
609617
"title": "framerate independence"
610618
},
619+
{
620+
"file": "launcher+follow+world.js",
621+
"title": "launcher follow world"
622+
},
623+
{
624+
"file": "launcher+follow.js",
625+
"title": "launcher follow"
626+
},
627+
{
628+
"file": "launcher.js",
629+
"title": "launcher"
630+
},
611631
{
612632
"file": "mass+velocity+test.js",
613633
"title": "mass velocity test"

examples/assets/sprites/block.png

18.7 KB
Loading
710 Bytes
Loading

examples/assets/tests/fusia.png

2.2 KB
Loading

examples/games/simon.js

Lines changed: 214 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,214 @@
1+
// mods by Patrick OReilly
2+
// Twitter: @pato_reilly Web: http://patricko.byethost9.com
3+
4+
var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update: update, render: render });
5+
6+
function preload() {
7+
8+
game.load.spritesheet('item', 'assets/buttons/number-buttons.png', 160, 160);
9+
}
10+
11+
var simon;
12+
var N = 1;
13+
var userCount = 0;
14+
var currentCount = 0;
15+
var sequenceCount = 16;
16+
var sequenceList = [];
17+
var simonSez = false;
18+
var timeCheck;
19+
var litSquare;
20+
var winner;
21+
var loser;
22+
var intro;
23+
24+
function create() {
25+
26+
simon = game.add.group();
27+
var item;
28+
29+
for (var i = 0; i < 3; i++)
30+
{
31+
item = simon.create(150 + 168 * i, 150, 'item', i);
32+
// Enable input.
33+
item.input.start(0, true);
34+
item.events.onInputDown.add(select);
35+
item.events.onInputUp.add(release);
36+
item.events.onInputOut.add(moveOff);
37+
simon.getAt(i).alpha = 0;
38+
}
39+
40+
for (var i = 0; i < 3; i++)
41+
{
42+
item = simon.create(150 + 168 * i, 318, 'item', i + 3);
43+
// Enable input.
44+
item.input.start(0, true);
45+
item.events.onInputDown.add(select);
46+
item.events.onInputUp.add(release);
47+
item.events.onInputOut.add(moveOff);
48+
simon.getAt(i + 3).alpha = 0;
49+
}
50+
51+
introTween();
52+
setUp();
53+
setTimeout(function(){simonSequence(); intro = false;}, 5000);
54+
55+
}
56+
57+
function restart() {
58+
59+
N = 1;
60+
userCount = 0;
61+
currentCount = 0;
62+
sequenceList = [];
63+
winner = false;
64+
loser = false;
65+
introTween();
66+
setUp();
67+
setTimeout(function(){simonSequence(); intro=false;}, 5000);
68+
69+
}
70+
71+
function introTween() {
72+
73+
intro = true;
74+
75+
for (var i = 0; i < 6; i++)
76+
{
77+
game.add.tween(simon.getAt(i)).to( { alpha: 1 }, 500, Phaser.Easing.Linear.None, true, 0, 4, true).to( { alpha: .25 }, 500, Phaser.Easing.Linear.None, true);
78+
}
79+
80+
}
81+
82+
function update() {
83+
84+
if (simonSez)
85+
{
86+
if (game.time.now - timeCheck >700-N*40)
87+
{
88+
simon.getAt(litSquare).alpha = .25;
89+
game.paused = true;
90+
91+
setTimeout(function()
92+
{
93+
if ( currentCount< N)
94+
{
95+
game.paused = false;
96+
simonSequence();
97+
}
98+
else
99+
{
100+
simonSez = false;
101+
game.paused = false;
102+
}
103+
}, 400 - N * 20);
104+
}
105+
}
106+
}
107+
108+
function playerSequence(selected) {
109+
110+
correctSquare = sequenceList[userCount];
111+
userCount++;
112+
thisSquare = simon.getIndex(selected);
113+
114+
if (thisSquare == correctSquare)
115+
{
116+
if (userCount == N)
117+
{
118+
if (N == sequenceCount)
119+
{
120+
winner = true;
121+
setTimeout(function(){restart();}, 3000);
122+
}
123+
else
124+
{
125+
userCount = 0;
126+
currentCount = 0;
127+
N++;
128+
simonSez = true;
129+
}
130+
}
131+
}
132+
else
133+
{
134+
loser = true;
135+
setTimeout(function(){restart();}, 3000);
136+
}
137+
138+
}
139+
140+
function simonSequence () {
141+
142+
simonSez = true;
143+
litSquare = sequenceList[currentCount];
144+
simon.getAt(litSquare).alpha = 1;
145+
timeCheck = game.time.now;
146+
currentCount++;
147+
148+
}
149+
150+
function setUp() {
151+
152+
for (var i = 0; i < sequenceCount; i++)
153+
{
154+
thisSquare = game.rnd.integerInRange(0,6);
155+
sequenceList.push(thisSquare);
156+
}
157+
158+
}
159+
160+
function select(item, pointer) {
161+
162+
if (!simonSez && !intro && !loser && !winner)
163+
{
164+
item.alpha = 1;
165+
}
166+
167+
}
168+
169+
function release(item, pointer) {
170+
171+
if (!simonSez && !intro && !loser && !winner)
172+
{
173+
item.alpha = .25;
174+
playerSequence(item);
175+
}
176+
}
177+
178+
function moveOff(item, pointer) {
179+
180+
if (!simonSez && !intro && !loser && !winner)
181+
{
182+
item.alpha = .25;
183+
}
184+
185+
}
186+
187+
function render() {
188+
189+
if (!intro)
190+
{
191+
if (simonSez)
192+
{
193+
game.debug.renderText('Simon Sez', 360, 96, 'rgb(255,0,0)');
194+
}
195+
else
196+
{
197+
game.debug.renderText('Your Turn', 360, 96, 'rgb(0,255,0)');
198+
}
199+
}
200+
else
201+
{
202+
game.debug.renderText('Get Ready', 360, 96, 'rgb(0,0,255)');
203+
}
204+
205+
if (winner)
206+
{
207+
game.debug.renderText('You Win!', 360, 32, 'rgb(0,0,255)');
208+
}
209+
else if (loser)
210+
{
211+
game.debug.renderText('You Lose!', 360, 32, 'rgb(0,0,255)');
212+
}
213+
214+
}

0 commit comments

Comments
 (0)