1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- let Global = require("Global");
- cc.Class({
- extends: cc.Component,
- properties: {
- sfxToggle: cc.Toggle,
- bgmToggle: cc.Toggle,
- shakeToggle: cc.Toggle,
- },
- onLoad() {
- this.isPlayBGM = false;
- this.bgmVolume = parseFloat(Global.getLocalStorageVaule("bgmVolume", 0.5));//.toFixed(1);
- this.sfxVolume = parseFloat(Global.getLocalStorageVaule("sfxVolume", 0.5));//.toFixed(1);
- this.shakeOpen = parseFloat(Global.getLocalStorageVaule("shakeOpen", 0));//.toFixed(1);
- this.sfxToggle.isChecked = this.sfxVolume != 0;
- this.bgmToggle.isChecked = this.bgmVolume != 0;
- this.shakeToggle.isChecked = this.shakeOpen != 0;
- },
- playButton() {
- this.playEffec("click");
- },
- playJump() {
- this.playEffec("clickjump");
- },
- playBGM() {
- this.isPlayBGM = true;
- this.playMusic("crashBgm", true);
- },
- playBoom() {
- this.playEffec("rocketBoom");
- },
- playStart() {
- this.playEffec("rocketStart");
- },
- playTimeDown() {
- this.isPlayBGM = false;
- this.playMusic("timedown", false);
- },
- playEffec(name) {
- if (cc.vv && cc.vv.audioMgr) {
- cc.vv.audioMgr.playSFX(name);
- }
- },
- playMusic(name, bool) {
- if (cc.vv && cc.vv.audioMgr) {
- cc.vv.audioMgr.playBGM(name, bool);
- }
- },
- clickSFX() {
- this.playButton();
- if (cc.vv.audioMgr.sfxVolume > 0) {
- cc.vv.audioMgr.setSFXVolume(0, false, true);
- } else {
- cc.vv.audioMgr.setSFXVolume(1, false, true);
- }
- },
- clickBGM() {
- this.playButton();
- if (cc.vv.audioMgr.bgmVolume > 0) {
- cc.vv.audioMgr.setBGMVolume(0, false, true);
- } else {
- cc.vv.audioMgr.setBGMVolume(1, false, true);
- }
- },
- clickShake() {
- this.playButton();
- if (cc.vv.audioMgr.shakeOpen > 0) {
- cc.vv.audioMgr.setShakeOpen(0);
- } else {
- cc.vv.audioMgr.setShakeOpen(1);
- }
- },
- });
|