123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- cc.Class({
- extends: cc.Component,
- properties: {
- labelCombo: cc.Label,
- anim: cc.Animation,
- comboColors: [cc.Color],
- showDuration: 0,
- comboActive: false
- },
-
- init (inGameUI) {
- this.inGameUI = inGameUI;
- this.comboCount = 0;
- this.node.active = false;
- this.showTimer = 0;
- this.comboScore = 1;
- },
- playCombo () {
- if(this.comboScore == 5) {
- this.comboCount++;
- this.node.active = true;
- // this.unschedule(this.hide);
- // let colorIdx = Math.min(Math.floor(this.comboCount / 10), this.comboColors.length - 1);
- // this.labelCombo.node.color = this.comboColors[colorIdx];
- this.labelCombo.string = this.comboCount;
- this.anim.play('combo-pop');
- this.showTimer = 0;
- this.comboActive = true;
- this.inGameUI.changeScoreRatio('combo');
- // this.scheduleOnce(this.hide.bind(this), this.showDuration );
- } else {
- this.comboScore++
- }
- },
- hide () {
- this.comboCount = 0;
- this.node.active = false;
- },
- update (dt) {
- if (!this.node.active) {
- return;
- }
- this.showTimer += dt;
- if (this.showTimer >= this.showDuration) {
- this.hide();
- this.comboActive = false;
- this.node.active = false;
- this.comboScore = 1;
- this.inGameUI.endScoreRatio('combo');
- }
- }
- });
|