Commit 396d96dd authored by 范雪寒's avatar 范雪寒

feat: global问题

parent 181499e2
const tools = require("../script/tools"); const tools = require("../script/tools");
import { initGlobal_NGT_02 } from "../../script/common/_preDefine";
var picNode = cc.Class({ var picNode = cc.Class({
extends: cc.Component, extends: cc.Component,
...@@ -12,6 +14,7 @@ var picNode = cc.Class({ ...@@ -12,6 +14,7 @@ var picNode = cc.Class({
}, },
ctor: function () { ctor: function () {
initGlobal_NGT_02();
picNode.inst = this; picNode.inst = this;
g.picNode = picNode; g.picNode = picNode;
}, },
......
This diff is collapsed.
import { initDataMgr_NGT_02 } from "../manager/data_mgr";
import { initEventMgr_NGT_02 } from "../manager/event_mgr";
import { initStorageMgr_NGT_02 } from "../manager/local_storage";
import { initResMgr_NGT_02 } from "../manager/res_mgr";
import { initSndMgr_NGT_02 } from "../manager/snd_mgr";
import { initUtils_NGT_02 } from "./utils";
import { initEnumMgr_NGT_02 } from "../game/speaker";
// 全局环境预声明 // 全局环境预声明
function initGlobal_NGT_02() { export function initGlobal_NGT_02() {
console.log('window.g init'); console.log('window.g init');
window.g = {}; if (!window.g) {
initDataMgr_NGT_02(); window.g = {};
initEventMgr_NGT_02(); initDataMgr_NGT_02();
initStorageMgr_NGT_02(); initEventMgr_NGT_02();
initResMgr_NGT_02(); initStorageMgr_NGT_02();
initSndMgr_NGT_02(); initResMgr_NGT_02();
initUtils_NGT_02(); initSndMgr_NGT_02();
initUtils_NGT_02();
initEnumMgr_NGT_02();
}
} }
\ No newline at end of file
This diff is collapsed.
g.enum = { export function initEnumMgr_NGT_02() {
E_Audio: { g.enum = {
Star: 0,//大星星 E_Audio: {
BtnCommom: 1,//按钮 Star: 0, //大星星
Flowers: 2,//撒花 BtnCommom: 1, //按钮
Right: 3,//正确 Flowers: 2, //撒花
Error: 4,//错误 Right: 3, //正确
Question: 5,//题数 Error: 4, //错误
} Question: 5, //题数
},
};
} }
/** /**
* 音效 * 音效
*/ */
var speaker = cc.Class({ var speaker = cc.Class({
extends: cc.Component, extends: cc.Component,
properties: { properties: {
eff_audio: { eff_audio: {
default: [], default: [],
type: cc.AudioClip, type: cc.AudioClip,
displayName: "音效列表" displayName: "音效列表",
}, },
}, },
ctor: function () { ctor: function () {
speaker.inst = this; speaker.inst = this;
g.speaker = speaker; g.speaker = speaker;
}, },
// //播放音效 // //播放音效
// playEffect: function (num, cb) { // playEffect: function (num, cb) {
// g.snd_mgr.playEffect(this.eff_audio[num], cb); // g.snd_mgr.playEffect(this.eff_audio[num], cb);
// }, // },
playEffect: function (num, cb) { playEffect: function (num, cb) {
g.snd_mgr.playMusic(this.eff_audio[num], 1, cb); g.snd_mgr.playMusic(this.eff_audio[num], 1, cb);
}, },
}); });
/** /**
* 数据管理器 * 数据管理器
*/ */
function initDataMgr_NGT_02() { export function initDataMgr_NGT_02() {
g.data_mgr = { g.data_mgr = {
data: null, //表所有数据 data: null, //表所有数据
......
function initEventMgr_NGT_02() { export function initEventMgr_NGT_02() {
// 事件汞 // 事件汞
let eventList = {}; // 响应列表(元素结构:eventName,[[target:cb]]) let eventList = {}; // 响应列表(元素结构:eventName,[[target:cb]])
g.event_mgr = { g.event_mgr = {
......
function initStorageMgr_NGT_02() { export function initStorageMgr_NGT_02() {
// localStorage封装 // localStorage封装
g.local_storage = { g.local_storage = {
// 背景音乐音量 // 背景音乐音量
......
function initResMgr_NGT_02() { export function initResMgr_NGT_02() {
/** /**
* 资源管理器 * 资源管理器
*/ */
......
function initSndMgr_NGT_02() { export function initSndMgr_NGT_02() {
// 声音管理器 // 声音管理器
g.snd_mgr = { g.snd_mgr = {
bgmId: -1, // 背景音乐的音频ID bgmId: -1, // 背景音乐的音频ID
......
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