Skip to content

Commit 7290204

Browse files
committed
New Game Objects structure in place, and starting to take shape.
Moved BitmapData and RenderTexture into the textures folder for now. All Game Objects now have their own sub-folder, with their Factory and renderer functions alongside them, plus any other files they need. New Factory class added. Currently hooked into `game.factory` for testing, but will swap to `game.add` when complete.
1 parent 85c580a commit 7290204

48 files changed

Lines changed: 1175 additions & 588 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

build/config.php

Lines changed: 70 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@
8383
<script src="$path/src/core/Filter.js"></script>
8484
<script src="$path/src/core/Plugin.js"></script>
8585
<script src="$path/src/core/PluginManager.js"></script>
86-
<script src="$path/src/core/Stage.js"></script>
8786
<script src="$path/src/core/Group.js"></script>
8887
<script src="$path/src/core/World.js"></script>
8988
<script src="$path/src/core/FlexGrid.js"></script>
@@ -109,7 +108,6 @@
109108
<script src="$path/src/textures/parsers/JSONHash.js"></script>
110109
<script src="$path/src/textures/parsers/SpriteSheet.js"></script>
111110
112-
113111
EOL;
114112

115113
if ($modules['keyboard'])
@@ -133,6 +131,22 @@
133131
}
134132

135133
echo <<<EOL
134+
135+
<script src="$path/src/renderer/canvas/CanvasRenderer.js"></script>
136+
137+
<script src="$path/src/renderer/webgl/WebGLRenderer.js"></script>
138+
<script src="$path/src/renderer/webgl/BatchManager.js"></script>
139+
<script src="$path/src/renderer/webgl/FilterManager.js"></script>
140+
<script src="$path/src/renderer/webgl/FilterTexture.js"></script>
141+
<script src="$path/src/renderer/webgl/ShaderManager.js"></script>
142+
<script src="$path/src/renderer/webgl/StencilManager.js"></script>
143+
<script src="$path/src/renderer/webgl/shaders/ComplexPrimitiveGraphics.js"></script>
144+
<script src="$path/src/renderer/webgl/shaders/PrimitiveGraphics.js"></script>
145+
<script src="$path/src/renderer/webgl/shaders/Sprite.js"></script>
146+
<script src="$path/src/renderer/webgl/shaders/SpriteBatch.js"></script>
147+
<script src="$path/src/renderer/webgl/shaders/Strip.js"></script>
148+
149+
136150
<script src="$path/src/gameobjects/components/Component.js"></script>
137151
<script src="$path/src/gameobjects/components/Angle.js"></script>
138152
<script src="$path/src/gameobjects/components/Animation.js"></script>
@@ -159,11 +173,38 @@
159173
160174
<script src="$path/src/gameobjects/GameObjectFactory.js"></script>
161175
<script src="$path/src/gameobjects/GameObjectCreator.js"></script>
162-
<script src="$path/src/gameobjects/Sprite.js"></script>
163-
<script src="$path/src/gameobjects/Image.js"></script>
164-
<script src="$path/src/gameobjects/Button.js"></script>
165-
<script src="$path/src/gameobjects/SpriteBatch.js"></script>
166-
<script src="$path/src/gameobjects/Particle.js"></script>
176+
177+
<script src="$path/src/gameobjects/Factory.js"></script>
178+
179+
<script src="$path/src/gameobjects/stage/Stage.js"></script>
180+
<script src="$path/src/gameobjects/stage/StageCanvasRenderer.js"></script>
181+
<script src="$path/src/gameobjects/stage/StageWebGLRenderer.js"></script>
182+
183+
<script src="$path/src/gameobjects/sprite/Sprite.js"></script>
184+
<script src="$path/src/gameobjects/sprite/SpriteFactory.js"></script>
185+
<script src="$path/src/gameobjects/sprite/SpriteCanvasRenderer.js"></script>
186+
<script src="$path/src/gameobjects/sprite/SpriteWebGLRenderer.js"></script>
187+
188+
<script src="$path/src/gameobjects/image/Image.js"></script>
189+
<script src="$path/src/gameobjects/image/ImageFactory.js"></script>
190+
<script src="$path/src/gameobjects/image/ImageCanvasRenderer.js"></script>
191+
<script src="$path/src/gameobjects/image/ImageWebGLRenderer.js"></script>
192+
193+
<script src="$path/src/gameobjects/button/Button.js"></script>
194+
195+
<script src="$path/src/gameobjects/spritebatch/SpriteBatch.js"></script>
196+
<script src="$path/src/gameobjects/spritebatch/SpriteBatchFactory.js"></script>
197+
<script src="$path/src/gameobjects/spritebatch/SpriteBatchCanvasRenderer.js"></script>
198+
<script src="$path/src/gameobjects/spritebatch/SpriteBatchWebGLRenderer.js"></script>
199+
200+
<script src="$path/src/gameobjects/particle/Particle.js"></script>
201+
202+
<script src="$path/src/gameobjects/container/Canvas.js"></script>
203+
<script src="$path/src/gameobjects/container/WebGL.js"></script>
204+
205+
206+
207+
167208
168209
<script src="$path/src/plugins/weapon/WeaponPlugin.js"></script>
169210
<script src="$path/src/plugins/weapon/Bullet.js"></script>
@@ -174,35 +215,14 @@
174215
<script src="$path/src/plugins/path/PathPoint.js"></script>
175216
<script src="$path/src/plugins/path/EventTarget.js"></script>
176217
177-
<script src="$path/src/renderer/canvas/CanvasRenderer.js"></script>
178-
<script src="$path/src/renderer/canvas/gameobjects/Container.js"></script>
179-
<script src="$path/src/renderer/canvas/gameobjects/Sprite.js"></script>
180-
<script src="$path/src/renderer/canvas/gameobjects/SpriteBatch.js"></script>
181-
<script src="$path/src/renderer/canvas/gameobjects/Stage.js"></script>
182-
183-
<script src="$path/src/renderer/webgl/WebGLRenderer.js"></script>
184-
<script src="$path/src/renderer/webgl/BatchManager.js"></script>
185-
<script src="$path/src/renderer/webgl/FilterManager.js"></script>
186-
<script src="$path/src/renderer/webgl/FilterTexture.js"></script>
187-
<script src="$path/src/renderer/webgl/ShaderManager.js"></script>
188-
<script src="$path/src/renderer/webgl/StencilManager.js"></script>
189-
<script src="$path/src/renderer/webgl/shaders/ComplexPrimitiveGraphics.js"></script>
190-
<script src="$path/src/renderer/webgl/shaders/PrimitiveGraphics.js"></script>
191-
<script src="$path/src/renderer/webgl/shaders/Sprite.js"></script>
192-
<script src="$path/src/renderer/webgl/shaders/SpriteBatch.js"></script>
193-
<script src="$path/src/renderer/webgl/shaders/Strip.js"></script>
194-
<script src="$path/src/renderer/webgl/gameobjects/Container.js"></script>
195-
<script src="$path/src/renderer/webgl/gameobjects/Sprite.js"></script>
196-
<script src="$path/src/renderer/webgl/gameobjects/SpriteBatch.js"></script>
197-
<script src="$path/src/renderer/webgl/gameobjects/Stage.js"></script>
198218
199219
200220
EOL;
201221

202222
if ($modules['rope'])
203223
{
204224
echo <<<EOL
205-
<script src="$path/src/gameobjects/Rope.js"></script>
225+
<script src="$path/src/gameobjects/rope/Rope.js"></script>
206226
207227
208228
EOL;
@@ -211,9 +231,10 @@
211231
if ($modules['tilesprite'])
212232
{
213233
echo <<<EOL
214-
<script src="$path/src/gameobjects/TileSprite.js"></script>
215-
<script src="$path/src/renderer/canvas/gameobjects/TileSprite.js"></script>
216-
<script src="$path/src/renderer/webgl/gameobjects/TileSprite.js"></script>
234+
<script src="$path/src/gameobjects/tilesprite/TileSprite.js"></script>
235+
<script src="$path/src/gameobjects/tilesprite/TileSpriteFactory.js"></script>
236+
<script src="$path/src/gameobjects/tilesprite/TileSpriteCanvasRenderer.js"></script>
237+
<script src="$path/src/gameobjects/tilesprite/TileSpriteWebGLRenderer.js"></script>
217238
218239
219240
EOL;
@@ -222,7 +243,8 @@
222243
if ($modules['creature'])
223244
{
224245
echo <<<EOL
225-
<script src="$path/src/gameobjects/Creature.js"></script>
246+
<script src="$path/src/gameobjects/creature/Creature.js"></script>
247+
<script src="$path/src/gameobjects/creature/CreatureFactory.js"></script>
226248
227249
228250
EOL;
@@ -231,7 +253,7 @@
231253
if ($modules['bitmapdata'])
232254
{
233255
echo <<<EOL
234-
<script src="$path/src/gameobjects/BitmapData.js"></script>
256+
<script src="$path/src/textures/BitmapData.js"></script>
235257
236258
237259
EOL;
@@ -240,11 +262,12 @@
240262
if ($modules['graphics'])
241263
{
242264
echo <<<EOL
243-
<script src="$path/src/gameobjects/GraphicsData.js"></script>
244-
<script src="$path/src/gameobjects/Graphics.js"></script>
245-
<script src="$path/src/renderer/canvas/gameobjects/Graphics.js"></script>
246-
<script src="$path/src/renderer/webgl/gameobjects/Graphics.js"></script>
247-
<script src="$path/src/renderer/webgl/gameobjects/GraphicsData.js"></script>
265+
<script src="$path/src/gameobjects/graphics/GraphicsData.js"></script>
266+
<script src="$path/src/gameobjects/graphics/Graphics.js"></script>
267+
<script src="$path/src/gameobjects/graphics/GraphicsFactory.js"></script>
268+
<script src="$path/src/gameobjects/graphics/GraphicsCanvasRenderer.js"></script>
269+
<script src="$path/src/gameobjects/graphics/GraphicsWebGLRenderer.js"></script>
270+
<script src="$path/src/gameobjects/graphics/GraphicsWebGLData.js"></script>
248271
249272
250273
EOL;
@@ -253,7 +276,7 @@
253276
if ($modules['rendertexture'])
254277
{
255278
echo <<<EOL
256-
<script src="$path/src/gameobjects/RenderTexture.js"></script>
279+
<script src="$path/src/textures/RenderTexture.js"></script>
257280
258281
259282
EOL;
@@ -262,9 +285,10 @@
262285
if ($modules['text'])
263286
{
264287
echo <<<EOL
265-
<script src="$path/src/gameobjects/Text.js"></script>
266-
<script src="$path/src/renderer/canvas/gameobjects/Text.js"></script>
267-
<script src="$path/src/renderer/webgl/gameobjects/Text.js"></script>
288+
<script src="$path/src/gameobjects/text/Text.js"></script>
289+
<script src="$path/src/gameobjects/text/TextFactory.js"></script>
290+
<script src="$path/src/gameobjects/text/TextCanvasRenderer.js"></script>
291+
<script src="$path/src/gameobjects/text/TextWebGLRenderer.js"></script>
268292
269293
270294
EOL;
@@ -273,7 +297,7 @@
273297
if ($modules['bitmaptext'])
274298
{
275299
echo <<<EOL
276-
<script src="$path/src/gameobjects/BitmapText.js"></script>
300+
<script src="$path/src/gameobjects/bitmaptext/BitmapText.js"></script>
277301
278302
279303
EOL;
@@ -282,7 +306,7 @@
282306
if ($modules['retrofont'] && $modules['rendertexture'])
283307
{
284308
echo <<<EOL
285-
<script src="$path/src/gameobjects/RetroFont.js"></script>
309+
<script src="$path/src/gameobjects/retrofont/RetroFont.js"></script>
286310
287311
288312
EOL;
@@ -291,7 +315,7 @@
291315
if ($modules['video'])
292316
{
293317
echo <<<EOL
294-
<script src="$path/src/gameobjects/Video.js"></script>
318+
<script src="$path/src/gameobjects/video/Video.js"></script>
295319
296320
297321
EOL;

src/Phaser.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -542,9 +542,9 @@ var Phaser = Phaser || { // jshint ignore:line
542542
NEAREST: 1
543543
},
544544

545-
Renderer: {
545+
GameObjects: {},
546546

547-
},
547+
Renderer: {},
548548

549549
tempMatrix: null
550550

src/core/Game.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,9 @@ Phaser.Game = function (width, height, renderer, parent, state, transparent, ant
216216
*/
217217
this.add = null;
218218

219+
// TODO: Testing new Game Objects Factory
220+
this.factory = null;
221+
219222
/**
220223
* @property {Phaser.GameObjectCreator} make - Reference to the GameObject Creator.
221224
*/
@@ -635,6 +638,10 @@ Phaser.Game.prototype = {
635638
this.sound.boot();
636639
this.state.boot();
637640

641+
this.factory = new Phaser.GameObjects.Factory(this);
642+
643+
this.factory.boot();
644+
638645
if (this.config['enableDebug'])
639646
{
640647
this.debug = new Phaser.Utils.Debug(this);

src/core/Group.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,9 @@ Phaser.Group = function (game, parent, name, addToStage, enableBody, physicsBody
125125
* when a new object is created it is passed the following parameters to its constructor: `(game, x, y, key, frame)`.
126126
*
127127
* @property {object} classType
128-
* @default {@link Phaser.Sprite}
128+
* @default {@link Phaser.GameObjects.Sprite}
129129
*/
130-
this.classType = Phaser.Sprite;
130+
this.classType = Phaser.GameObjects.Sprite;
131131

132132
/**
133133
* The current display object that the group cursor is pointing to, if any. (Can be set manually.)

0 commit comments

Comments
 (0)