const GameNotificationKey = require('../utils/GameEnum').GameNotificationKey;
const GameModule = require("../utils/GameModule");
cc.Class({
extends: cc.Component,
properties: {
coinRichText: cc.RichText,
coinSkeleton: sp.Skeleton
},
// LIFE-CYCLE CALLBACKS:
onLoad () {
this.vsize = cc.view.getVisibleSize();
this.coinSkeleton.node.y = -600;
},
init(gold) {
this.gold = gold;
this.showCoin();
},
showCoin() {
let coinY = (this.vsize.height - this.coinSkeleton.node.height)/2 - 350;
let moveAction = cc.moveTo(0.8, 0, coinY).easing(cc.easeCubicActionOut());
let scaleAction = cc.scaleTo(0.8, 1.5, 1.5);
let spaw = cc.spawn(moveAction,scaleAction);
let finished = cc.callFunc(() => {
this.coinSkeleton.node.scale = 1.0;
this.coinSkeleton.setAnimation(0, 'jinbi_hit', false);
GameModule.audioMng.playUpdateBuilding();
this.coinSkeleton.setCompleteListener(() => {
});
setTimeout(() => {
this.showCoinText();
}, 700);
});
this.coinSkeleton.node.runAction(cc.sequence(spaw, finished));
GameEvent.fire(GameNotificationKey.PlaySuccessAnimation, true);
GameEvent.fire('just_cat_hit');
},
showCoinText() {
this.coinRichText.node.active = true;
this.coinRichText.string = ` +${this.gold}>`;
setTimeout(() => {
this.node.destroy();
}, 1100);
},
start () {
},
// update (dt) {},
});