| 123456789101112131415161718192021222324252627282930313233343536 |
- cc.Class({
- extends: cc.Component,
- properties: {
- },
- countDown(callback)
- {
- this.node.opacity = 255;
- this.callback = callback;
- this.currentCount = 3;
- this.counting();
- },
- counting()
- {
- let Self = this;
- cc.loader.loadRes("Audios/Game/Nums/"+this.currentCount, cc.AudioClip, (err, audioClip)=> {
- Self.node.getComponent(cc.Label).string = Self.currentCount;
- Self.currentAudio = cc.audioEngine.play(audioClip, false, 1);
- cc.audioEngine.setFinishCallback(Self.currentAudio, function () {
- if(Self.currentCount == 1)
- {
- Self.currentCount = 3;
- Self.node.opacity = 0;
- Self.callback();
- return;
- }
- Self.currentCount--;
- Self.counting();
- });
- });
- }
- });
|