mirror of
https://github.com/danbulant/heaventaker
synced 2026-05-24 12:35:04 +00:00
fix: clouds destroying not working properly
This commit is contained in:
parent
fe4743e68d
commit
a7e190812e
1 changed files with 15 additions and 10 deletions
|
|
@ -133,24 +133,24 @@ export class GameScene extends Phaser.Scene {
|
||||||
} else {
|
} else {
|
||||||
this.flags[x][y] = null;
|
this.flags[x][y] = null;
|
||||||
}
|
}
|
||||||
var item = row[x];
|
if(!row[x]) {
|
||||||
if(!item) {
|
|
||||||
this.items[x][y] = null;
|
this.items[x][y] = null;
|
||||||
this.winds[x][y] = null;
|
this.winds[x][y] = null;
|
||||||
this.sourceWinds[x][y] = null;
|
this.sourceWinds[x][y] = null;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
var item = {};
|
||||||
|
if(typeof row[x] === "string") {
|
||||||
|
item.type = row[x];
|
||||||
|
} else {
|
||||||
|
Object.assign(item, row[x]);
|
||||||
|
}
|
||||||
if(item.type === null) {
|
if(item.type === null) {
|
||||||
this.items[x][y] = item;
|
this.items[x][y] = item;
|
||||||
this.winds[x][y] = null;
|
this.winds[x][y] = null;
|
||||||
this.sourceWinds[x][y] = null;
|
this.sourceWinds[x][y] = null;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(typeof item === "string") {
|
|
||||||
item = {
|
|
||||||
type: item
|
|
||||||
}
|
|
||||||
}
|
|
||||||
item.direction = item.direction ?? 0;
|
item.direction = item.direction ?? 0;
|
||||||
y = parseInt(y);
|
y = parseInt(y);
|
||||||
x = parseInt(x);
|
x = parseInt(x);
|
||||||
|
|
@ -160,8 +160,9 @@ export class GameScene extends Phaser.Scene {
|
||||||
type = this.map.sprite;
|
type = this.map.sprite;
|
||||||
item.texture = type;
|
item.texture = type;
|
||||||
}
|
}
|
||||||
|
let sprite;
|
||||||
if(this.textures.get(type).frameTotal > 1) {
|
if(this.textures.get(type).frameTotal > 1) {
|
||||||
var sprite = this.add.sprite(x * this.map.px, y * this.map.px);
|
sprite = this.add.sprite(x * this.map.px, y * this.map.px);
|
||||||
item.animated = true;
|
item.animated = true;
|
||||||
if(!this.anims.exists(type)) {
|
if(!this.anims.exists(type)) {
|
||||||
const frames = this.anims.generateFrameNumbers(type);
|
const frames = this.anims.generateFrameNumbers(type);
|
||||||
|
|
@ -175,13 +176,16 @@ export class GameScene extends Phaser.Scene {
|
||||||
}
|
}
|
||||||
sprite.play(type);
|
sprite.play(type);
|
||||||
} else {
|
} else {
|
||||||
var sprite = this.add.sprite(x * this.map.px, y * this.map.px, type);
|
console.log("sprite", x, y, type);
|
||||||
|
sprite = this.add.sprite(x * this.map.px, y * this.map.px, type);
|
||||||
item.animated = false;
|
item.animated = false;
|
||||||
}
|
}
|
||||||
sprite.scale = this.map.px / 100;
|
sprite.scale = this.map.px / 100;
|
||||||
sprite.setRotation(item.direction * Math.PI / 2);
|
sprite.setRotation(item.direction * Math.PI / 2);
|
||||||
this.grid.add(sprite);
|
this.grid.add(sprite);
|
||||||
item.sprite = sprite;
|
Object.defineProperty(item, "sprite", {
|
||||||
|
value: sprite
|
||||||
|
});
|
||||||
|
|
||||||
if(item.type === "spawn") {
|
if(item.type === "spawn") {
|
||||||
/** @type {{ x: number, y: number, hasKey: boolean }} */
|
/** @type {{ x: number, y: number, hasKey: boolean }} */
|
||||||
|
|
@ -273,6 +277,7 @@ export class GameScene extends Phaser.Scene {
|
||||||
*/
|
*/
|
||||||
tryDestroy(toX, toY) {
|
tryDestroy(toX, toY) {
|
||||||
if(this.items[toX][toY].destroyable) {
|
if(this.items[toX][toY].destroyable) {
|
||||||
|
console.log("Destroying", toX, toY, this.items[toX][toY].sprite.x, this.items[toX][toY].sprite.y, this.items[toX][toY].sprite);
|
||||||
this.items[toX][toY].sprite.alpha = 0;
|
this.items[toX][toY].sprite.alpha = 0;
|
||||||
this.items[toX][toY].sprite.destroy();
|
this.items[toX][toY].sprite.destroy();
|
||||||
this.items[toX][toY] = null;
|
this.items[toX][toY] = null;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue