import BaseEvent from "../../fight/evnet/base/BaseEvent"; /** * 摘果子 */ const { ccclass, property } = cc._decorator; @ccclass export default class JG0106_3 extends BaseEvent { @property({ displayName: '摘取的道具id' }) public id = 5001; @property({ type: cc.ProgressBar, displayName: '进度条' }) public mProgressBar: cc.ProgressBar = null; @property({ type: cc.SpriteFrame, displayName: '图标' }) public mTipsIcon: cc.SpriteFrame = null; onLoad() { super.onLoad() this.mProgressBar.node.active = false; } /** * 主角进入碰撞区域 * @param tag 碰撞组件编号 */ public onBegin(tag: number) { this.showOpt(this.mTipsIcon, () => { this.pick(); }) } public onEnd(tag: number) { this.closeOpt() } /** * 摘取果子 */ public pick() { this.closeOpt() this.pause() this.mProgressBar.node.active = true; this.mProgressBar.progress = 0; this.ff.mBlockInputEvents.active = true; this.schedule(this.pupdate, 0.1); } public pupdate() { let progress = this.mProgressBar.progress; progress += 0.1; this.mProgressBar.progress = progress; if (progress >= 1) { this.ff.mBlockInputEvents.active = false; this.unschedule(this.pupdate); this.ff.mFFheader.addTmpGood(this.id, 1); this.node.removeComponent(cc.PhysicsBoxCollider); this.resume() cc.tween(this.node).sequence( cc.fadeOut(0.5), cc.destroySelf() ).start() } } }