(function() {"use strict";var __module = CC_EDITOR ? module : {exports:{}};var __filename = 'preview-scripts/assets/Script/music.js';var __require = CC_EDITOR ? function (request) {return cc.require(request, require);} : function (request) {return cc.require(request, __filename);};function __define (exports, require, module) {"use strict";
cc._RF.push(module, '9e6f4BH681Ju6yEZbJCjR+e', 'music', __filename);
// Script/music.ts

// Learn TypeScript:
//  - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/typescript.html
//  - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/typescript.html
// Learn Attribute:
//  - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
//  - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
//  - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/life-cycle-callbacks.html
Object.defineProperty(exports, "__esModule", { value: true });
var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
var NewClass = /** @class */ (function (_super) {
    __extends(NewClass, _super);
    function NewClass() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.playState = true;
        _this.autoAudioPlay = function () {
            _this.audioid = cc.audioEngine.play(_this.bgAudio, true, 1);
            _this.action = cc.repeatForever(cc.rotateBy(3, 360));
            _this.node.runAction(_this.action);
        };
        _this.playSwitch = function () {
            if (_this.playState) {
                _this.playState = false;
                // 停止一个动作
                _this.node.stopAction(_this.action);
                cc.audioEngine.pause(_this.audioid);
                cc.loader.loadRes("musicStop", cc.SpriteFrame, function (err, spriteFrame) {
                    _this.node.getComponent(cc.Sprite).spriteFrame = spriteFrame;
                });
            }
            else {
                _this.playState = true;
                // 执行动作
                _this.node.runAction(_this.action);
                cc.audioEngine.resume(_this.audioid);
                cc.loader.loadRes("music", cc.SpriteFrame, function (err, spriteFrame) {
                    _this.node.getComponent(cc.Sprite).spriteFrame = spriteFrame;
                });
            }
        };
        return _this;
    }
    NewClass.prototype.onLoad = function () {
        cc.game.addPersistRootNode(this.node);
        this.autoAudioPlay();
    };
    NewClass.prototype.onDestroy = function () {
    };
    __decorate([
        property({
            type: cc.AudioClip
        })
    ], NewClass.prototype, "bgAudio", void 0);
    NewClass = __decorate([
        ccclass
    ], NewClass);
    return NewClass;
}(cc.Component));
exports.default = NewClass;

cc._RF.pop();
        }
        if (CC_EDITOR) {
            __define(__module.exports, __require, __module);
        }
        else {
            cc.registerModuleFunc(__filename, function () {
                __define(__module.exports, __require, __module);
            });
        }
        })();
        //# sourceMappingURL=music.js.map
        