mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 10:37:34 +00:00
layer bugfixing
This commit is contained in:
parent
d29c64385d
commit
1d3ad16a07
9 changed files with 56 additions and 9 deletions
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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']);
|
||||
|
|
|
|||
18
app/Game/Client/View/Views/Pixi/Layer.js
Normal file
18
app/Game/Client/View/Views/Pixi/Layer.js
Normal file
|
|
@ -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;
|
||||
});
|
||||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ define([
|
|||
};
|
||||
|
||||
Level.prototype.createItem = function(uid, options) {
|
||||
|
||||
switch(options.type) {
|
||||
//case 'skateboard':
|
||||
// return new Skateboard(this.engine, uid, options);
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue