Commit 53368db2 authored by 范雪寒's avatar 范雪寒

fix: g

parent 50c2a6c9
......@@ -14,7 +14,7 @@ var game = cc.Class({
ctor: function () {
game.inst = this;
g.game = game;
g_ps05.game = game;
},
// 生命周期 onLoad
......@@ -31,20 +31,20 @@ var game = cc.Class({
//屏幕缩放
scaleEventCallBack: function () {
g.event_mgr.send("adjustUI");
g_ps05.event_mgr.send("adjustUI");
},
//初始化游戏
initGame: function () {
//获得数据
g.res_mgr.getFormData();
g_ps05.res_mgr.getFormData();
},
onBtnTest() {
g.Light.inst.addLightNum(3);
g_ps05.Light.inst.addLightNum(3);
},
onBtnTest2() {
g.Light.inst.showLight();
g_ps05.Light.inst.showLight();
},
//检查当前缩放倍数
......@@ -61,9 +61,9 @@ var game = cc.Class({
//添加节点
addItem: function () {
let itemArr = g.data_mgr.getSheepArr();
let itemArr = g_ps05.data_mgr.getSheepArr();
this.idx = this.checkNodeParent();
g.data_mgr.nowNum = itemArr.length;
g_ps05.data_mgr.nowNum = itemArr.length;
itemArr.sort(function () { return Math.random() > 0.5 ? -1 : 1; })
......@@ -76,7 +76,7 @@ var game = cc.Class({
com.updateUI(itemInfo);
newItem_0.active = true;
//设置类别
let sheepInfo = g.data_mgr.getSheep(i);
let sheepInfo = g_ps05.data_mgr.getSheep(i);
newItem_0.getChildByName("item").type = this.checkType(sheepInfo.sheepfoldId);
......@@ -87,7 +87,7 @@ var game = cc.Class({
//检测放到哪个节点底下
checkNodeParent: function () {
//获取到总列表
var itemArr = g.data_mgr.getSheepArr();
var itemArr = g_ps05.data_mgr.getSheepArr();
//
if (itemArr.length <= 7) {
......@@ -102,8 +102,8 @@ var game = cc.Class({
//检查类别
checkType: function (Id) {
for (var i in g.data_mgr.getSheepfoldArr()) {
var sheepfoldInfo = g.data_mgr.getSheepfoldArr()[i];
for (var i in g_ps05.data_mgr.getSheepfoldArr()) {
var sheepfoldInfo = g_ps05.data_mgr.getSheepfoldArr()[i];
if (Id == sheepfoldInfo.id) {
return ~~i + 1;
}
......@@ -114,7 +114,7 @@ var game = cc.Class({
//设置目标节点类型
setOptionType: function () {
//设置类型
this.OptionType = g.data_mgr.getSheepfoldArr().length - 3;
this.OptionType = g_ps05.data_mgr.getSheepfoldArr().length - 3;
},
getOptionType: function () {
......@@ -126,28 +126,28 @@ var game = cc.Class({
this.btnRestart.active = false;
//设置题目长度
g.scoreStart.inst.addStar(g.data_mgr.data.starArr.length);
g.data_mgr.ansId = 0;
g.data_mgr.startId = 0;
g_ps05.scoreStart.inst.addStar(g_ps05.data_mgr.data.starArr.length);
g_ps05.data_mgr.ansId = 0;
g_ps05.data_mgr.startId = 0;
//初始化单题题目
this.InitQuestion();
},
//初始化单个题目
InitQuestion() {
var question = g.data_mgr.data.starArr[g.data_mgr.startId].queArr[g.data_mgr.ansId]
var question = g_ps05.data_mgr.data.starArr[g_ps05.data_mgr.startId].queArr[g_ps05.data_mgr.ansId]
//初始化灯
g.Light.inst.addLightNum(question.hotZoneItemArr.length);
g_ps05.Light.inst.addLightNum(question.hotZoneItemArr.length);
//初始化标题
g.titleType.inst.showTitle(question.title, question.title_audio_url);
g_ps05.titleType.inst.showTitle(question.title, question.title_audio_url);
if (question.title_audio_url) {
g.data_mgr.gameState = 2;
g_ps05.data_mgr.gameState = 2;
setTimeout(() => {
g.titleType.inst.onBtnPlayEffect();
g_ps05.titleType.inst.onBtnPlayEffect();
}, 500)
}
//设置中间图片
g.picNode.inst.onShow(question);
g_ps05.picNode.inst.onShow(question);
},
onBtnCheck() {
......@@ -156,21 +156,21 @@ var game = cc.Class({
//播放特效
//灯+1
g.speaker.inst.playEffect(g.enum.E_Audio.Right);
let num = g.Light.inst.showLight();
g_ps05.speaker.inst.playEffect(g_ps05.enum.E_Audio.Right);
let num = g_ps05.Light.inst.showLight();
if (num == -1) {
g.data_mgr.ansId += 1;
if (g.data_mgr.ansId >= g.data_mgr.data.starArr[g.data_mgr.startId].queArr.length) {
g_ps05.data_mgr.ansId += 1;
if (g_ps05.data_mgr.ansId >= g_ps05.data_mgr.data.starArr[g_ps05.data_mgr.startId].queArr.length) {
//大星星音效
g.speaker.inst.playEffect(g.enum.E_Audio.Star);
g.scoreStart.inst.showStar();
g.data_mgr.ansId = 0;
g.data_mgr.startId += 1;
g_ps05.speaker.inst.playEffect(g_ps05.enum.E_Audio.Star);
g_ps05.scoreStart.inst.showStar();
g_ps05.data_mgr.ansId = 0;
g_ps05.data_mgr.startId += 1;
}
setTimeout(() => {
if (g.data_mgr.startId >= g.data_mgr.data.starArr.length) {
g.speaker.inst.playEffect(g.enum.E_Audio.Flowers);
g.effect.inst.showEffect2();
if (g_ps05.data_mgr.startId >= g_ps05.data_mgr.data.starArr.length) {
g_ps05.speaker.inst.playEffect(g_ps05.enum.E_Audio.Flowers);
g_ps05.effect.inst.showEffect2();
this.btnRestart.active = true;
const middleLayer = cc.find('middleLayer');
if (middleLayer) {
......@@ -191,9 +191,9 @@ var game = cc.Class({
//播放标题音效
playAudioTitle: function () {
//获得播放路径
var path = g.data_mgr.data.audio_url;
g.res_mgr.playAudioByUrl(path, (url) => {
g.snd_mgr.playEffect(url, null);
var path = g_ps05.data_mgr.data.audio_url;
g_ps05.res_mgr.playAudioByUrl(path, (url) => {
g_ps05.snd_mgr.playEffect(url, null);
});
},
......@@ -203,12 +203,12 @@ var game = cc.Class({
this.contentArr_2[0].removeAllChildren();
this.contentArr_2[1].removeAllChildren();
//移除所有子节点
g.event_mgr.send("reSetGame");
g_ps05.event_mgr.send("reSetGame");
},
//重新开始
onBtnReStart: function () {
g.speaker.inst.playEffect(g.enum.E_Audio.BtnCommom);
g_ps05.speaker.inst.playEffect(g_ps05.enum.E_Audio.BtnCommom);
//移除所有计时器
this.unscheduleAllCallbacks();
//初始化界面
......@@ -217,7 +217,7 @@ var game = cc.Class({
//游戏开始
gameStart: function () {
console.log("游戏开始:" + g.data_mgr);
console.log("游戏开始:" + g_ps05.data_mgr);
//播放一个上面的音乐
this.setAudioInfo(1);
},
......
// 全局环境预声明
window.g = window.g || {}; // 全局
\ No newline at end of file
window.g_ps05 = window.g_ps05 || {}; // 全局
\ No newline at end of file
......@@ -14,7 +14,7 @@ var eff_well = cc.Class({
ctor: function () {
eff_well.inst = this;
g.eff_well = eff_well;
g_ps05.eff_well = eff_well;
},
//显示特效
......@@ -22,7 +22,7 @@ var eff_well = cc.Class({
this.node.active = true;
this.eff_welldown.play();
//播放撒花音效
g.speaker.inst.play_congratulation();
g_ps05.speaker.inst.play_congratulation();
setTimeout(() => {
this.node.active = false;
}, 2000)
......
g.utils = {
g_ps05.utils = {
// 范围随机
randFromTo: function (_min, _max) {
var min = parseFloat(_min);
......
......@@ -62,7 +62,7 @@ cc.Class({
}
}, 0);
g.event_mgr.reg("adjustUI", () => {
g_ps05.event_mgr.reg("adjustUI", () => {
this.setBgScale();
this.setUiPositon();
});
......@@ -89,7 +89,7 @@ cc.Class({
var h = (canvaSize.height) / 1334;
this.MaxSize = w / h > 1 ? w / h : h / w;
g.data_mgr.MaxSize = this.MaxSize;
g_ps05.data_mgr.MaxSize = this.MaxSize;
this.setUIMax(this.MaxSize);
this.settopUI(this.MaxSize);
this.setBgScale();
......@@ -102,15 +102,15 @@ cc.Class({
},
onDestroy: function () {
if (g.event_pump) {
g.event_pump.unReg("adjustUI");
if (g_ps05.event_pump) {
g_ps05.event_pump.unReg("adjustUI");
}
},
settopUI: function (s) {
if (!g.data_mgr.phoneInfo) {
if (!g_ps05.data_mgr.phoneInfo) {
return;
}
var top = g.data_mgr.phoneInfo;
var top = g_ps05.data_mgr.phoneInfo;
top = top * s;
for (var i in this.topUI) {
if (this.topUI[i].perTop == undefined) {
......
......@@ -15,15 +15,15 @@ cc.Class({
},
onLoad() {
this.labTitle.string = g.data_mgr.getSheepfold(this.setAnswerId).word;
this.labTitle.string = g_ps05.data_mgr.getSheepfold(this.setAnswerId).word;
this.Event();
},
Event() {
this.m_uuid = g.utils.generateUUID(); //生成一个唯一Id
this.m_uuid = g_ps05.utils.generateUUID(); //生成一个唯一Id
g.event_mgr.reg("reSetGame", () => {
g_ps05.event_mgr.reg("reSetGame", () => {
this.node.getChildByName("scrollView").getChildByName("view").getChildByName("content").removeAllChildren();
}, this.m_uuid);
},
......
......@@ -13,7 +13,7 @@ var scoreStart = cc.Class({
ctor: function () {
scoreStart.inst = this;
g.scoreStart = scoreStart;
g_ps05.scoreStart = scoreStart;
},
addStar(num) {
......
......@@ -15,14 +15,14 @@ var effect = cc.Class({
ctor: function () {
effect.inst = this;
g.effect = effect;
g_ps05.effect = effect;
},
showEffect: function () {
const bg = cc.find('Canvas/bg/connent');
this.showAllFirework(bg, cc.find('paperBase').children);
g.speaker.inst.play_congratulation();
g_ps05.speaker.inst.play_congratulation();
},
showEffect2: function () {
......
......@@ -26,7 +26,7 @@ var TouchDragger = cc.Class({
},
ctor: function () {
TouchDragger.inst = this;
g.TouchDragger = TouchDragger;
g_ps05.TouchDragger = TouchDragger;
},
onLoad: function () {
this.arMap = [];
......@@ -36,7 +36,7 @@ var TouchDragger = cc.Class({
this.isFirstMove = true;
//初始化格子数据
this.initGridInfo(g.data_mgr.challengeData.IngredientList);
this.initGridInfo(g_ps05.data_mgr.challengeData.IngredientList);
},
start: function () {
......
......@@ -79,7 +79,7 @@ cc.Class({
return
}
var answer = g.game.inst.checkAnswer(this.node, this.node.type);
var answer = g_ps05.game.inst.checkAnswer(this.node, this.node.type);
if (answer) {
this.setItemState(answer);
......@@ -91,28 +91,28 @@ cc.Class({
setItemState: function (content) {
this.Item_complete.active = true;
this.node.isComplent = true;
g.data_mgr.nowNum -= 1;
if (g.data_mgr.nowNum == 0) {
g_ps05.data_mgr.nowNum -= 1;
if (g_ps05.data_mgr.nowNum == 0) {
setTimeout(() => {
g.speaker.inst.play_congratulation();
g.effect.inst.showEffect2();
g_ps05.speaker.inst.play_congratulation();
g_ps05.effect.inst.showEffect2();
}, 500)
}
g.speaker.inst.play_good();
g_ps05.speaker.inst.play_good();
if (g.game.inst.getOptionType() == 2) {
if (g_ps05.game.inst.getOptionType() == 2) {
// newItem_temp.scale = 0.8;
// this.node.scale = this.node.scale * 0.8;
var newItem_temp = cc.instantiate(g.game.inst.Item_0[3]);
var newItem_temp = cc.instantiate(g_ps05.game.inst.Item_0[3]);
} else {
var newItem_temp = cc.instantiate(g.game.inst.Item_0[2]);
var newItem_temp = cc.instantiate(g_ps05.game.inst.Item_0[2]);
}
// var newItem_temp = cc.instantiate(g.game.inst.Item_0[2]);
// var newItem_temp = cc.instantiate(g_ps05.game.inst.Item_0[2]);
content.getChildByName("db").active = true;
content.getChildByName("db").getComponent(dragonBones.ArmatureDisplay).playAnimation("newAnimation", 1);
if (this.node.width >= 150) {
if (g.game.inst.getOptionType() == 2) {
if (g_ps05.game.inst.getOptionType() == 2) {
this.node.scale = 0.45;
this.node.x = 0;
} else {
......@@ -120,7 +120,7 @@ cc.Class({
this.node.x = 0;
}
} else {
if (g.game.inst.getOptionType() == 2) {
if (g_ps05.game.inst.getOptionType() == 2) {
this.node.scale = 0.7;
this.node.x = 0;
} else {
......@@ -138,7 +138,7 @@ cc.Class({
},
errorEffect: function () {
g.speaker.inst.play_error();
g_ps05.speaker.inst.play_error();
this.node.getChildByName("red").active = true;
cc.tween(this.node)
......@@ -178,7 +178,7 @@ cc.Class({
//点击翻面
onBtnRotate: function () {
//翻面音效
g.speaker.inst.play_btn();
g_ps05.speaker.inst.play_btn();
var scaleX = this.node.scaleY;
......@@ -207,10 +207,10 @@ cc.Class({
//初始化信息
InitData: function () {
//设置图片
g.res_mgr.getSpriteFrimeByUrl(this.itemInfo.picUrl, (list) => {
g_ps05.res_mgr.getSpriteFrimeByUrl(this.itemInfo.picUrl, (list) => {
this.Item_photo.getComponent(cc.Sprite).spriteFrame = list;
this.photoScare(this.Item_photo, g.game.inst.idx);
this.photoScare(this.Item_photo, g_ps05.game.inst.idx);
// this.photoScare(this.nodeState[2].getChildByName("spt_item"), 1);
});
//设置名字
......
......@@ -11,7 +11,7 @@ var Light = cc.Class({
ctor: function () {
Light.inst = this;
g.Light = Light;
g_ps05.Light = Light;
},
addLightNum(Num) {
......
g.enum = {
g_ps05.enum = {
E_Audio: {
Star: 0,//大星星
BtnCommom: 1,//按钮
......@@ -25,15 +25,15 @@ var speaker = cc.Class({
ctor: function () {
speaker.inst = this;
g.speaker = speaker;
g_ps05.speaker = speaker;
},
// //播放音效
// playEffect: function (num, cb) {
// g.snd_mgr.playEffect(this.eff_audio[num], cb);
// g_ps05.snd_mgr.playEffect(this.eff_audio[num], cb);
// },
playEffect: function (num, cb) {
g.snd_mgr.playMusic(this.eff_audio[num], 1, cb);
g_ps05.snd_mgr.playMusic(this.eff_audio[num], 1, cb);
},
});
......@@ -11,7 +11,7 @@ var titleType = cc.Class({
ctor: function () {
titleType.inst = this;
g.titleType = titleType;
g_ps05.titleType = titleType;
},
start() {
......@@ -49,8 +49,8 @@ var titleType = cc.Class({
//获得播放路径
this.schedule(this.setSndEff, 0.3);
g.res_mgr.playAudioByUrl(this.audio, (url) => {
g.snd_mgr.playEffect(url, () => {
g_ps05.res_mgr.playAudioByUrl(this.audio, (url) => {
g_ps05.snd_mgr.playEffect(url, () => {
//关闭效果
this.unschedule(this.setSndEff);
this.btnSnd.active = true;
......
/**
* 数据管理器
*/
g.data_mgr = {
g_ps05.data_mgr = {
data: null,//表所有数据
nowNum: null,//剩余个数
......@@ -117,8 +117,8 @@ g.data_mgr = {
},
loadEnd() {
//更新游戏界面信息
g.game.inst.UpdataUi();
g_ps05.game.inst.UpdataUi();
g.game.inst.isLoadEnd = true;
g_ps05.game.inst.isLoadEnd = true;
},
}
\ No newline at end of file
// 事件汞
let eventList = {}; // 响应列表(元素结构:eventName,[[target:cb]])
g.event_mgr = {
g_ps05.event_mgr = {
// 注册事件-响应 入参:事件名、响应、目标名
reg: function (eventName, cb, target) {
var event = eventList[eventName];
......
// localStorage封装
g.local_storage = {
g_ps05.local_storage = {
// 背景音乐音量
getMusicVolume: function () {
var vol = cc.sys.localStorage.getItem("music");
......
/**
* 资源管理器
*/
g.res_mgr = {
g_ps05.res_mgr = {
//获得表数据数据
getFormData() {
console.log('初始化数据');
......@@ -9,9 +9,9 @@ g.res_mgr = {
if (window && window.courseware) {
window.courseware.getData((res) => {
//存入数据管理器
g.data_mgr.data = res;
g_ps05.data_mgr.data = res;
//数据处理
g.data_mgr.proGameData();
g_ps05.data_mgr.proGameData();
console.log("获得表单数据:" + res);
});
return;
......@@ -22,9 +22,9 @@ g.res_mgr = {
const middleLayerComponent = middleLayer.getComponent('middleLayer');
middleLayerComponent.getData((res) => {
//存入数据管理器
g.data_mgr.data = res;
g_ps05.data_mgr.data = res;
//数据处理
g.data_mgr.proGameData();
g_ps05.data_mgr.proGameData();
console.log("获得表单数据:" + res);
});
return;
......@@ -32,9 +32,9 @@ g.res_mgr = {
//console.error('没有查找到courseware.getData方法', error);
//获得默认数据
g.data_mgr.data = g.data_mgr.getDefaultData();
g_ps05.data_mgr.data = g_ps05.data_mgr.getDefaultData();
//数据处理
g.data_mgr.proGameData();
g_ps05.data_mgr.proGameData();
},
//得到图片资源
......@@ -84,7 +84,7 @@ g.res_mgr = {
return;
}
animationDisplay.armatureName = data.name;
g.data_mgr.dragonName = data.animation[0].name;
g_ps05.data_mgr.dragonName = data.animation[0].name;
animationDisplay.node.active = true;
}
......
// 声音管理器
g.snd_mgr = {
g_ps05.snd_mgr = {
bgmId: -1, // 背景音乐的音频ID
effIds: [], // 音效的音频ID列表(由cc.audioEngine保证音频ID不重复)
bgmVol: 1, // 背景音乐音量
......@@ -10,7 +10,7 @@ g.snd_mgr = {
sndNativeUrls: {},
newsnd: null,
init: function () {
var local_storage = g.local_storage;
var local_storage = g_ps05.local_storage;
var music_vol = local_storage.getMusicVolume();
var effect_vol = local_storage.getEffectsVolume();
music_vol != undefined && music_vol + "" != "" && this.setMusicVolume(music_vol);
......@@ -32,7 +32,7 @@ g.snd_mgr = {
if (!snd) return;
this.newsnd = snd;
var loop = _loop ? false : true; // 除非指定为false,否则默认为true
// if (g.configs.platform == "vo") {
// if (g_ps05.configs.platform == "vo") {
// this.bgmId = cc.audioEngine.play(snd, loop);
// 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