import { _decorator, Component, Node, Animation } from 'cc'; import { Sound } from '../core/sound/Sound'; const { ccclass, property } = _decorator; @ccclass('OpenAnim') export class OpenAnim extends Component { @property({ tooltip: "开字旋转动画", type: Animation }) private anim: Animation; @property({ tooltip: "开红包动画", type: Animation }) private openRedAnim: Animation; @property({ tooltip: "音效组件", type: Sound }) private sound: Sound; private times = 3; start() { // [3] } public animBack() { this.times--; !this.times && this.anim.stop(); !this.times && this.openRedAnim.play(); !this.times && this.sound.play(); } }