feat(game/enemies): 完善怪物头顶语录飘字系统,集成语录数据文件,添加跟随移动和淡出动画

This commit is contained in:
Cloud Bot
2026-03-21 08:14:53 +00:00
parent f6694544f0
commit d13e17ffc5
5 changed files with 22 additions and 19 deletions

View File

@@ -112,6 +112,10 @@ export abstract class EnemyBase {
this.moveAlongPath(delta)
this.drawHealthBar()
this.sprite.setPosition(this.x, this.y)
// 语录文字跟随怪物移动
if (this.quoteText && this.quoteText.alpha > 0) {
this.quoteText.setPosition(this.x, this.y - 30)
}
}
protected processDOT(delta: number): void {
@@ -229,12 +233,19 @@ export abstract class EnemyBase {
protected onDeath(): void {}
/** 显示头顶语录(短暂 */
/** 显示头顶语录(出生后随机触发3秒后淡出 */
showQuote(): void {
if (this.isDead || !this.quoteText) return
this.quoteText.setText(this.getQuote())
this.quoteText.setPosition(this.x, this.y - 30)
this.quoteText.setAlpha(1)
this.scene.time.delayedCall(1500, () => {
if (this.quoteText) this.quoteText.setAlpha(0)
// 3秒后淡出动画
this.scene.tweens.add({
targets: this.quoteText,
alpha: 0,
duration: 800,
delay: 2200,
ease: 'Linear',
})
}