123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- const GameModule = require("../utils/GameModule");
- cc.Class({
- extends: cc.Component,
- properties: {
- coinSkeleton: sp.Skeleton,
- },
- // LIFE-CYCLE CALLBACKS:
- onLoad () {
- this.isPlaying = false;
- var sd = this.coinSkeleton.skeletonData.getRuntimeData(true);
- this.hitAnimations = sd.animations.filter(item => item.name.indexOf('jinbi_hit') != -1).map(animation => animation.name) || [];
- },
- showOnceCoin() {
- if (this.hitAnimations.length > 0) {
- let hitType = Math.floor(Math.random() * this.hitAnimations.length);
- this.coinSkeleton.setAnimation(0, this.hitAnimations[hitType], false);
- this.coinSkeleton.setCompleteListener(() => {
- this.coinSkeleton.completeListener = null;
- this.node.active = false;
- });
- }
- },
- showCoin(callback) {
- if (this.isPlaying) { return }
- if (this.hitAnimations.length > 0) {
- this.isPlaying = true;
- let hitType = Math.floor(Math.random() * this.hitAnimations.length);
- this.coinSkeleton.setAnimation(0, this.hitAnimations[hitType], false);
- setTimeout(() => {
- GameModule.audioMng.playUpdateBuilding();
- }, 200);
- this.coinSkeleton.setCompleteListener(() => {
- this.isPlaying = false;
- this.coinSkeleton.completeListener = null;
- this.node.active = false;
- if (callback) {
- callback();
- }
- });
- }
- },
- showAutoCoin(callback, finishCallback) {
- if (this.isPlaying) { return }
- if (this.hitAnimations.length > 0) {
- this.isPlaying = true;
- let hitType = Math.floor(Math.random() * this.hitAnimations.length);
- this.coinSkeleton.setAnimation(0, this.hitAnimations[hitType], false);
- this.coinSkeleton.setCompleteListener(() => {
- this.isPlaying = false;
- this.coinSkeleton.completeListener = null;
- this.node.active = false;
- if (finishCallback) {
- finishCallback();
- }
- });
- setTimeout(() => {
- if (callback) {
- callback();
- }
- }, 200);
- }
- },
- start () {
- },
- // update (dt) {},
- });
|