feat(hero): 添加受击闪光效果并重构相关代码

新增FlashSprite组件实现受击闪光效果
重构HeroAnmComp和HeroViewComp以支持闪光效果
更新多个英雄prefab以包含闪光材质和组件
This commit is contained in:
2025-11-15 11:15:30 +08:00
parent 4af9a6fd9e
commit 46a779633a
28 changed files with 2800 additions and 862 deletions

View File

@@ -0,0 +1,29 @@
import { _decorator, color, Component, Material, Node, Sprite } from 'cc';
const { ccclass, property } = _decorator;
@ccclass('FlashSprite')
export class FlashSprite extends Component {
@property(Material)
hitFlashMaterial: Material;
orginalFlashMaterial: Material;
sprite: Sprite;
start() {
this.sprite = this.node.getComponent(Sprite);
this.orginalFlashMaterial = this.sprite.getRenderMaterial(0);
}
update(deltaTime: number) {
}
public clickFlash() {
this.sprite.setSharedMaterial(this.hitFlashMaterial, 0);
this.scheduleOnce(() => {
this.sprite.setSharedMaterial(this.orginalFlashMaterial, 0);
}, 0.1);
}
}