diff --git a/blank_game_multiplayer/client.js b/blank_game_multiplayer/client.js index a878e44ad..1694f9c82 100644 --- a/blank_game_multiplayer/client.js +++ b/blank_game_multiplayer/client.js @@ -41,7 +41,7 @@ var Client = IgeClass.extend({ }); // Load the base scene data - ige.addGraph('BaseScene'); + ige.addGraph('IgeBaseScene'); }); } }); diff --git a/blank_game_multiplayer/gameClasses/ExampleEntity.js b/blank_game_multiplayer/gameClasses/ExampleEntity.js new file mode 100644 index 000000000..73f88f587 --- /dev/null +++ b/blank_game_multiplayer/gameClasses/ExampleEntity.js @@ -0,0 +1,7 @@ +var ExampleEntity = IgeEntity.extend({ + classId: 'ExampleEntity', + + init: function () { + IgeEntity.prototype.init.call(this); + } +}); \ No newline at end of file diff --git a/blank_game_multiplayer/levels/ExampleGraph.js b/blank_game_multiplayer/levels/ExampleGraph.js new file mode 100644 index 000000000..27fea3d6e --- /dev/null +++ b/blank_game_multiplayer/levels/ExampleGraph.js @@ -0,0 +1,11 @@ +var ExampleGraph = IgeSceneGraph.extend({ + classId: 'ExampleGraph', + + addGraph: function () { + + }, + + removeGraph: function () { + + } +}); \ No newline at end of file diff --git a/blank_game_multiplayer/server.js b/blank_game_multiplayer/server.js index e96211050..41a9e10ce 100644 --- a/blank_game_multiplayer/server.js +++ b/blank_game_multiplayer/server.js @@ -25,7 +25,7 @@ var Server = IgeClass.extend({ ige.network.acceptConnections(true); // Load the base scene data - ige.addGraph('BaseScene'); + ige.addGraph('IgeBaseScene'); } }); }); diff --git a/engine/CoreConfig.js b/engine/CoreConfig.js index 28d42b034..6ed52ceff 100644 --- a/engine/CoreConfig.js +++ b/engine/CoreConfig.js @@ -58,6 +58,7 @@ var igeCoreConfig = { ['csap', 'IgeUiStyleExtension', 'extensions/IgeUiStyleExtension.js'], /* Main Engine Classes */ ['csap', 'IgeSceneGraph', 'core/IgeSceneGraph.js'], + ['csap', 'IgeBaseScene', 'core/IgeBaseScene.js'], ['csap', 'IgeDummyCanvas', 'core/IgeDummyCanvas.js'], ['csap', 'IgeDummyContext', 'core/IgeDummyContext.js'], ['csap', 'IgePathNode', 'core/IgePathNode.js'], diff --git a/engine/core/IgeBaseScene.js b/engine/core/IgeBaseScene.js new file mode 100644 index 000000000..74a581381 --- /dev/null +++ b/engine/core/IgeBaseScene.js @@ -0,0 +1,47 @@ +/** + * When loaded into memory using ige.addGraph('IgeBaseScene') will create + * the scene "baseScene" and the viewport "vp1" that are used in almost all + * examples and can be used as the base for your scenegraph as well. + */ +var IgeBaseScene = IgeSceneGraph.extend({ + classId: 'IgeBaseScene', + + init: function () {}, + + /** + * Called when loading the graph data via ige.addGraph(). + * @param options + */ + addGraph: function (options) { + // Clear existing graph data + if (ige.$('baseScene')) { + this.destroyGraph(); + } + + // Create the scene + var baseScene = new IgeScene2d() + .id('baseScene'); + + // Create the main viewport to look at "baseScene" + new IgeViewport() + .id('vp1') + .autoSize(true) + .scene(baseScene) + .drawBounds(false) + .mount(ige); + }, + + /** + * The method called when the graph items are to be removed from the + * active graph. + */ + removeGraph: function () { + // Destroy the viewport + ige.$('vp1').destroy(); + + // Destroy the baseScene + ige.$('baseScene').destroy(); + } +}); + +if (typeof(module) !== 'undefined' && typeof(module.exports) !== 'undefined') { module.exports = IgeBaseScene; } \ No newline at end of file diff --git a/examples/0.0-load-graph/client.js b/examples/0.0-load-graph/client.js index 71c9283b4..17e5f767e 100644 --- a/examples/0.0-load-graph/client.js +++ b/examples/0.0-load-graph/client.js @@ -26,7 +26,7 @@ var Client = IgeClass.extend({ // Check if the engine started successfully if (success) { // Load the base scene data - ige.addGraph('BaseScene'); + ige.addGraph('IgeBaseScene'); // Add all the items in Scene1 to the scenegraph // (see gameClasses/Scene1.js :: addGraph() to see diff --git a/examples/1.1.0-startup/client.js b/examples/1.1.0-startup/client.js index 363fb6e80..73826b1ec 100644 --- a/examples/1.1.0-startup/client.js +++ b/examples/1.1.0-startup/client.js @@ -25,7 +25,7 @@ var Client = IgeClass.extend({ // Check if the engine started successfully if (success) { // Load the base scene data - ige.addGraph('BaseScene'); + ige.addGraph('IgeBaseScene'); // Create an entity and mount it to the scene self.obj[0] = new Rotator(0.1) diff --git a/examples/1.1.1-startup-own-canvas/client.js b/examples/1.1.1-startup-own-canvas/client.js index f472febce..932d9d1ff 100644 --- a/examples/1.1.1-startup-own-canvas/client.js +++ b/examples/1.1.1-startup-own-canvas/client.js @@ -28,7 +28,7 @@ var Client = IgeClass.extend({ // Check if the engine started successfully if (success) { // Load the base scene data - ige.addGraph('BaseScene'); + ige.addGraph('IgeBaseScene'); // Create an entity and mount it to the scene self.obj[0] = new Rotator() diff --git a/examples/1.1.2-startup-offset-canvas/client.js b/examples/1.1.2-startup-offset-canvas/client.js index 73e777a75..f92e520dd 100644 --- a/examples/1.1.2-startup-offset-canvas/client.js +++ b/examples/1.1.2-startup-offset-canvas/client.js @@ -28,7 +28,7 @@ var Client = IgeClass.extend({ // Check if the engine started successfully if (success) { // Load the base scene data - ige.addGraph('BaseScene'); + ige.addGraph('IgeBaseScene'); // Create an entity that will follow the mouse self.mouseEnt = new IgeEntity() diff --git a/examples/1.3-cell-sheets/client.js b/examples/1.3-cell-sheets/client.js index 2ebbb5eed..6e8f344af 100644 --- a/examples/1.3-cell-sheets/client.js +++ b/examples/1.3-cell-sheets/client.js @@ -26,7 +26,7 @@ var Client = IgeClass.extend({ // Check if the engine started successfully if (success) { // Load the base scene data - ige.addGraph('BaseScene'); + ige.addGraph('IgeBaseScene'); // Create an entity and mount it to the scene self.obj[0] = new IgeEntity() diff --git a/examples/1.4-sprite-sheets/client.js b/examples/1.4-sprite-sheets/client.js index 927d4da8d..e29f5c1c8 100644 --- a/examples/1.4-sprite-sheets/client.js +++ b/examples/1.4-sprite-sheets/client.js @@ -38,7 +38,7 @@ var Client = IgeClass.extend({ // Check if the engine started successfully if (success) { // Load the base scene data - ige.addGraph('BaseScene'); + ige.addGraph('IgeBaseScene'); // Create an entity and mount it to the scene self.obj[0] = new IgeEntity() diff --git a/examples/1.5-filters/client.js b/examples/1.5-filters/client.js index 9e8f96b92..8a078f5f7 100644 --- a/examples/1.5-filters/client.js +++ b/examples/1.5-filters/client.js @@ -41,7 +41,7 @@ var Client = IgeClass.extend({ var yStart = -300; // Load the base scene data - ige.addGraph('BaseScene'); + ige.addGraph('IgeBaseScene'); // Create an entity and mount it to the scene self.obj[0] = new IgeEntity() diff --git a/examples/1.8-point-at-mouse/client.js b/examples/1.8-point-at-mouse/client.js index 756167377..1a8ae8d4c 100644 --- a/examples/1.8-point-at-mouse/client.js +++ b/examples/1.8-point-at-mouse/client.js @@ -22,7 +22,7 @@ var Client = IgeClass.extend({ // Check if the engine started successfully if (success) { // Load the base scene data - ige.addGraph('BaseScene'); + ige.addGraph('IgeBaseScene'); self.vp1.camera.translateTo(200, 200, 0); diff --git a/examples/2.1-viewports/client.js b/examples/2.1-viewports/client.js index 378770767..cafbbc721 100644 --- a/examples/2.1-viewports/client.js +++ b/examples/2.1-viewports/client.js @@ -31,7 +31,7 @@ var Client = IgeClass.extend({ ige.viewportDepth(true); // Load the base scene data - ige.addGraph('BaseScene'); + ige.addGraph('IgeBaseScene'); // Make a load of viewports for (i = 0; i < vpCount; i++) {