12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- const Global = require("Global");
- var SoundFun = require("TrucoSoundFun");
- cc.Class({
- extends: cc.Component,
- properties: {
-
- _countdown:0,
- _totalTime:0,
- },
- onLoad: function(){
- this.node.active = false;
- },
- getNowTimeColor(times) {
- if(times <= 6) {
- return new cc.color(255, 30, 0);
- }else if(times <= 9) {
- return new cc.color(255, 144, 0);
- }else if(times <= 12) {
- return new cc.color(230, 255, 0);
- }else{
- return new cc.color(0, 255, 31);
- }
- },
- stopTimeSchedule: function(show){
- if (this.timeCallback != null)
- {
- this.unschedule(this.timeCallback);
- this.timeCallback = null;
- }
- if(show){
- this.node.active = true;
- }else{
- this.node.active = false;
- }
- },
- playTimeAction: function(UserLeftTime, bSelf){
- this.node.active = true;
- this._countdown = UserLeftTime;
-
- let timeLabel = this.node.getChildByName("TimeSprite").getChildByName("time").getComponent(cc.Label);
- timeLabel.string = this._countdown;
- var self = this
- this.timeCallback = function(){
- if(self._countdown <= 0){
- self.stopTimeSchedule(false);
- return;
- }
- self._countdown--;
- if(self._countdown < 0){
- self._countdown = 0;
- }
- if(self._countdown <= 5) {
- SoundFun.playEffectEX(SoundFun.EX_COUNTDOWN);
- }
- timeLabel.string = self._countdown;
- }
- this.unschedule(this.timeCallback);
- this.schedule(this.timeCallback,1);
- },
- start () {
-
- },
-
- });
|