#79 added possibility to add non-colliding tile layers from tiled editor

This commit is contained in:
logsol 2015-03-12 11:11:16 +01:00
parent 61e66f5796
commit feca76f677
7 changed files with 60 additions and 3 deletions

View file

@ -103,8 +103,45 @@ function (Parent, Settings, Nc) {
);
}
// Adding tiles without collision
else if (options.type == "tilelayer" && options.name != "tiles") {
this.createNonCollidingTiles(options);
}
};
TiledLevel.prototype.createNonCollidingTiles = function(options) {
var data = options.data;
var tilesOptions = [];
for (var i = 0; i < data.length; i++) {
var gid = data[i];
if(gid === 0) continue;
var imagePath = this.getTileImagePath(gid);
var parts = imagePath.split("/");
var tileType = parts[parts.length - 1].split(".")[0].split("")
var callback = function(mesh) {
Nc.trigger(Nc.ns.client.view.mesh.add, options.layerId, mesh);
}
Nc.trigger(Nc.ns.client.view.mesh.create,
options.layerId,
Settings.MAPS_PATH + imagePath,
callback,
{
width: Settings.TILE_SIZE,
height: Settings.TILE_SIZE,
x: (i % options.width) * Settings.TILE_SIZE,
y: parseInt(i / options.height , 10) * Settings.TILE_SIZE,
}
);
}
}
TiledLevel.prototype.getLayer = function(levelData, name) {
for (var i = 0; i < levelData.layers.length; i++) {
if(levelData.layers[i].name === name) {

View file

@ -262,7 +262,8 @@ function (Parent, PIXI, ColorRangeReplaceFilter, Settings, ColorConverter) {
|| this.name == "tile"
|| this.name == "item"
|| this.name == "ghost"
|| this.name == "swiper") {
|| this.name == "swiper"
|| this.parallaxSpeed == 0) {
this.container.x = this.position.current.x;
this.container.y = this.position.current.y;
}