// Learn TypeScript: // - https://docs.cocos.com/creator/2.4/manual/en/scripting/typescript.html // Learn Attribute: // - https://docs.cocos.com/creator/2.4/manual/en/scripting/reference/attributes.html // Learn life-cycle callbacks: // - https://docs.cocos.com/creator/2.4/manual/en/scripting/life-cycle-callbacks.html import EventName, { GuideType } from "../EventName/EventName"; import LocalData from "../LocalData"; import { AwardType } from "../Pop/Award"; import MyComponent from "../Template/MyComponent"; import RewardMnr from "../Template/RewardMnr"; const { ccclass, property } = cc._decorator; //抛物线的次数 @ccclass export default class XuXian extends MyComponent { @property(cc.Label) Count: cc.Label = null; @property(cc.Sprite) CountBg_Video: cc.Sprite = null; @property(cc.SpriteFrame) CountBg: cc.SpriteFrame = null; @property(cc.SpriteFrame) Video: cc.SpriteFrame = null; // LIFE-CYCLE CALLBACKS: // onLoad () {} start() { this.regEvent(EventName.changeParabolaCount, this.changeParabolaCount, this) this.node.on(cc.Node.EventType.TOUCH_START, this.useParabola, this);//当手指在背景上移动时触发move事件 cc.systemEvent.emit(EventName.changeParabolaCount) } useParabola() { if (!LocalData.getInstance().getGuide(GuideType.完整抛物线)) { cc.systemEvent.emit(EventName.ShowGuide, GuideType.完整抛物线) } if (LocalData.getInstance().getParabolaCount() > 0) { RewardMnr.getInstance().PropUseParabola(1) } else { // cc.systemEvent.emit(EventName.Tips, `完整抛物线去看广告一次的逻辑`) RewardMnr.getInstance().PopAward(AwardType.XuXian) LocalData.getInstance().setParabolaCount(3, '+') } } changeParabolaCount() { if (LocalData.getInstance().getParabolaCount() > 0) { this.CountBg_Video.spriteFrame = this.CountBg this.Count.string = LocalData.getInstance().getParabolaCount().toString() } else { this.CountBg_Video.spriteFrame = this.Video this.Count.string = '' } } // update (dt) {} }