12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- cc.Class({
- extends: cc.Component,
- properties: {
- Time:90,
- intervalTime:90,
- progressbar:null,
- progress:1,
- Success:cc.Node,
- GameOver:cc.Node,
- Store:cc.Node,
- },
- onLoad: function () {
- Audio.playmusic('resources/audio/music_bg.mp3');
- },
- // use this for initialization
- //cc.director.pause()
-
- //cc.director.resume()
- start: function () {
- //this.Time = Global.LevelTime;
- //this.intervalTime =Global.LevelTime;
- this.progressbar = cc.find('Canvas/ProgressBar');
- this.progress = this.progressbar.getComponent(cc.ProgressBar);
- },
- // called every frame
- update: function (dt) {
- if(this.Success.active == true){
- return;
- }
- if(this.Store.active == true){
- return;
- }
- if (this.intervalTime >= 0 ) {
- this.intervalTime -= dt;
- this.progress.progress =this.intervalTime/this.Time;
- }else{
- //console.log('游戏结束');
- //cc.director.pause();
- if(this.GameOver.active == false){
- cc.audioEngine.stopMusic();
- Audio.playeffect('resources/audio/sound_lose.ogg');
- }
- this.GameOver.active = true;
- }
-
- },
- });
|