fixes initial level positioning

This commit is contained in:
Jeena 2015-04-19 16:06:23 +02:00
parent aaa1db4468
commit cad112419d
14 changed files with 91 additions and 61 deletions

View file

@ -12,6 +12,10 @@ function (Parent, Settings, Nc, PIXI, AbstractLayer) {
function Level (uid, engine, gameObjects) {
Parent.call(this, uid, engine, gameObjects);
this.levelSize = {
width: 0,
height: 0
}
}
Level.prototype = Object.create(Parent.prototype);
@ -112,7 +116,16 @@ function (Parent, Settings, Nc, PIXI, AbstractLayer) {
if (options.properties && options.properties.parallaxSpeed) {
parallaxSpeed = parseFloat(options.properties.parallaxSpeed);
}
Nc.trigger(Nc.ns.client.view.layer.createAndInsert, options.layerId, parallaxSpeed, behind, referenceId);
Nc.trigger(
Nc.ns.client.view.layer.createAndInsert,
options.layerId,
{
parallaxSpeed: parallaxSpeed,
levelSize: this.levelSize
},
behind,
referenceId
);
};
return Level;

View file

@ -16,16 +16,14 @@ function (Parent, Settings, Nc) {
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);
}
var tilesLayerData = this.getLayer(levelData, "tiles");
this.levelSize = {
width: tilesLayerData.width * Settings.TILE_SIZE,
height: tilesLayerData.height * Settings.TILE_SIZE
};
*/
Nc.trigger(Nc.ns.client.view.layer.levelSizeUpdate, this.levelSize);
Parent.prototype.setup.call(this, levelData);
};