Tilorswift fix for save

This commit is contained in:
Mal 2023-09-19 01:23:18 +02:00
parent 32a2c15551
commit c6b0baa533
1 changed files with 13 additions and 13 deletions

View File

@ -205,36 +205,36 @@ export default class Tilorswift
window.addEventListener(
TilorswiftEvent.MENU_SAVE_CLICKED,
()=> {
if (this.saveLevelToFile(this.level)) {
if (this.saveLevelToFile()) {
window.dispatchEvent(new TilorswiftSavedEvent());
}
}
);
}
getLevelAsJson(level)
getLevelAsJson()
{
let matrix = [];
for (let y = 0; y < level.terrain.fields.length; y++) {
for (let y = 0; y < this.level.terrain.fields.length; y++) {
let row = [];
for (let x = 0; x < level.terrain.fields[y].length; x++) {
row.push(level.terrain.fields[y][x].index);
for (let x = 0; x < this.level.terrain.fields[y].length; x++) {
row.push(this.level.terrain.fields[y][x].index);
}
matrix.push(row);
}
let data = {
tileset: level.getTilesetId(),
rows: level.getRows(),
columns: level.getColumns(),
startX: level.getStartX(),
startY: level.getStartY(),
targetX: level.getTargetX(),
targetY: level.getTargetY(),
gravity: level.gravity,
tileset: this.level.getTilesetId(),
rows: this.level.getRows(),
columns: this.level.getColumns(),
startX: this.level.getStartX(),
startY: this.level.getStartY(),
targetX: this.level.getTargetX(),
targetY: this.level.getTargetY(),
gravity: this.level.gravity,
matrix: matrix,
};