mirror of
http://junepve.top:3000/chicrobot/CINC.git
synced 2026-10-30 04:21:29 +08:00
fix(SS) 故事场景备份
This commit is contained in:
1 parent
201322d2e7
commit
31a41bbffe
1 file changed
+25
-25
@@ -10,12 +10,15 @@ export default class BreatheLife extends Phaser.Scene {
|
||||
* 构造函数
|
||||
* 初始化场景并设置场景键名为 'BreatheLife'
|
||||
*/
|
||||
constructor() {super('BreatheLife')}
|
||||
constructor() {
|
||||
super('BreatheLife')
|
||||
this.nextScene = 'MenuScene'
|
||||
}
|
||||
|
||||
preload() {
|
||||
// 加载角色动画和图片资源
|
||||
this.load.image(`player0-0`, `assets/PNG/Players/Tiles/tile_${String(0).padStart(4, '0')}.png`);
|
||||
this.load.image(`player1-0`, `assets/PNG/Players/Tiles/tile_${String(8).padStart(4, '0')}.png`);
|
||||
this.load.image(`player0-0`, `assets/PNG/Players/Tiles/tile_${String(0).padStart(4, '0')}.png`)
|
||||
this.load.image(`player1-0`, `assets/PNG/Players/Tiles/tile_${String(8).padStart(4, '0')}.png`)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -47,32 +50,29 @@ export default class BreatheLife extends Phaser.Scene {
|
||||
// 获取点击位置的精灵
|
||||
const clickedSprite = this.getClickedSprite(x, y)
|
||||
console.log("点击到的精灵:", clickedSprite)
|
||||
console.log("已设置纹理的角色数量:", this.spriteTextureCount)
|
||||
console.log("已创建的角色数量:", this.spriteCount)
|
||||
// 如果满足条件则切换到下一场景
|
||||
if (this.spriteCount >= 3 && this.spriteTextureCount >= 3) {
|
||||
this.scene.start('MenuScene')
|
||||
return
|
||||
}else if (clickedSprite) { // 如果点击到了精灵
|
||||
// 显示当前精灵的纹理
|
||||
console.log("当前精灵的纹理:", clickedSprite.texture.key)
|
||||
// 如果没有纹理或纹理为默认值
|
||||
if (clickedSprite.texture.key === '__MISSING' || clickedSprite.texture.key === 'player') {
|
||||
// 设置纹理
|
||||
this.setSpriteTexture(clickedSprite, `player1-0`)
|
||||
}
|
||||
return
|
||||
}else if (this.spriteCount >= 3) {
|
||||
return
|
||||
this.scene.start(this.nextScene)
|
||||
}
|
||||
else if (clickedSprite) { // 如果点击到了精灵
|
||||
console.log("当前精灵的纹理:", clickedSprite.texture.key) // 查看当前精灵的纹理
|
||||
// 如果纹理为默认值或纹理缺失
|
||||
if (clickedSprite.texture.key === 'player' || clickedSprite.texture.key === '__MISSING') {
|
||||
this.setSpriteTexture(clickedSprite, `player1-0`) // 设置指定的纹理
|
||||
}
|
||||
}
|
||||
else {
|
||||
// 创建一个新的角色 sprite,缩放为1倍
|
||||
const sprite = this.physics.add.sprite(x, y, 'player').setScale(1)
|
||||
|
||||
// 创建一个新的角色 sprite,缩放为1倍
|
||||
const sprite = this.physics.add.sprite(x, y, 'player').setScale(1)
|
||||
// 设置角色碰撞世界边界
|
||||
sprite.setCollideWorldBounds(true)
|
||||
|
||||
// 设置角色碰撞世界边界
|
||||
sprite.setCollideWorldBounds(true)
|
||||
|
||||
// 增加角色计数器
|
||||
this.spriteCount++
|
||||
// 增加角色计数器
|
||||
this.spriteCount++
|
||||
console.log("已设置纹理的角色数量:", this.spriteTextureCount)
|
||||
console.log("已创建的角色数量:", this.spriteCount)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user