// Learn cc.Class: // - https://docs.cocos.com/creator/manual/en/scripting/class.html // Learn Attribute: // - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html // Learn life-cycle callbacks: // - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html cc.Class({ extends: cc.Component, properties: { coinParticle:{ default: null, type: cc.Prefab, }, earnMoney:{ default: null, type: cc.Prefab, }, lb:{ default: null, type: cc.Label, }, }, onLoad(){ cc.game.addPersistRootNode(this.node); this.inittime(); }, inittime(){ let _this = this; // let countDownNode = this.daojishi_string.getComponent(Label); this.lb.string = '05:00'; let time = 180; this.lb.schedule(function () { time--; let minute = Math.floor(time / 60); let second = time % 60; let timeStr = minute + ":" + second; _this.lb.string = timeStr; if (time == 0) { cc.tween(_this.node) .to(1, { scale: 1.2}) .to(1, { scale: 1 }) .union() .repeatForever() .start(); if (cc.sys.language != cc.sys.LANGUAGE_CHINESE) { _this.lb.string = "Get" } else { _this.lb.string = "领取" } } }, 1, time - 1, 0); }, gettimereward(){ if (cc.sys.language != cc.sys.LANGUAGE_CHINESE) { if (this.lb.string != 'Get') { return; } } else { if (this.lb.string != '领取') { return; } } let ani = this.node.getComponent(cc.Animation); ani.play(); // ani.setCurrentTime(2); // register event to all animation this.finished() this.inittime(); // this.node.getComponent('collect_coin_anim').onPlayCoinAni(this.node); }, finished : function () { // callback console.log("finished") this.scheduleOnce(()=>{ this.node.stopAllActions(); this.node.getComponent(cc.Animation).stop(); },1) let icon = Storage.Get_storage(Storage.GameMessageType.coin); Storage.Set_storage(Storage.GameMessageType.coin, Number(icon) + 10000); let sjb = cc.instantiate(this.coinParticle); sjb.parent = this.node; this.showCoinAdd(10000) }, showCoinAdd(num) { let earnnum = cc.instantiate(this.earnMoney); earnnum.setScale(0.5); earnnum.getComponent(cc.Label).string = num; earnnum.parent = this.node; // var placeAction = cc.place(-425, 0); var actionhide = cc.hide(); var actionTo = cc.jumpTo(0.5, 0, 50, 50, 1); var ActionAll = cc.sequence(actionTo, actionhide) earnnum.runAction(ActionAll); } });