diff --git a/app/Game/Client/GameObjects/Doll.js b/app/Game/Client/GameObjects/Doll.js index 20c2343..19fd078 100755 --- a/app/Game/Client/GameObjects/Doll.js +++ b/app/Game/Client/GameObjects/Doll.js @@ -31,7 +31,6 @@ function (Parent, Settings, Nc, Exception, ColorConverter) { var converter = new ColorConverter(); this.primaryColor = converter.getColorByName(player.getNickname()); - console.log(this.primaryColor.toString(16)) Parent.call(this, physicsEngine, uid, player); } diff --git a/app/Game/Client/Loader/Level.js b/app/Game/Client/Loader/Level.js index 794b79a..df5ba5e 100755 --- a/app/Game/Client/Loader/Level.js +++ b/app/Game/Client/Loader/Level.js @@ -89,13 +89,21 @@ function (Parent, Settings, Nc, PIXI) { }; Level.prototype.createItems = function(options) { - Nc.trigger(); // FIXME + + var layerName = "items"; + Nc.trigger(Nc.ns.client.view.layer.createAndAdd, layerName); + options.layer = layerName; + Parent.prototype.createItems.call(this, options); }; - Level.prototype.createTiles = function(first_argument) { - Nc.trigger(); // FIXME - Parent.prototype.createItems.call(this, options); + Level.prototype.createTiles = function(options) { + + var layerName = "tiles"; + Nc.trigger(Nc.ns.client.view.layer.createAndAdd, layerName); + options.layer = layerName; + + Parent.prototype.createTiles.call(this, options); }; return Level; diff --git a/app/Game/Client/View/Views/AbstractView.js b/app/Game/Client/View/Views/AbstractView.js index 31bb692..38e5636 100755 --- a/app/Game/Client/View/Views/AbstractView.js +++ b/app/Game/Client/View/Views/AbstractView.js @@ -14,6 +14,8 @@ function (Abstract, DomController, Settings, Exception, Nc) { this.debugMode = false; this.ncTokens = [ + Nc.on(Nc.ns.client.view.layer.createAndAdd, this.createLayer, this), + Nc.on(Nc.ns.client.view.mesh.create, this.createMesh, this), Nc.on(Nc.ns.client.view.animatedMesh.create, this.createAnimatedMesh, this), Nc.on(Nc.ns.client.view.mesh.add, this.addMesh, this), @@ -41,6 +43,7 @@ function (Abstract, DomController, Settings, Exception, Nc) { } Abstract.prototype.addMethod.call(AbstractView, 'render'); + Abstract.prototype.addMethod.call(AbstractView, 'createAndAddLayer', ['name']); Abstract.prototype.addMethod.call(AbstractView, 'createMesh', ['texturePath', 'callback', 'options']); Abstract.prototype.addMethod.call(AbstractView, 'createAnimatedMesh', ['texturePaths', 'callback', 'options']); Abstract.prototype.addMethod.call(AbstractView, 'addMesh', ['mesh']); diff --git a/app/Game/Client/View/Views/Pixi/Layer.js b/app/Game/Client/View/Views/Pixi/Layer.js new file mode 100644 index 0000000..8f9d4d9 --- /dev/null +++ b/app/Game/Client/View/Views/Pixi/Layer.js @@ -0,0 +1,18 @@ +define([ + "Lib/Vendor/Pixi", +], + +function (PIXI) { + + function Layer (name, parallax) { + this.name = name; + this.container = new PIXI.DisplayObjectContainer(); + this.parallax = parallax; + } + + Layer.prototype.getContainer = function() { + return this.container; + }; + + return Layer; +}); \ No newline at end of file diff --git a/app/Game/Client/View/Views/PixiView.js b/app/Game/Client/View/Views/PixiView.js index 22767f4..77810d2 100755 --- a/app/Game/Client/View/Views/PixiView.js +++ b/app/Game/Client/View/Views/PixiView.js @@ -6,10 +6,11 @@ define([ "Game/Config/Settings", "Lib/Utilities/NotificationCenter", "Lib/Utilities/Exception", - "Game/Client/View/Views/Pixi/GameStats" + "Game/Client/View/Views/Pixi/GameStats", + "Game/Client/View/Views/Pixi/Layer" ], -function (Parent, DomController, PIXI, ColorRangeReplaceFilter, Settings, Nc, Exception, GameStats) { +function (Parent, DomController, PIXI, ColorRangeReplaceFilter, Settings, Nc, Exception, GameStats, Layer) { var AVAILABLE_MESH_FILTERS = { "blur": PIXI.BlurFilter, @@ -32,6 +33,7 @@ function (Parent, DomController, PIXI, ColorRangeReplaceFilter, Settings, Nc, Ex this.init(); this.pixi = PIXI; this.currentZoom = Settings.ZOOM_DEFAULT; + this.layers = []; PIXI.scaleModes.DEFAULT = PIXI.scaleModes.NEAREST; } @@ -72,6 +74,15 @@ function (Parent, DomController, PIXI, ColorRangeReplaceFilter, Settings, Nc, Ex this.renderer.render(this.stage); } + // Layers + + PixiView.prototype.createAndAddLayer = function(name) { + + var layer = new Layer(name, 1); + this.layers.push(layer); + this.stage.addChild(layer.getContainer()); + }; + // Meshes PixiView.prototype.addMesh = function(mesh) { diff --git a/app/Game/Core/GameObjects/Item.js b/app/Game/Core/GameObjects/Item.js index dea0e5f..f517a69 100644 --- a/app/Game/Core/GameObjects/Item.js +++ b/app/Game/Core/GameObjects/Item.js @@ -27,7 +27,7 @@ function (Parent, Box2D, Options, Settings, Exception, Nc) { if(!this.options.category) { // FIXME add more validation - console.warn('item category empty (' + this.options.name + ')' ); + //console.warn('item category empty (' + this.options.name + ')' ); } Parent.call(this, physicsEngine, uid); diff --git a/app/Game/Core/Loader/Level.js b/app/Game/Core/Loader/Level.js index 529fde5..1d73374 100755 --- a/app/Game/Core/Loader/Level.js +++ b/app/Game/Core/Loader/Level.js @@ -42,6 +42,7 @@ define([ }; Level.prototype.createItem = function(uid, options) { + switch(options.type) { //case 'skateboard': // return new Skateboard(this.engine, uid, options); diff --git a/app/Game/Core/Loader/TiledLevel.js b/app/Game/Core/Loader/TiledLevel.js index cc80943..7471f71 100755 --- a/app/Game/Core/Loader/TiledLevel.js +++ b/app/Game/Core/Loader/TiledLevel.js @@ -17,6 +17,7 @@ define([ this.layerMapping = { tiles: this.createTiles.bind(this), + collision: this.createTiles.bind(this), items: this.createItems.bind(this), spawnpoints: this.createSpawnPoints.bind(this) }; @@ -34,7 +35,10 @@ define([ var layerOptions = levelData.layers[i]; layerOptions.z = i; if(this.layerMapping[layerOptions.name]) { + this.layerMapping[layerOptions.name](layerOptions); + } else { + console.warn('No layerMapping for level file layer: ' + layerOptions.name); } }; @@ -87,7 +91,7 @@ define([ return { x: o.x, y: o.y }; }); - Parent.prototype.createSpawnPoints(this, points); + Parent.prototype.createSpawnPoints.call(this, points); }; TiledLevel.prototype.gatherOptions = function(tiledObject) { diff --git a/app/Lib/Utilities/NotificationCenter.js b/app/Lib/Utilities/NotificationCenter.js index 6b6cc71..8afe2dd 100755 --- a/app/Lib/Utilities/NotificationCenter.js +++ b/app/Lib/Utilities/NotificationCenter.js @@ -25,6 +25,9 @@ function (Exception) { this.ns = { client: { view: { + layer: { + createAndAdd: null + }, mesh: { create: null, add: null,