30 lines
723 B
TypeScript
30 lines
723 B
TypeScript
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);
|
|
}
|
|
}
|
|
|