implemented spawn points and a brand new map

This commit is contained in:
logsol 2014-02-03 16:18:22 +01:00
parent 4ea86a97aa
commit cc8aedd3ba
10 changed files with 1283 additions and 10645 deletions

View file

@ -62,8 +62,6 @@ define([
} else {
console.warn("Level: No collision Layer given");
}
this.levelData = null; // free up memory
}
TiledLevel.prototype.getTileImagePath = function(gid) {
@ -77,5 +75,26 @@ define([
}
}
TiledLevel.prototype.getRandomSpawnPoint = function() {
if(!this.levelData) {
return Parent.prototype.getRandomSpawnPoint.call(this);
}
for (var i = 0; i < this.levelData.layers.length; i++) {
if(this.levelData.layers[i].name === "spawnpoints") {
var spawnLayer = this.levelData.layers[i];
var size = spawnLayer.objects.length;
var object = spawnLayer.objects[parseInt(Math.random() * (size -1), 10)];
return {
x: object.x,
y: object.y
}
}
}
};
return TiledLevel;
})