feat(hero): 添加受击闪光效果并重构相关代码
新增FlashSprite组件实现受击闪光效果 重构HeroAnmComp和HeroViewComp以支持闪光效果 更新多个英雄prefab以包含闪光材质和组件
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user