123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- const DWTool = require('../utils/DWTool');
- cc.Class({
- extends: cc.Component,
- properties: {
- coinNode: cc.Node,
- totalRateLabel: cc.Label,
- coinCount: 0,
- totalRate: {
- get: function() {
- if (!this._totalRate) {
- this._totalRate = 0;
- }
- return this._totalRate;
- },
- set: function(value) {
- this._totalRate = value;
- this.totalRateLabel.string = DWTool.coinParse(this._totalRate);
- }
- },
- coinSpine: sp.Skeleton,
-
- isPlay: false,
- isPlaying: false,
- index: 0,
-
- },
-
- onLoad () {
- },
- getOwner() {
- return this.node;
- },
-
- initStatic(coinIndex) {
- let animKeyArray = ['jinbi_1', 'jinbi_2', 'jinbi_3'];
- let animKey;
- if(coinIndex <= animKeyArray.length - 1) {
- animKey = animKeyArray[coinIndex]
- } else {
- animKey = coinIndex % animKeyArray.length;
- }
-
- this.coinSpine.setAnimation(0, animKey, true)
- },
-
- initAnim() {
- let animKeyArray = ['jinbi_zhuangdong1', 'jinbi_zhuangdong2', 'jinbi_zhuangdong3']
-
- let ran = Math.floor(Math.random() * 3);
- let animKey = animKeyArray[ran]
- this.totalRateLabel.node.active = false;
- this.coinSpine.setAnimation(0, animKey, true)
- },
- showAnimation() {
-
- if (this.isPlaying) { return; }
- this.node.stopAllActions();
- this.node.active = true;
- this.isPlayed = true;
- this.isPlaying = true;
- let jumpHeight = 175;
- let duration = 0.3;
- let animationArray = [];
- let moveAction1 = cc.moveBy(duration, 0, jumpHeight).easing(cc.easeCubicActionOut());
- let moveAction2 = cc.moveBy(duration, 0, -95).easing(cc.easeCubicActionIn());
- animationArray.push(moveAction1);
- animationArray.push(moveAction2);
- while(jumpHeight > 0.1) {
- jumpHeight = jumpHeight - (jumpHeight / 3);
- duration = duration - (duration / 3);
- let upAction = cc.moveBy(duration, 0, jumpHeight).easing(cc.easeCubicActionOut());
- let downAction = cc.moveBy(duration, 0, -jumpHeight).easing(cc.easeCubicActionIn());
- animationArray.push(upAction);
- animationArray.push(downAction);
- }
- let callback = cc.callFunc(() => {
- this.isPlaying = false;
- });
- animationArray.push(callback);
- this.node.runAction(cc.sequence(animationArray));
- },
- updateAnimation() {
- if (this.isPlaying) { return; }
- this.node.stopAllActions();
-
- this.isPlaying = true;
- let upAction = cc.moveBy(0.1, 0, 30);
- let downAction = cc.moveBy(0.1, 0, -30);
- let callback = cc.callFunc(() => {
- this.isPlaying = false;
- });
- this.coinNode.runAction(cc.sequence(upAction, downAction, callback));
- },
- start () {
- },
-
- });
|