Skip to content

Commit f260108

Browse files
committed
Tidying up source code for release. Also refactored World to use a Group instance, rather tha duplicate functions.
1 parent 87858d6 commit f260108

25 files changed

Lines changed: 276 additions & 485 deletions

examples/fullscreen.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ function create() {
3131

3232
game.stage.backgroundColor = '#e3ed49';
3333

34+
// Testing iOS7 lack of fullscreen. Damnit.
35+
document.documentElement['style'].minHeight = '2000px';
36+
window.scrollTo(0, document.body.scrollHeight);
37+
3438
game.input.onDown.add(gofull, this);
3539

3640
}
@@ -40,6 +44,13 @@ function gofull() {
4044
}
4145

4246
function update() {
47+
48+
if (document.getElementsByTagName('body')[0].scrollTop > 1000)
49+
{
50+
game.stage.backgroundColor = '#87ff55';
51+
window.scrollTo(0, 0);
52+
}
53+
4354
}
4455

4556
function render() {

examples/group1.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ function create() {
3838

3939
for (var i = 0; i < 10; i++)
4040
{
41-
var x = (i * 64);
42-
s = g.create(x, 0, 'diamond');
41+
var x = 50 + (i * 64);
42+
s = g.create(x, 100, 'diamond');
4343
s.name = 'd' + i;
4444
s.anchor.setTo(0.5, 0.5);
4545
}
@@ -68,8 +68,8 @@ function setAlpha (sprite) {
6868

6969
function update() {
7070

71-
// g.addAll('angle', 10);
72-
g.angle++;
71+
g.addAll('angle', 10);
72+
// g.angle++;
7373

7474
}
7575

examples/sound1.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ function preload() {
3030
function create() {
3131

3232
game.stage.backgroundColor = '#182d3b';
33+
game.input.touch.preventDefault = false;
3334

3435
music = game.add.audio('boden');
3536
music.play();

src/animation/Animation.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,7 @@ Object.defineProperty(Phaser.Animation.prototype, "frameTotal", {
168168

169169
get: function () {
170170
return this._frames.length;
171-
},
172-
173-
enumerable: true,
174-
configurable: true
171+
}
175172

176173
});
177174

@@ -200,9 +197,6 @@ Object.defineProperty(Phaser.Animation.prototype, "frame", {
200197
this._parent.setTexture(PIXI.TextureCache[this.currentFrame.uuid]);
201198
}
202199

203-
},
204-
205-
enumerable: true,
206-
configurable: true
200+
}
207201

208202
});

src/animation/AnimationManager.js

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -217,10 +217,8 @@ Object.defineProperty(Phaser.AnimationManager.prototype, "frameData", {
217217

218218
get: function () {
219219
return this._frameData;
220-
},
220+
}
221221

222-
enumerable: true,
223-
configurable: true
224222
});
225223

226224
Object.defineProperty(Phaser.AnimationManager.prototype, "frameTotal", {
@@ -235,10 +233,8 @@ Object.defineProperty(Phaser.AnimationManager.prototype, "frameTotal", {
235233
{
236234
return -1;
237235
}
238-
},
236+
}
239237

240-
enumerable: true,
241-
configurable: true
242238
});
243239

244240
Object.defineProperty(Phaser.AnimationManager.prototype, "frame", {
@@ -266,10 +262,8 @@ Object.defineProperty(Phaser.AnimationManager.prototype, "frame", {
266262
this.sprite.setTexture(PIXI.TextureCache[this.currentFrame.uuid]);
267263
}
268264

269-
},
265+
}
270266

271-
enumerable: true,
272-
configurable: true
273267
});
274268

275269
Object.defineProperty(Phaser.AnimationManager.prototype, "frameName", {
@@ -296,8 +290,6 @@ Object.defineProperty(Phaser.AnimationManager.prototype, "frameName", {
296290
{
297291
console.warn("Cannot set frameName: " + value);
298292
}
299-
},
293+
}
300294

301-
enumerable: true,
302-
configurable: true
303295
});

src/animation/FrameData.js

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ Phaser.Animation.FrameData.prototype = {
9292
}
9393

9494
return true;
95+
9596
},
9697

9798
/**
@@ -105,7 +106,8 @@ Phaser.Animation.FrameData.prototype = {
105106

106107
if (typeof output === "undefined") { output = []; }
107108

108-
for (var i = start; i <= end; i++) {
109+
for (var i = start; i <= end; i++)
110+
{
109111
output.push(this._frames[i]);
110112
}
111113

@@ -122,7 +124,8 @@ Phaser.Animation.FrameData.prototype = {
122124

123125
if (typeof output === "undefined") { output = []; }
124126

125-
for (var i = 0; i < this._frames.length; i++) {
127+
for (var i = 0; i < this._frames.length; i++)
128+
{
126129
output.push(i);
127130
}
128131

@@ -139,12 +142,12 @@ Phaser.Animation.FrameData.prototype = {
139142

140143
var output = [];
141144

142-
for (var i = 0; i < input.length; i++) {
143-
144-
if (this.getFrameByName(input[i])) {
145+
for (var i = 0; i < input.length; i++)
146+
{
147+
if (this.getFrameByName(input[i]))
148+
{
145149
output.push(this.getFrameByName(input[i]).index);
146150
}
147-
148151
}
149152

150153
return output;
@@ -168,7 +171,8 @@ Phaser.Animation.FrameData.prototype = {
168171

169172
var output = [];
170173

171-
for (var i = 0; i < range.length; i++) {
174+
for (var i = 0; i < range.length; i++)
175+
{
172176
output.push(this._frames[i]);
173177
}
174178

@@ -178,10 +182,10 @@ Phaser.Animation.FrameData.prototype = {
178182
};
179183

180184
Object.defineProperty(Phaser.Animation.FrameData.prototype, "total", {
185+
181186
get: function () {
182187
return this._frames.length;
183-
},
184-
enumerable: true,
185-
configurable: true
188+
}
189+
186190
});
187191

src/core/Camera.js

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -207,10 +207,8 @@ Object.defineProperty(Phaser.Camera.prototype, "x", {
207207

208208
set: function (value) {
209209
this.view.x = value;
210-
},
210+
}
211211

212-
enumerable: true,
213-
configurable: true
214212
});
215213

216214
Object.defineProperty(Phaser.Camera.prototype, "y", {
@@ -221,10 +219,8 @@ Object.defineProperty(Phaser.Camera.prototype, "y", {
221219

222220
set: function (value) {
223221
this.view.y = value;
224-
},
222+
}
225223

226-
enumerable: true,
227-
configurable: true
228224
});
229225

230226
Object.defineProperty(Phaser.Camera.prototype, "width", {
@@ -235,10 +231,8 @@ Object.defineProperty(Phaser.Camera.prototype, "width", {
235231

236232
set: function (value) {
237233
this.view.width = value;
238-
},
234+
}
239235

240-
enumerable: true,
241-
configurable: true
242236
});
243237

244238
Object.defineProperty(Phaser.Camera.prototype, "height", {
@@ -249,8 +243,6 @@ Object.defineProperty(Phaser.Camera.prototype, "height", {
249243

250244
set: function (value) {
251245
this.view.height = value;
252-
},
246+
}
253247

254-
enumerable: true,
255-
configurable: true
256248
});

src/core/Game.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -447,9 +447,7 @@ Object.defineProperty(Phaser.Game.prototype, "paused", {
447447
}
448448
}
449449

450-
},
450+
}
451451

452-
enumerable: true,
453-
configurable: true
454452
});
455453

src/core/Group.js

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,40 @@
1-
Phaser.Group = function (game, parent, name) {
1+
Phaser.Group = function (game, parent, name, useStage) {
22

33
parent = parent || null;
44

5+
if (typeof useStage == 'undefined')
6+
{
7+
useStage = false;
8+
}
9+
510
this.game = game;
611
this.name = name || 'group';
712

8-
this._container = new PIXI.DisplayObjectContainer();
9-
this._container.name = this.name;
10-
11-
if (parent)
13+
if (useStage)
14+
{
15+
this._container = this.game.stage._stage;
16+
}
17+
else
1218
{
13-
if (parent instanceof Phaser.Group)
19+
this._container = new PIXI.DisplayObjectContainer();
20+
this._container.name = this.name;
21+
22+
if (parent)
1423
{
15-
parent._container.addChild(this._container);
24+
if (parent instanceof Phaser.Group)
25+
{
26+
parent._container.addChild(this._container);
27+
}
28+
else
29+
{
30+
parent.addChild(this._container);
31+
}
1632
}
1733
else
1834
{
19-
parent.addChild(this._container);
35+
this.game.stage._stage.addChild(this._container);
2036
}
2137
}
22-
else
23-
{
24-
this.game.world.add(this._container);
25-
}
2638

2739
this.exists = true;
2840

@@ -274,13 +286,13 @@ Phaser.Group.prototype = {
274286
sortHandler: function (obj1, obj2) {
275287

276288
/*
277-
if(!obj1 || !obj2) {
289+
if (!obj1 || !obj2) {
278290
//console.log('null objects in sort', obj1, obj2);
279291
return 0;
280292
}
281-
if(obj1[this._sortIndex] < obj2[this._sortIndex]) {
293+
if (obj1[this._sortIndex] < obj2[this._sortIndex]) {
282294
return this._sortOrder;
283-
} else if(obj1[this._sortIndex] > obj2[this._sortIndex]) {
295+
} else if (obj1[this._sortIndex] > obj2[this._sortIndex]) {
284296
return -this._sortOrder;
285297
}
286298
return 0;
@@ -788,10 +800,8 @@ Object.defineProperty(Phaser.Group.prototype, "x", {
788800

789801
set: function (value) {
790802
this._container.position.x = value;
791-
},
803+
}
792804

793-
enumerable: true,
794-
configurable: true
795805
});
796806

797807
Object.defineProperty(Phaser.Group.prototype, "y", {
@@ -802,10 +812,8 @@ Object.defineProperty(Phaser.Group.prototype, "y", {
802812

803813
set: function (value) {
804814
this._container.position.y = value;
805-
},
815+
}
806816

807-
enumerable: true,
808-
configurable: true
809817
});
810818

811819
Object.defineProperty(Phaser.Group.prototype, "angle", {
@@ -816,10 +824,8 @@ Object.defineProperty(Phaser.Group.prototype, "angle", {
816824

817825
set: function(value) {
818826
this._container.rotation = Phaser.Math.degToRad(value);
819-
},
827+
}
820828

821-
enumerable: true,
822-
configurable: true
823829
});
824830

825831
Object.defineProperty(Phaser.Group.prototype, "rotation", {
@@ -830,10 +836,8 @@ Object.defineProperty(Phaser.Group.prototype, "rotation", {
830836

831837
set: function (value) {
832838
this._container.rotation = value;
833-
},
839+
}
834840

835-
enumerable: true,
836-
configurable: true
837841
});
838842

839843
Object.defineProperty(Phaser.Group.prototype, "visible", {
@@ -844,8 +848,6 @@ Object.defineProperty(Phaser.Group.prototype, "visible", {
844848

845849
set: function (value) {
846850
this._container.visible = value;
847-
},
851+
}
848852

849-
enumerable: true,
850-
configurable: true
851853
});

0 commit comments

Comments
 (0)