// 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 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 Supjump 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.changeSupjumpCount, this.changeSupjumpCount, this) this.node.on(cc.Node.EventType.TOUCH_START, this.useSupjump, this);//当手指在背景上移动时触发move事件 cc.systemEvent.emit(EventName.changeSupjumpCount) } useSupjump() { if (LocalData.getInstance().getSupjumpCount() > 0) { RewardMnr.getInstance().PropUseSupjump(1) } else { // cc.systemEvent.emit(EventName.Tips, `超级跳去看广告一次的逻辑`) RewardMnr.getInstance().PopAward(AwardType.ChaojiTiao) LocalData.getInstance().setSupjumpCount(1, '+') } } changeSupjumpCount() { if (LocalData.getInstance().getSupjumpCount() > 0) { this.CountBg_Video.spriteFrame = this.CountBg this.Count.string = LocalData.getInstance().getSupjumpCount().toString() } else { this.CountBg_Video.spriteFrame = this.Video this.Count.string = '' } } // update (dt) {} }