Commit 0a30bf35 authored by liujiangnan's avatar liujiangnan

fix: 全局变量

parent f22f9236
...@@ -33,7 +33,7 @@ var game = cc.Class({ ...@@ -33,7 +33,7 @@ var game = cc.Class({
ctor: function () { ctor: function () {
game.inst = this; game.inst = this;
g.game = game; LWD_3.game = game;
}, },
// 生命周期 onLoad // 生命周期 onLoad
...@@ -51,13 +51,13 @@ var game = cc.Class({ ...@@ -51,13 +51,13 @@ var game = cc.Class({
//屏幕缩放 //屏幕缩放
scaleEventCallBack: function () { scaleEventCallBack: function () {
g.event_mgr.send("adjustUI"); LWD_3.event_mgr.send("adjustUI");
}, },
//初始化游戏 //初始化游戏
initGame: function () { initGame: function () {
//获得数据 //获得数据
g.res_mgr.getFormData(); LWD_3.res_mgr.getFormData();
}, },
setAABB() { setAABB() {
...@@ -96,10 +96,10 @@ var game = cc.Class({ ...@@ -96,10 +96,10 @@ var game = cc.Class({
//添加节点 //添加节点
addItem: function () { addItem: function () {
let itemArr = g.data_mgr.getQuestionOneList(g.data_mgr.quesId); let itemArr = LWD_3.data_mgr.getQuestionOneList(LWD_3.data_mgr.quesId);
itemArr.sort(function () { return Math.random() > 0.5 ? -1 : 1; }) itemArr.sort(function () { return Math.random() > 0.5 ? -1 : 1; })
g.data_mgr.nowNum = 0; LWD_3.data_mgr.nowNum = 0;
for (var i = 0; i < itemArr.length; i++) { for (var i = 0; i < itemArr.length; i++) {
let newItem = cc.instantiate(this.Item); let newItem = cc.instantiate(this.Item);
...@@ -109,7 +109,7 @@ var game = cc.Class({ ...@@ -109,7 +109,7 @@ var game = cc.Class({
com.updateUI(itemInfo); com.updateUI(itemInfo);
newItem.active = true; newItem.active = true;
if (itemInfo.is_right == true) { if (itemInfo.is_right == true) {
g.data_mgr.nowNum += 1; LWD_3.data_mgr.nowNum += 1;
} }
newItem.getChildByName("item").is_right = itemInfo.is_right; newItem.getChildByName("item").is_right = itemInfo.is_right;
...@@ -123,7 +123,7 @@ var game = cc.Class({ ...@@ -123,7 +123,7 @@ var game = cc.Class({
// this.playLionDragon("openmouth") // this.playLionDragon("openmouth")
this.playCatDragon("begin") this.playCatDragon("begin")
g.speaker.inst.playEffect(g.enum.E_Audio.CatHint); LWD_3.speaker.inst.playEffect(LWD_3.enum.E_Audio.CatHint);
for (var i = 0; i < this.contentArr.childrenCount; i++) { for (var i = 0; i < this.contentArr.childrenCount; i++) {
cc.tween(this.contentArr.children[i].children[0]) cc.tween(this.contentArr.children[i].children[0])
.to(0.1, { x: -50 }) .to(0.1, { x: -50 })
...@@ -136,9 +136,9 @@ var game = cc.Class({ ...@@ -136,9 +136,9 @@ var game = cc.Class({
//隐藏剩余物品并跳转下一题 //隐藏剩余物品并跳转下一题
resetQues: function () { resetQues: function () {
if (g.data_mgr.quesId >= 4) { if (LWD_3.data_mgr.quesId >= 4) {
this.finish(); this.finish();
g.data_mgr.gameState = 2 LWD_3.data_mgr.gameState = 2
} else { } else {
for (var i = 0; i < this.contentArr.childrenCount; i++) { for (var i = 0; i < this.contentArr.childrenCount; i++) {
cc.tween(this.contentArr.children[i].children[0]) cc.tween(this.contentArr.children[i].children[0])
...@@ -157,14 +157,14 @@ var game = cc.Class({ ...@@ -157,14 +157,14 @@ var game = cc.Class({
this.playLionDragon("normal") this.playLionDragon("normal")
this.playCatDragon("finish") this.playCatDragon("finish")
setTimeout(() => { setTimeout(() => {
g.speaker.inst.playEffect(g.enum.E_Audio.CatComplete); LWD_3.speaker.inst.playEffect(LWD_3.enum.E_Audio.CatComplete);
}, 500) }, 500)
}, },
//检测放到哪个节点底下 //检测放到哪个节点底下
checkNodeParent: function () { checkNodeParent: function () {
//获取到总列表 //获取到总列表
var itemArr = g.data_mgr.getSheepArr(); var itemArr = LWD_3.data_mgr.getSheepArr();
// //
if (itemArr.length <= 7) { if (itemArr.length <= 7) {
...@@ -177,8 +177,8 @@ var game = cc.Class({ ...@@ -177,8 +177,8 @@ var game = cc.Class({
//检查类别 //检查类别
checkType: function (Id) { checkType: function (Id) {
for (var i in g.data_mgr.getSheepfoldArr()) { for (var i in LWD_3.data_mgr.getSheepfoldArr()) {
var sheepfoldInfo = g.data_mgr.getSheepfoldArr()[i]; var sheepfoldInfo = LWD_3.data_mgr.getSheepfoldArr()[i];
if (Id == sheepfoldInfo.id) { if (Id == sheepfoldInfo.id) {
return ~~i + 1; return ~~i + 1;
} }
...@@ -188,13 +188,13 @@ var game = cc.Class({ ...@@ -188,13 +188,13 @@ var game = cc.Class({
//更新界面信息 //更新界面信息
UpdataUi: function () { UpdataUi: function () {
g.data_mgr.gameState == 1; LWD_3.data_mgr.gameState == 1;
var Info = { var Info = {
tex_json: g.data_mgr.data.tex_json, tex_json: LWD_3.data_mgr.data.tex_json,
ske_json: g.data_mgr.data.ske_json, ske_json: LWD_3.data_mgr.data.ske_json,
tex_png: g.data_mgr.data.tex_png, tex_png: LWD_3.data_mgr.data.tex_png,
} }
g.res_mgr.loadSpine(this.dragonLion, Info); LWD_3.res_mgr.loadSpine(this.dragonLion, Info);
//刚进入课件 //刚进入课件
//播放第一题题干 //播放第一题题干
...@@ -205,7 +205,7 @@ var game = cc.Class({ ...@@ -205,7 +205,7 @@ var game = cc.Class({
//播放题干 //播放题干
this.playAudioTitle(); this.playAudioTitle();
// g.speaker.inst.playEffect(E_Audio.BtnCommom); // LWD_3.speaker.inst.playEffect(E_Audio.BtnCommom);
//重置UI界面 //重置UI界面
this.resetUI(); this.resetUI();
...@@ -230,11 +230,11 @@ var game = cc.Class({ ...@@ -230,11 +230,11 @@ var game = cc.Class({
//播放题干 //播放题干
playAudioTitle: function () { playAudioTitle: function () {
if (g.data_mgr.quesId >= 4) return if (LWD_3.data_mgr.quesId >= 4) return
//获得播放路径 //获得播放路径
var path = g.data_mgr.getQuestionStem(g.data_mgr.quesId); var path = LWD_3.data_mgr.getQuestionStem(LWD_3.data_mgr.quesId);
g.res_mgr.playAudioByUrl(path, (url) => { LWD_3.res_mgr.playAudioByUrl(path, (url) => {
g.snd_mgr.playEffect(url, () => { LWD_3.snd_mgr.playEffect(url, () => {
//结束回调 //结束回调
this.playCatDragon("normal"); this.playCatDragon("normal");
}); });
...@@ -249,17 +249,17 @@ var game = cc.Class({ ...@@ -249,17 +249,17 @@ var game = cc.Class({
//重新开始 //重新开始
onBtnReStart: function () { onBtnReStart: function () {
g.speaker.inst.play_btn(); LWD_3.speaker.inst.play_btn();
//移除所有计时器 //移除所有计时器
this.unscheduleAllCallbacks(); this.unscheduleAllCallbacks();
//初始化界面 //初始化界面
this.UpdataUi(); this.UpdataUi();
g.speaker.inst.play_restart(); LWD_3.speaker.inst.play_restart();
}, },
//游戏开始 //游戏开始
gameStart: function () { gameStart: function () {
console.log("游戏开始:" + g.data_mgr); console.log("游戏开始:" + LWD_3.data_mgr);
//播放一个上面的音乐 //播放一个上面的音乐
this.setAudioInfo(1); this.setAudioInfo(1);
}, },
...@@ -267,20 +267,20 @@ var game = cc.Class({ ...@@ -267,20 +267,20 @@ var game = cc.Class({
//设置上下页按钮状态 //设置上下页按钮状态
setButtonState: function () { setButtonState: function () {
//先判断题目长度 //先判断题目长度
if (g.data_mgr.data.contentObj.pageArr.length < 2) { if (LWD_3.data_mgr.data.contentObj.pageArr.length < 2) {
this.btnList[0].node.active = false; this.btnList[0].node.active = false;
this.btnList[1].node.active = false; this.btnList[1].node.active = false;
} else { } else {
//如果第一页 //如果第一页
if (g.data_mgr.pageId == 0) { if (LWD_3.data_mgr.pageId == 0) {
this.btnList[1].node.active = true; this.btnList[1].node.active = true;
this.btnList[0].node.active = false; this.btnList[0].node.active = false;
} }
if (g.data_mgr.pageId == g.data_mgr.data.contentObj.pageArr.length - 1) { if (LWD_3.data_mgr.pageId == LWD_3.data_mgr.data.contentObj.pageArr.length - 1) {
this.btnList[0].node.active = true; this.btnList[0].node.active = true;
this.btnList[1].node.active = false; this.btnList[1].node.active = false;
} }
if (g.data_mgr.pageId > 0 && g.data_mgr.pageId < g.data_mgr.data.contentObj.pageArr.length - 1) { if (LWD_3.data_mgr.pageId > 0 && LWD_3.data_mgr.pageId < LWD_3.data_mgr.data.contentObj.pageArr.length - 1) {
this.btnList[0].node.active = true; this.btnList[0].node.active = true;
this.btnList[1].node.active = true; this.btnList[1].node.active = true;
} }
...@@ -289,29 +289,29 @@ var game = cc.Class({ ...@@ -289,29 +289,29 @@ var game = cc.Class({
//下一关 //下一关
onBtnNextQues: function () { onBtnNextQues: function () {
g.data_mgr.time = 0; LWD_3.data_mgr.time = 0;
g.speaker.inst.playEffect(g.enum.E_Audio.BtnCommom); LWD_3.speaker.inst.playEffect(LWD_3.enum.E_Audio.BtnCommom);
g.data_mgr.quesId += 1; LWD_3.data_mgr.quesId += 1;
g.game.inst.resetQues(); LWD_3.game.inst.resetQues();
}, },
//重新开始 //重新开始
onBtnReStart() { onBtnReStart() {
g.data_mgr.time = 0; LWD_3.data_mgr.time = 0;
g.data_mgr.resetQuestion(); LWD_3.data_mgr.resetQuestion();
g.speaker.inst.playEffect(g.enum.E_Audio.BtnCommom); LWD_3.speaker.inst.playEffect(LWD_3.enum.E_Audio.BtnCommom);
g.data_mgr.quesId = 0; LWD_3.data_mgr.quesId = 0;
this.UpdataUi(); this.UpdataUi();
}, },
//上一关 //上一关
onBtnLastPage: function () { onBtnLastPage: function () {
g.speaker.inst.play_btn(); LWD_3.speaker.inst.play_btn();
if (g.data_mgr.pageId - 1 >= 0) { if (LWD_3.data_mgr.pageId - 1 >= 0) {
g.data_mgr.pageId -= 1; LWD_3.data_mgr.pageId -= 1;
this.setButtonState(); this.setButtonState();
this.onBtnReStart(); this.onBtnReStart();
} }
...@@ -319,10 +319,10 @@ var game = cc.Class({ ...@@ -319,10 +319,10 @@ var game = cc.Class({
//下一关 //下一关
onBtnNextPage: function () { onBtnNextPage: function () {
g.speaker.inst.play_btn(); LWD_3.speaker.inst.play_btn();
if (g.data_mgr.pageId + 1 < g.data_mgr.data.contentObj.pageArr.length) { if (LWD_3.data_mgr.pageId + 1 < LWD_3.data_mgr.data.contentObj.pageArr.length) {
g.data_mgr.pageId += 1; LWD_3.data_mgr.pageId += 1;
this.setButtonState(); this.setButtonState();
this.onBtnReStart(); this.onBtnReStart();
} }
......
// 全局环境预声明 // 全局环境预声明
window.g = window.g || {}; // 全局 window.LWD_3 = window.LWD_3 || {}; // 全局
\ No newline at end of file \ No newline at end of file
...@@ -14,7 +14,7 @@ var eff_well = cc.Class({ ...@@ -14,7 +14,7 @@ var eff_well = cc.Class({
ctor: function () { ctor: function () {
eff_well.inst = this; eff_well.inst = this;
g.eff_well = eff_well; LWD_3.eff_well = eff_well;
}, },
//显示特效 //显示特效
...@@ -22,7 +22,7 @@ var eff_well = cc.Class({ ...@@ -22,7 +22,7 @@ var eff_well = cc.Class({
this.node.active = true; this.node.active = true;
this.eff_welldown.play(); this.eff_welldown.play();
//播放撒花音效 //播放撒花音效
g.speaker.inst.play_congratulation(); LWD_3.speaker.inst.play_congratulation();
setTimeout(() => { setTimeout(() => {
this.node.active = false; this.node.active = false;
}, 2000) }, 2000)
......
g.utils = { LWD_3.utils = {
// 范围随机 // 范围随机
randFromTo: function (_min, _max) { randFromTo: function (_min, _max) {
var min = parseFloat(_min); var min = parseFloat(_min);
......
...@@ -65,7 +65,7 @@ cc.Class({ ...@@ -65,7 +65,7 @@ cc.Class({
} }
}, 0); }, 0);
g.event_mgr.reg("adjustUI", () => { LWD_3.event_mgr.reg("adjustUI", () => {
this.setBgScale(); this.setBgScale();
this.setUiPositon(); this.setUiPositon();
}); });
...@@ -89,7 +89,7 @@ cc.Class({ ...@@ -89,7 +89,7 @@ cc.Class({
var h = (canvaSize.height) / HEIGTH; var h = (canvaSize.height) / HEIGTH;
this.MaxSize = w / h > 1 ? w / h : h / w; this.MaxSize = w / h > 1 ? w / h : h / w;
g.data_mgr.MaxSize = this.MaxSize; LWD_3.data_mgr.MaxSize = this.MaxSize;
this.setUIMax(this.MaxSize); this.setUIMax(this.MaxSize);
this.settopUI(this.MaxSize); this.settopUI(this.MaxSize);
this.setBgScale(); this.setBgScale();
...@@ -102,13 +102,13 @@ cc.Class({ ...@@ -102,13 +102,13 @@ cc.Class({
}, },
onDestroy: function () { onDestroy: function () {
g.event_pump.unReg("adjustUI"); LWD_3.event_pump.unReg("adjustUI");
}, },
settopUI: function (s) { settopUI: function (s) {
if (!g.data_mgr.phoneInfo) { if (!LWD_3.data_mgr.phoneInfo) {
return; return;
} }
var top = g.data_mgr.phoneInfo; var top = LWD_3.data_mgr.phoneInfo;
top = top * s; top = top * s;
for (var i in this.topUI) { for (var i in this.topUI) {
if (this.topUI[i].perTop == undefined) { if (this.topUI[i].perTop == undefined) {
......
...@@ -15,14 +15,14 @@ var effect = cc.Class({ ...@@ -15,14 +15,14 @@ var effect = cc.Class({
ctor: function () { ctor: function () {
effect.inst = this; effect.inst = this;
g.effect = effect; LWD_3.effect = effect;
}, },
showEffect: function () { showEffect: function () {
const bg = cc.find('Canvas/bg/connent'); const bg = cc.find('Canvas/bg/connent');
this.showAllFirework(bg, cc.find('paperBase').children); this.showAllFirework(bg, cc.find('paperBase').children);
g.speaker.inst.play_congratulation(); LWD_3.speaker.inst.play_congratulation();
}, },
showEffect2: function () { showEffect2: function () {
......
g.enum = { LWD_3.enum = {
E_Audio: { E_Audio: {
AllPop: 0,//全部弹出 AllPop: 0,//全部弹出
BtnCommom: 1,//按钮 BtnCommom: 1,//按钮
......
...@@ -26,7 +26,7 @@ var TouchDragger = cc.Class({ ...@@ -26,7 +26,7 @@ var TouchDragger = cc.Class({
}, },
ctor: function () { ctor: function () {
TouchDragger.inst = this; TouchDragger.inst = this;
g.TouchDragger = TouchDragger; LWD_3.TouchDragger = TouchDragger;
}, },
onLoad: function () { onLoad: function () {
this.arMap = []; this.arMap = [];
...@@ -36,7 +36,7 @@ var TouchDragger = cc.Class({ ...@@ -36,7 +36,7 @@ var TouchDragger = cc.Class({
this.isFirstMove = true; this.isFirstMove = true;
//初始化格子数据 //初始化格子数据
this.initGridInfo(g.data_mgr.challengeData.IngredientList); this.initGridInfo(LWD_3.data_mgr.challengeData.IngredientList);
}, },
start: function () { start: function () {
......
...@@ -30,14 +30,14 @@ cc.Class({ ...@@ -30,14 +30,14 @@ cc.Class({
//触摸开始 //触摸开始
touchBegan: function (event) { touchBegan: function (event) {
g.data_mgr.gameState = 2; LWD_3.data_mgr.gameState = 2;
g.data_mgr.time = 0; LWD_3.data_mgr.time = 0;
//狮子猫动画 //狮子猫动画
g.game.inst.playLionDragon("openmouth"); LWD_3.game.inst.playLionDragon("openmouth");
g.res_mgr.playAudioByUrl(this.itemInfo.audio_url, (url) => { LWD_3.res_mgr.playAudioByUrl(this.itemInfo.audio_url, (url) => {
g.snd_mgr.playEffect(url, null); LWD_3.snd_mgr.playEffect(url, null);
}); });
this.m_touchTime = 0; this.m_touchTime = 0;
...@@ -47,8 +47,8 @@ cc.Class({ ...@@ -47,8 +47,8 @@ cc.Class({
this.m_touchTime += 1; this.m_touchTime += 1;
if (this.m_touchTime >= 3) { if (this.m_touchTime >= 3) {
this.m_touchTime = 0; this.m_touchTime = 0;
g.res_mgr.playAudioByUrl(this.itemInfo.audio_url, (url) => { LWD_3.res_mgr.playAudioByUrl(this.itemInfo.audio_url, (url) => {
g.snd_mgr.playEffect(url, null); LWD_3.snd_mgr.playEffect(url, null);
}); });
} }
}, 1000) }, 1000)
...@@ -75,9 +75,9 @@ cc.Class({ ...@@ -75,9 +75,9 @@ cc.Class({
touchEnd: function (event) { touchEnd: function (event) {
clearInterval(this.timer); clearInterval(this.timer);
//暂停音效 //暂停音效
g.snd_mgr.pauseVolume(); LWD_3.snd_mgr.pauseVolume();
g.data_mgr.gameState = 1; LWD_3.data_mgr.gameState = 1;
//获得世界坐标 //获得世界坐标
var posScreen = event.getLocation(); //点击事件获取位置 var posScreen = event.getLocation(); //点击事件获取位置
var posNode = this.node.convertToNodeSpaceAR(posScreen); var posNode = this.node.convertToNodeSpaceAR(posScreen);
...@@ -94,7 +94,7 @@ cc.Class({ ...@@ -94,7 +94,7 @@ cc.Class({
} }
//获得俩个节点的世界坐标 //获得俩个节点的世界坐标
var contentArrPos = g.game.inst.setAABB(); var contentArrPos = LWD_3.game.inst.setAABB();
// 获取 ScrollView Node 的左下角坐标在世界坐标系中的坐标 // 获取 ScrollView Node 的左下角坐标在世界坐标系中的坐标
let svLeftBottomPoint = this.node.parent.convertToWorldSpaceAR( let svLeftBottomPoint = this.node.parent.convertToWorldSpaceAR(
...@@ -128,37 +128,37 @@ cc.Class({ ...@@ -128,37 +128,37 @@ cc.Class({
setItemState: function () { setItemState: function () {
this.node.isComplent = true; this.node.isComplent = true;
this.node.active = false; this.node.active = false;
g.data_mgr.nowNum -= 1; LWD_3.data_mgr.nowNum -= 1;
//狮子猫动画 //狮子猫动画
g.game.inst.playLionDragon("chew"); LWD_3.game.inst.playLionDragon("chew");
//先播放错误声音 //先播放错误声音
g.speaker.inst.playEffect(g.enum.E_Audio.Right); LWD_3.speaker.inst.playEffect(LWD_3.enum.E_Audio.Right);
setTimeout(() => { setTimeout(() => {
g.game.inst.playCatDragon("right"); LWD_3.game.inst.playCatDragon("right");
let num = g.utils.randFromTo_Int(g.enum.E_Audio.CatRight1, g.enum.E_Audio.CatRight2); let num = LWD_3.utils.randFromTo_Int(LWD_3.enum.E_Audio.CatRight1, LWD_3.enum.E_Audio.CatRight2);
//先播放错误声音 //先播放错误声音
g.speaker.inst.playEffect(num); LWD_3.speaker.inst.playEffect(num);
//当前关卡是否结束 //当前关卡是否结束
if (g.data_mgr.nowNum <= 0) { if (LWD_3.data_mgr.nowNum <= 0) {
g.data_mgr.quesId += 1; LWD_3.data_mgr.quesId += 1;
g.game.inst.resetQues(); LWD_3.game.inst.resetQues();
} }
}, 500) }, 500)
// g.data_mgr.nowNum -= 1; // LWD_3.data_mgr.nowNum -= 1;
// if (g.data_mgr.nowNum == 0) { // if (LWD_3.data_mgr.nowNum == 0) {
// setTimeout(() => { // setTimeout(() => {
// g.effect.inst.showEffect2(); // LWD_3.effect.inst.showEffect2();
// }, 500) // }, 500)
// } // }
// var newItem_temp = cc.instantiate(g.game.inst.Item_0[2]); // var newItem_temp = cc.instantiate(LWD_3.game.inst.Item_0[2]);
// content.getChildByName("db").active = true; // content.getChildByName("db").active = true;
// content.getChildByName("db").getComponent(dragonBones.ArmatureDisplay).playAnimation("newAnimation", 1); // content.getChildByName("db").getComponent(dragonBones.ArmatureDisplay).playAnimation("newAnimation", 1);
...@@ -174,11 +174,11 @@ cc.Class({ ...@@ -174,11 +174,11 @@ cc.Class({
errorEffect: function () { errorEffect: function () {
//狮子猫动画 //狮子猫动画
g.game.inst.playCatDragon("wrong"); LWD_3.game.inst.playCatDragon("wrong");
g.game.inst.playLionDragon("no"); LWD_3.game.inst.playLionDragon("no");
//先播放错误声音 //先播放错误声音
g.speaker.inst.playEffect(g.enum.E_Audio.Error); LWD_3.speaker.inst.playEffect(LWD_3.enum.E_Audio.Error);
cc.tween(this.node) cc.tween(this.node)
.to(0.1, { scaleY: 0.9, scaleX: 1.1 }) .to(0.1, { scaleY: 0.9, scaleX: 1.1 })
...@@ -190,14 +190,14 @@ cc.Class({ ...@@ -190,14 +190,14 @@ cc.Class({
this.node.x = 0; this.node.x = 0;
this.node.y = 0; this.node.y = 0;
let num = g.utils.randFromTo_Int(g.enum.E_Audio.CatError1, g.enum.E_Audio.CatError2); let num = LWD_3.utils.randFromTo_Int(LWD_3.enum.E_Audio.CatError1, LWD_3.enum.E_Audio.CatError2);
//先播放错误声音 //先播放错误声音
g.speaker.inst.playEffect(num, () => { LWD_3.speaker.inst.playEffect(num, () => {
g.game.inst.playCatDragon("normal"); LWD_3.game.inst.playCatDragon("normal");
}); });
g.game.inst.playCatDragon("wrong"); LWD_3.game.inst.playCatDragon("wrong");
g.game.inst.playLionDragon("normal"); LWD_3.game.inst.playLionDragon("normal");
}, 500) }, 500)
}, },
...@@ -210,7 +210,7 @@ cc.Class({ ...@@ -210,7 +210,7 @@ cc.Class({
this.node.y = 0; this.node.y = 0;
this.isMove = false; this.isMove = false;
g.data_mgr.gameState = 1; LWD_3.data_mgr.gameState = 1;
}, },
...@@ -252,9 +252,9 @@ cc.Class({ ...@@ -252,9 +252,9 @@ cc.Class({
//初始化信息 //初始化信息
InitData: function () { InitData: function () {
//设置图片 //设置图片
g.res_mgr.getSpriteFrimeByUrl(this.itemInfo.pic_url, (list) => { LWD_3.res_mgr.getSpriteFrimeByUrl(this.itemInfo.pic_url, (list) => {
this.Item_photo.getComponent(cc.Sprite).spriteFrame = list; this.Item_photo.getComponent(cc.Sprite).spriteFrame = list;
this.photoScare(this.Item_photo, g.game.inst.idx); this.photoScare(this.Item_photo, LWD_3.game.inst.idx);
// this.photoScare(this.nodeState[2].getChildByName("spt_item"), 1); // this.photoScare(this.nodeState[2].getChildByName("spt_item"), 1);
}); });
//设置名字 //设置名字
......
...@@ -95,49 +95,49 @@ var speaker = cc.Class({ ...@@ -95,49 +95,49 @@ var speaker = cc.Class({
ctor: function () { ctor: function () {
speaker.inst = this; speaker.inst = this;
g.speaker = speaker; LWD_3.speaker = speaker;
}, },
//播放音效 //播放音效
playEffect: function (num, cb) { playEffect: function (num, cb) {
g.snd_mgr.playEffect(this.eff_audio[num], cb); LWD_3.snd_mgr.playEffect(this.eff_audio[num], cb);
}, },
// //点击按钮 // //点击按钮
// play_btn: function () { // play_btn: function () {
// g.snd_mgr.playEffect(this.eff_btn); // LWD_3.snd_mgr.playEffect(this.eff_btn);
// }, // },
// //撒花音效 // //撒花音效
// play_congratulation: function () { // play_congratulation: function () {
// g.snd_mgr.playEffect(this.eff_congratulation); // LWD_3.snd_mgr.playEffect(this.eff_congratulation);
// }, // },
// //答错 // //答错
// play_error: function () { // play_error: function () {
// g.snd_mgr.playEffect(this.eff_error); // LWD_3.snd_mgr.playEffect(this.eff_error);
// }, // },
// //答对 // //答对
// play_good: function (cb) { // play_good: function (cb) {
// g.snd_mgr.playEffect(this.eff_good, cb); // LWD_3.snd_mgr.playEffect(this.eff_good, cb);
// }, // },
// //显示弹窗 // //显示弹窗
// play_showPop: function () { // play_showPop: function () {
// g.snd_mgr.playEffect(this.eff_showPop); // LWD_3.snd_mgr.playEffect(this.eff_showPop);
// }, // },
// //游戏开始 // //游戏开始
// play_start: function (cb) { // play_start: function (cb) {
// g.snd_mgr.playEffect(this.eff_start, cb); // LWD_3.snd_mgr.playEffect(this.eff_start, cb);
// }, // },
// //拉开窗帘 // //拉开窗帘
// play_open: function () { // play_open: function () {
// g.snd_mgr.playEffect(this.eff_open); // LWD_3.snd_mgr.playEffect(this.eff_open);
// }, // },
// //重新开始 // //重新开始
// play_restart: function () { // play_restart: function () {
// g.snd_mgr.playEffect(this.eff_restart); // LWD_3.snd_mgr.playEffect(this.eff_restart);
// }, // },
}); });
/** /**
* 数据管理器 * 数据管理器
*/ */
g.data_mgr = { LWD_3.data_mgr = {
data: null,//表所有数据 data: null,//表所有数据
quesId: 0,//题目id quesId: 0,//题目id
nowNum: 0,//剩余正确数量 nowNum: 0,//剩余正确数量
...@@ -54,7 +54,7 @@ g.data_mgr = { ...@@ -54,7 +54,7 @@ g.data_mgr = {
resetQuestion() { resetQuestion() {
for (var i in this.data.question_arr) { for (var i in this.data.question_arr) {
if (i % 2 == 0) { if (i % 2 == 0) {
let num = g.utils.randFromTo_Int(0, 1); let num = LWD_3.utils.randFromTo_Int(0, 1);
if (num == 0 && this.data.question_arr[~~i + 1]) { if (num == 0 && this.data.question_arr[~~i + 1]) {
let swap = (arr, i, j) => { let swap = (arr, i, j) => {
[arr[i], arr[j]] = [arr[j], arr[i]]; [arr[i], arr[j]] = [arr[j], arr[i]];
...@@ -143,26 +143,26 @@ g.data_mgr = { ...@@ -143,26 +143,26 @@ g.data_mgr = {
} else { } else {
this.loadEnd(); this.loadEnd();
} }
cc.debug.setDisplayStats(false); cc.debuLWD_3.setDisplayStats(false);
}); });
}, },
loadEnd() { loadEnd() {
//更新游戏界面信息 //更新游戏界面信息
g.game.inst.UpdataUi(); LWD_3.game.inst.UpdataUi();
clearInterval(this.timer) clearInterval(this.timer)
this.timer = setInterval(() => { this.timer = setInterval(() => {
if (g.data_mgr.gameState == 2) { if (LWD_3.data_mgr.gameState == 2) {
return; return;
} }
g.data_mgr.time += 1; LWD_3.data_mgr.time += 1;
if (g.data_mgr.time >= 10) { if (LWD_3.data_mgr.time >= 10) {
g.data_mgr.time = 0; LWD_3.data_mgr.time = 0;
g.game.inst.hintPlay(); LWD_3.game.inst.hintPlay();
} }
}, 1000) }, 1000)
g.game.inst.isLoadEnd = true; LWD_3.game.inst.isLoadEnd = true;
}, },
} }
\ No newline at end of file
// 事件汞 // 事件汞
let eventList = {}; // 响应列表(元素结构:eventName,[[target:cb]]) let eventList = {}; // 响应列表(元素结构:eventName,[[target:cb]])
g.event_mgr = { LWD_3.event_mgr = {
// 注册事件-响应 入参:事件名、响应、目标名 // 注册事件-响应 入参:事件名、响应、目标名
reg: function (eventName, cb, target) { reg: function (eventName, cb, target) {
var event = eventList[eventName]; var event = eventList[eventName];
......
// localStorage封装 // localStorage封装
g.local_storage = { LWD_3.local_storage = {
// 背景音乐音量 // 背景音乐音量
getMusicVolume: function () { getMusicVolume: function () {
var vol = cc.sys.localStorage.getItem("music"); var vol = cc.sys.localStorage.getItem("music");
......
/** /**
* 资源管理器 * 资源管理器
*/ */
g.res_mgr = { LWD_3.res_mgr = {
//获得表数据数据 //获得表数据数据
getFormData() { getFormData() {
console.log('初始化数据'); console.log('初始化数据');
try { try {
window.courseware.getData((res) => { window.courseware.getData((res) => {
//存入数据管理器 //存入数据管理器
g.data_mgr.data = res; LWD_3.data_mgr.data = res;
//数据处理 //数据处理
g.data_mgr.proGameData(); LWD_3.data_mgr.proGameData();
console.log("获得表单数据:" + res); console.log("获得表单数据:" + res);
}); });
} catch (error) { } catch (error) {
//console.error('没有查找到courseware.getData方法', error); //console.error('没有查找到courseware.getData方法', error);
//获得默认数据 //获得默认数据
g.data_mgr.data = g.data_mgr.getDefaultData(); LWD_3.data_mgr.data = LWD_3.data_mgr.getDefaultData();
//数据处理 //数据处理
g.data_mgr.proGameData(); LWD_3.data_mgr.proGameData();
} }
}, },
...@@ -66,7 +66,7 @@ g.res_mgr = { ...@@ -66,7 +66,7 @@ g.res_mgr = {
return; return;
} }
animationDisplay.armatureName = data.name; animationDisplay.armatureName = data.name;
g.data_mgr.dragonName = data.animation[0].name; LWD_3.data_mgr.dragonName = data.animation[0].name;
animationDisplay.node.active = true; animationDisplay.node.active = true;
} }
......
// 声音管理器 // 声音管理器
g.snd_mgr = { LWD_3.snd_mgr = {
bgmId: -1, // 背景音乐的音频ID bgmId: -1, // 背景音乐的音频ID
effIds: [], // 音效的音频ID列表(由cc.audioEngine保证音频ID不重复) effIds: [], // 音效的音频ID列表(由cc.audioEngine保证音频ID不重复)
bgmVol: 1, // 背景音乐音量 bgmVol: 1, // 背景音乐音量
...@@ -10,7 +10,7 @@ g.snd_mgr = { ...@@ -10,7 +10,7 @@ g.snd_mgr = {
sndNativeUrls: {}, sndNativeUrls: {},
newsnd: null, newsnd: null,
init: function () { init: function () {
var local_storage = g.local_storage; var local_storage = LWD_3.local_storage;
var music_vol = local_storage.getMusicVolume(); var music_vol = local_storage.getMusicVolume();
var effect_vol = local_storage.getEffectsVolume(); var effect_vol = local_storage.getEffectsVolume();
music_vol != undefined && music_vol + "" != "" && this.setMusicVolume(music_vol); music_vol != undefined && music_vol + "" != "" && this.setMusicVolume(music_vol);
...@@ -32,7 +32,7 @@ g.snd_mgr = { ...@@ -32,7 +32,7 @@ g.snd_mgr = {
if (!snd) return; if (!snd) return;
this.newsnd = snd; this.newsnd = snd;
var loop = _loop ? false : true; // 除非指定为false,否则默认为true var loop = _loop ? false : true; // 除非指定为false,否则默认为true
// if (g.configs.platform == "vo") { // if (LWD_3.configs.platform == "vo") {
// this.bgmId = cc.audioEngine.play(snd, loop); // this.bgmId = cc.audioEngine.play(snd, loop);
// return; // return;
// } // }
......
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