mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 10:37:34 +00:00
#79 added possibility to add non-colliding tile layers from tiled editor
This commit is contained in:
parent
61e66f5796
commit
feca76f677
7 changed files with 60 additions and 3 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
BIN
static/img/Tiles/Background/darkkitchentile.png
Normal file
BIN
static/img/Tiles/Background/darkkitchentile.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 163 B |
BIN
static/img/Tiles/Background/darksoil.png
Normal file
BIN
static/img/Tiles/Background/darksoil.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 512 B |
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue