Commit 305b762d authored by wjf's avatar wjf

l

parent 46866bd9
......@@ -28,7 +28,7 @@ import { PassType } from '../something/enum/PassType';
import { ElementTargetData } from '../something/interface/ElementTargetData';
import { ScoreAni } from '../something/anis/ScoreAni';
import { ScoreProgress } from '../something/uis/ScoreProgress';
import { playSound, SoundType } from '../soundCtrl';
import { playSound, SoundType, toggleSound, toggleBg, getSoundOn, getBgOn } from '../soundCtrl';
import Scene from '../../libs/new_wx/components/Scene';
import { showToast } from '../../libs/new_wx/ctrls/toastCtrl';
import getResPath from '../../libs/new_tc/getResPath';
......@@ -188,11 +188,8 @@ export default class MainScene extends Scene {
this.initSvgas();
//先禁掉事件
this.enableMouseEvt(false);
this.initBuired()
// this.initBuired()
var b=new BonusShootAni();
console.log(b)
this.addChild(b)
//步数初始化
this.steps = this.chapterData.stepCount;
//分数置0
......@@ -494,11 +491,20 @@ export default class MainScene extends Scene {
this.onTap_settingBtn();
}
onTap_soundBtnn() {
toggleSound()
if(getSoundOn()){
this.soundBtn.source="mainSoundBtnOn_png"
}else{
this.soundBtn.source="mainSoundBtnOff_png"
}
}
onTap_musicBtn() {
toggleBg();
if(getBgOn()){
this.musicBtn.source="mainMusicBtnOn_png"
}else{
this.musicBtn.source="mainMusicBtnOff_png"
}
}
onTap_quitBtn() {
PanelCtrl.instance.show("quit");
......@@ -1278,6 +1284,11 @@ export default class MainScene extends Scene {
} else {
//通关了
//提交分数等
var json = this.getSubmitJson()
console.log(json)
playSound(SoundType.sucess);
//区分奖品
PanelCtrl.instance.show(ModuleTypes.PRIZE_PANEL);
}
return
}
......@@ -1285,6 +1296,9 @@ export default class MainScene extends Scene {
if (this.steps == 0) {
//判断是否有加步数的道具,有则提示是否加(加完判断死图),没有则直接结束
//失败弹框
playSound(SoundType.fail);
PanelCtrl.instance.show("failed");
} else {
//检查死图
this.warningCop = this.dieMapCheck()
......@@ -1706,9 +1720,7 @@ export default class MainScene extends Scene {
}
})
}, 150 * deltaCount)
}
}
}
/**
......@@ -1966,6 +1978,7 @@ export default class MainScene extends Scene {
/**
* 禁用与开启事件
* 暂时只禁止道具及元素的
* @param b
*/
enableMouseEvt(b: boolean) {
......
let soundOn = true;
let bgChannel: egret.SoundChannel;
let loading = false;
export const getSoundOn = () => {
return soundOn
}
export const toggleSound = () => {
soundOn = !soundOn;
if (bgChannel) {
if (!soundOn) {
bgChannel.stop();
bgChannel = null;
}
} else {
if (soundOn) {
playBg();
}
}
}
export const playBg = async () => {
if (bgChannel) return;
if (loading) return;
loading = true;
const bg = await RES.getResAsync('bgMusic_mp3');
bgChannel = bg.play();
loading = false;
}
export enum SoundType {
fall = 'fall',
magic = 'magic',
boom = 'boom',
sucess = 'sucess',
mapBg = 'mapBg',
eliminate = 'eliminate',
toast = 'toast',
fail = 'fail',
playBg = 'playBg',
line = 'line',
}
export const playSound = (type: SoundType) => {
if (!soundOn) return;
const sound: egret.Sound = RES.getRes(type + "_mp3");
if (sound)
sound.play(0, 1);
else
RES.getResAsync(type + "_mp3")
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment