mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 10:37:34 +00:00
added layers
This commit is contained in:
parent
7c783d19e8
commit
d29c64385d
4 changed files with 142 additions and 108 deletions
|
|
@ -13,11 +13,6 @@ function (Parent, Settings, Nc, PIXI) {
|
|||
|
||||
Level.prototype = Object.create(Parent.prototype);
|
||||
|
||||
Level.prototype.setup = function(levelData) {
|
||||
this.levelData = levelData;
|
||||
this.addBackground();
|
||||
Parent.prototype.setup.call(this, levelData);
|
||||
};
|
||||
|
||||
Level.prototype.loadLevelDataFromPath = function (path, callback) {
|
||||
var self = this;
|
||||
|
|
@ -93,5 +88,15 @@ function (Parent, Settings, Nc, PIXI) {
|
|||
return paths;
|
||||
};
|
||||
|
||||
Level.prototype.createItems = function(options) {
|
||||
Nc.trigger(); // FIXME
|
||||
Parent.prototype.createItems.call(this, options);
|
||||
};
|
||||
|
||||
Level.prototype.createTiles = function(first_argument) {
|
||||
Nc.trigger(); // FIXME
|
||||
Parent.prototype.createItems.call(this, options);
|
||||
};
|
||||
|
||||
return Level;
|
||||
});
|
||||
|
|
@ -10,7 +10,21 @@ function (Parent, Settings) {
|
|||
}
|
||||
|
||||
TiledLevel.prototype = Object.create(Parent.prototype);
|
||||
|
||||
|
||||
TiledLevel.prototype.setup = function(levelData) {
|
||||
/*
|
||||
FIXME: find a name for this shit!
|
||||
for (var i = 0; i < levelData.layers.length; i++) {
|
||||
var layerOptions = levelData.layers[i];
|
||||
layerOptions.z = i;
|
||||
if(!this.layerMapping[layerOptions.name]) {
|
||||
this.createLayer(layerOptions);
|
||||
}
|
||||
};
|
||||
*/
|
||||
Parent.prototype.setup.call(this, levelData);
|
||||
};
|
||||
|
||||
TiledLevel.prototype.getAssetPaths = function(levelData) {
|
||||
var paths = Parent.prototype.getAssetPaths.call(this, levelData);
|
||||
|
||||
|
|
@ -44,9 +58,32 @@ function (Parent, Settings) {
|
|||
paths.push(Settings.MAPS_PATH + background.image);
|
||||
|
||||
return paths;
|
||||
|
||||
}
|
||||
|
||||
|
||||
TiledLevel.prototype.addBackground = function(options) {
|
||||
var texturePath = Settings.GRAPHICS_PATH + options.image;
|
||||
|
||||
var callback = function (mesh) {
|
||||
Nc.trigger(Nc.ns.client.view.mesh.add, mesh, 0); // FIXME: add at z layer -1 or so
|
||||
}
|
||||
Nc.trigger(Nc.ns.client.view.mesh.create, texturePath, callback, {
|
||||
width: 4000,
|
||||
height: 2959,
|
||||
x: -(4000 - Settings.STAGE_WIDTH) / 2,
|
||||
y: -(2959 + Settings.STAGE_HEIGHT + 700) / 2
|
||||
});
|
||||
}
|
||||
|
||||
TiledLevel.prototype.getLayer = function(levelData, name) {
|
||||
for (var i = 0; i < levelData.layers.length; i++) {
|
||||
if(levelData.layers[i].name === name) {
|
||||
return levelData.layers[i];
|
||||
}
|
||||
}
|
||||
|
||||
throw "Layer '" + name + "' not found.";
|
||||
};
|
||||
|
||||
return TiledLevel;
|
||||
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue