12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- // 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 Fly 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.changeFlyCount, this.changeFlyCount, this)
- this.node.on(cc.Node.EventType.TOUCH_START, this.UseFly, this);//当手指在背景上移动时触发move事件
- cc.systemEvent.emit(EventName.changeFlyCount)
- }
- UseFly() {
- if (LocalData.getInstance().getFlyCount() > 0) {
- RewardMnr.getInstance().PropFlyjump(1)
- } else {
- cc.systemEvent.emit(EventName.Tips, `起飞去看广告一次的逻辑`)
- RewardMnr.getInstance().PopAward(AwardType.Fly)
- LocalData.getInstance().setFlyCount(1, '+')
- }
- }
- changeFlyCount() {
- if (LocalData.getInstance().getFlyCount() > 0) {
- this.CountBg_Video.spriteFrame = this.CountBg
- this.Count.string = LocalData.getInstance().getFlyCount().toString()
- } else {
- this.CountBg_Video.spriteFrame = this.Video
- this.Count.string = ''
- }
- }
- // update (dt) {}
- }
|