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

feat: global问题

parent 181499e2
const tools = require("../script/tools");
import { initGlobal_NGT_02 } from "../../script/common/_preDefine";
var picNode = cc.Class({
extends: cc.Component,
......@@ -12,6 +14,7 @@ var picNode = cc.Class({
},
ctor: function () {
initGlobal_NGT_02();
picNode.inst = this;
g.picNode = picNode;
},
......
import { initGlobal_NGT_02 } from "../script/common/_preDefine";
/**
* 游戏主逻辑
*/
var game = cc.Class({
extends: cc.Component,
properties: {
btnRestart: {
default: null,
type: cc.Node,
displayName: "重开按钮"
}
},
ctor: function () {
initGlobal_NGT_02();
game.inst = this;
g.game = game;
},
// 生命周期 onLoad
onLoad() {
//初始化游戏
this.initGame();
if (window.addEventListener) {
window.addEventListener('resize', this.scaleEventCallBack, false)
} else if (window.attachEvent) {
window.attachEvent('resize', this.scaleEventCallBack, false)
}
cc.debug.setDisplayStats(false);
},
//屏幕缩放
scaleEventCallBack: function () {
g.event_mgr.send("adjustUI");
},
//初始化游戏
initGame: function () {
//获得数据
g.res_mgr.getFormData();
},
onBtnTest() {
g.Light.inst.addLightNum(3);
},
onBtnTest2() {
g.Light.inst.showLight();
},
//检查当前缩放倍数
checkScale: function (num) {
var scale = 1;
if (num > 2 && num <= 4) {
scale = 0.74
}
if (num > 4) {
scale = 0.65
}
return scale;
},
//添加节点
addItem: function () {
let itemArr = g.data_mgr.getSheepArr();
this.idx = this.checkNodeParent();
g.data_mgr.nowNum = itemArr.length;
itemArr.sort(function () { return Math.random() > 0.5 ? -1 : 1; })
for (var i = 0; i < itemArr.length; i++) {
let newItem_0 = cc.instantiate(this.Item_0[itemArr.length > 14 ? 0 : 1]);
//更新子项
var com = newItem_0.getChildByName("item").getComponent("item");
let itemInfo = itemArr[i];
com.updateUI(itemInfo);
newItem_0.active = true;
//设置类别
let sheepInfo = g.data_mgr.getSheep(i);
newItem_0.getChildByName("item").type = this.checkType(sheepInfo.sheepfoldId);
newItem_0.parent = this.contentArr_2[this.idx];
};
},
//检测放到哪个节点底下
checkNodeParent: function () {
//获取到总列表
var itemArr = g.data_mgr.getSheepArr();
//
if (itemArr.length <= 7) {
this.contentArr_2[1].active = true;
var idx = 1;
} else {
this.contentArr_2[0].active = true;
var idx = 0;
}
return idx;
},
//检查类别
checkType: function (Id) {
for (var i in g.data_mgr.getSheepfoldArr()) {
var sheepfoldInfo = g.data_mgr.getSheepfoldArr()[i];
if (Id == sheepfoldInfo.id) {
return ~~i + 1;
}
}
return -1;
},
//设置目标节点类型
setOptionType: function () {
//设置类型
this.OptionType = g.data_mgr.getSheepfoldArr().length - 3;
},
getOptionType: function () {
return this.OptionType;
},
//更新界面信息
UpdataUi: function () {
this.btnRestart.active = false;
//设置题目长度
g.scoreStart.inst.addStar(g.data_mgr.data.starArr.length);
g.data_mgr.ansId = 0;
g.data_mgr.startId = 0;
//初始化单题题目
this.InitQuestion();
},
//初始化单个题目
InitQuestion() {
var question = g.data_mgr.data.starArr[g.data_mgr.startId].queArr[g.data_mgr.ansId]
//初始化灯
g.Light.inst.addLightNum(question.hotZoneItemArr.length);
//初始化标题
g.titleType.inst.showTitle(question.title, question.title_audio_url);
if (question.title_audio_url) {
g.data_mgr.gameState = 2;
setTimeout(() => {
g.titleType.inst.onBtnPlayEffect();
}, 500)
}
//设置中间图片
g.picNode.inst.onShow(question);
},
onBtnCheck() {
//默认答对
//播放特效
//灯+1
g.speaker.inst.playEffect(g.enum.E_Audio.Right);
let num = g.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.speaker.inst.playEffect(g.enum.E_Audio.Star);
g.scoreStart.inst.showStar();
g.data_mgr.ansId = 0;
g.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();
this.btnRestart.active = true;
const middleLayer = cc.find('middleLayer');
if (middleLayer) {
const middleLayerComponent = middleLayer.getComponent('middleLayer');
if (middleLayerComponent.role == 'student') {
middleLayerComponent.onHomeworkFinish(() => { });
}
} else {
console.log('onHomeworkFinish');
}
} else {
this.InitQuestion();
}
}, 1500)
}
},
//播放标题音效
playAudioTitle: function () {
//获得播放路径
var path = g.data_mgr.data.audio_url;
g.res_mgr.playAudioByUrl(path, (url) => {
g.snd_mgr.playEffect(url, null);
});
},
//重置UI界面
resetUI: function () {
//移除所有子节点
this.contentArr_2[0].removeAllChildren();
this.contentArr_2[1].removeAllChildren();
//移除所有子节点
g.event_mgr.send("reSetGame");
},
//重新开始
onBtnReStart: function () {
g.speaker.inst.playEffect(g.enum.E_Audio.BtnCommom);
//移除所有计时器
this.unscheduleAllCallbacks();
//初始化界面
this.UpdataUi();
},
//游戏开始
gameStart: function () {
console.log("游戏开始:" + g.data_mgr);
//播放一个上面的音乐
this.setAudioInfo(1);
},
checkAnswer(caller, option_i) {
if (caller == undefined) {
return;
}
if (option_i != -1) {
let nodOption = this.contType[this.OptionType].children[option_i - 1]
if (nodOption) {
let AABB = nodOption.getComponent("DragGameOptionObject").setAABB();
let callerAABB = this.getCallerAABB(caller);
var isIntersect = AABB.containsRect(callerAABB);//判断是否被包含
console.log(isIntersect)
if (isIntersect) {
return nodOption;
}
return false
}
}
},
getCallerAABB(caller) {
let svLeftBottomPoint = caller.parent.convertToWorldSpaceAR(
cc.v2(
caller.x,
caller.y
)
);
var posNode_1 = cc.rect(
svLeftBottomPoint.x,
svLeftBottomPoint.y,
0,
0
);
return posNode_1
},
onDestroy() {
window.g = null;
}
extends: cc.Component,
properties: {
btnRestart: {
default: null,
type: cc.Node,
displayName: "重开按钮",
},
},
ctor: function () {
initGlobal_NGT_02();
game.inst = this;
g.game = game;
},
// 生命周期 onLoad
onLoad() {
//初始化游戏
this.initGame();
if (window.addEventListener) {
window.addEventListener("resize", this.scaleEventCallBack, false);
} else if (window.attachEvent) {
window.attachEvent("resize", this.scaleEventCallBack, false);
}
cc.debug.setDisplayStats(false);
},
//屏幕缩放
scaleEventCallBack: function () {
g.event_mgr.send("adjustUI");
},
//初始化游戏
initGame: function () {
//获得数据
g.res_mgr.getFormData();
},
onBtnTest() {
g.Light.inst.addLightNum(3);
},
onBtnTest2() {
g.Light.inst.showLight();
},
//检查当前缩放倍数
checkScale: function (num) {
var scale = 1;
if (num > 2 && num <= 4) {
scale = 0.74;
}
if (num > 4) {
scale = 0.65;
}
return scale;
},
//添加节点
addItem: function () {
let itemArr = g.data_mgr.getSheepArr();
this.idx = this.checkNodeParent();
g.data_mgr.nowNum = itemArr.length;
itemArr.sort(function () {
return Math.random() > 0.5 ? -1 : 1;
});
for (var i = 0; i < itemArr.length; i++) {
let newItem_0 = cc.instantiate(this.Item_0[itemArr.length > 14 ? 0 : 1]);
//更新子项
var com = newItem_0.getChildByName("item").getComponent("item");
let itemInfo = itemArr[i];
com.updateUI(itemInfo);
newItem_0.active = true;
//设置类别
let sheepInfo = g.data_mgr.getSheep(i);
newItem_0.getChildByName("item").type = this.checkType(
sheepInfo.sheepfoldId
);
newItem_0.parent = this.contentArr_2[this.idx];
}
},
//检测放到哪个节点底下
checkNodeParent: function () {
//获取到总列表
var itemArr = g.data_mgr.getSheepArr();
//
if (itemArr.length <= 7) {
this.contentArr_2[1].active = true;
var idx = 1;
} else {
this.contentArr_2[0].active = true;
var idx = 0;
}
return idx;
},
//检查类别
checkType: function (Id) {
for (var i in g.data_mgr.getSheepfoldArr()) {
var sheepfoldInfo = g.data_mgr.getSheepfoldArr()[i];
if (Id == sheepfoldInfo.id) {
return ~~i + 1;
}
}
return -1;
},
//设置目标节点类型
setOptionType: function () {
//设置类型
this.OptionType = g.data_mgr.getSheepfoldArr().length - 3;
},
getOptionType: function () {
return this.OptionType;
},
//更新界面信息
UpdataUi: function () {
this.btnRestart.active = false;
//设置题目长度
g.scoreStart.inst.addStar(g.data_mgr.data.starArr.length);
g.data_mgr.ansId = 0;
g.data_mgr.startId = 0;
//初始化单题题目
this.InitQuestion();
},
//初始化单个题目
InitQuestion() {
var question =
g.data_mgr.data.starArr[g.data_mgr.startId].queArr[g.data_mgr.ansId];
//初始化灯
g.Light.inst.addLightNum(question.hotZoneItemArr.length);
//初始化标题
g.titleType.inst.showTitle(question.title, question.title_audio_url);
if (question.title_audio_url) {
g.data_mgr.gameState = 2;
setTimeout(() => {
g.titleType.inst.onBtnPlayEffect();
}, 500);
}
//设置中间图片
g.picNode.inst.onShow(question);
},
onBtnCheck() {
//默认答对
//播放特效
//灯+1
g.speaker.inst.playEffect(g.enum.E_Audio.Right);
let num = g.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.speaker.inst.playEffect(g.enum.E_Audio.Star);
g.scoreStart.inst.showStar();
g.data_mgr.ansId = 0;
g.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();
this.btnRestart.active = true;
const middleLayer = cc.find("middleLayer");
if (middleLayer) {
const middleLayerComponent =
middleLayer.getComponent("middleLayer");
if (middleLayerComponent.role == "student") {
middleLayerComponent.onHomeworkFinish(() => {});
}
} else {
console.log("onHomeworkFinish");
}
} else {
this.InitQuestion();
}
}, 1500);
}
},
//播放标题音效
playAudioTitle: function () {
//获得播放路径
var path = g.data_mgr.data.audio_url;
g.res_mgr.playAudioByUrl(path, (url) => {
g.snd_mgr.playEffect(url, null);
});
},
//重置UI界面
resetUI: function () {
//移除所有子节点
this.contentArr_2[0].removeAllChildren();
this.contentArr_2[1].removeAllChildren();
//移除所有子节点
g.event_mgr.send("reSetGame");
},
//重新开始
onBtnReStart: function () {
g.speaker.inst.playEffect(g.enum.E_Audio.BtnCommom);
//移除所有计时器
this.unscheduleAllCallbacks();
//初始化界面
this.UpdataUi();
},
//游戏开始
gameStart: function () {
console.log("游戏开始:" + g.data_mgr);
//播放一个上面的音乐
this.setAudioInfo(1);
},
checkAnswer(caller, option_i) {
if (caller == undefined) {
return;
}
if (option_i != -1) {
let nodOption = this.contType[this.OptionType].children[option_i - 1];
if (nodOption) {
let AABB = nodOption.getComponent("DragGameOptionObject").setAABB();
let callerAABB = this.getCallerAABB(caller);
var isIntersect = AABB.containsRect(callerAABB); //判断是否被包含
console.log(isIntersect);
if (isIntersect) {
return nodOption;
}
return false;
}
}
},
getCallerAABB(caller) {
let svLeftBottomPoint = caller.parent.convertToWorldSpaceAR(
cc.v2(caller.x, caller.y)
);
var posNode_1 = cc.rect(svLeftBottomPoint.x, svLeftBottomPoint.y, 0, 0);
return posNode_1;
},
onDestroy() {
window.g = null;
},
});
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');
window.g = {};
initDataMgr_NGT_02();
initEventMgr_NGT_02();
initStorageMgr_NGT_02();
initResMgr_NGT_02();
initSndMgr_NGT_02();
initUtils_NGT_02();
if (!window.g) {
window.g = {};
initDataMgr_NGT_02();
initEventMgr_NGT_02();
initStorageMgr_NGT_02();
initResMgr_NGT_02();
initSndMgr_NGT_02();
initUtils_NGT_02();
initEnumMgr_NGT_02();
}
}
\ No newline at end of file
function initUtils_NGT_02() {
export function initUtils_NGT_02() {
g.utils = {
// 范围随机
randFromTo: function (_min, _max) {
......@@ -42,227 +42,225 @@ function initUtils_NGT_02() {
}
},
};
}
export function getPosByAngle(angle, len) {
const radian = (angle * Math.PI) / 180;
const x = Math.sin(radian) * len;
const y = Math.cos(radian) * len;
return { x, y };
}
export function getPosByAngle(angle, len) {
const radian = (angle * Math.PI) / 180;
const x = Math.sin(radian) * len;
const y = Math.cos(radian) * len;
export function getAngleByPos(px, py, mx, my) {
const x = Math.abs(px - mx);
const y = Math.abs(py - my);
return { x, y };
}
const z = Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2));
const cos = y / z;
const radina = Math.acos(cos); // 用反三角函数求弧度
let angle = Math.floor((180 / (Math.PI / radina)) * 100) / 100; // 将弧度转换成角度
export function getAngleByPos(px, py, mx, my) {
const x = Math.abs(px - mx);
const y = Math.abs(py - my);
if (mx > px && my > py) {
// 鼠标在第四象限
angle = 180 - angle;
}
if (mx === px && my > py) {
// 鼠标在y轴负方向上
angle = 180;
}
if (mx > px && my === py) {
// 鼠标在x轴正方向上
angle = 90;
}
if (mx < px && my > py) {
// 鼠标在第三象限
angle = 180 + angle;
}
if (mx < px && my === py) {
// 鼠标在x轴负方向
angle = 270;
}
if (mx < px && my < py) {
// 鼠标在第二象限
angle = 360 - angle;
}
const z = Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2));
const cos = y / z;
const radina = Math.acos(cos); // 用反三角函数求弧度
let angle = Math.floor((180 / (Math.PI / radina)) * 100) / 100; // 将弧度转换成角度
// console.log('angle: ', angle);
return angle;
if (mx > px && my > py) {
// 鼠标在第四象限
angle = 180 - angle;
}
export function exchangeNodePos(baseNode, targetNode) {
return baseNode.convertToNodeSpaceAR(
targetNode._parent.convertToWorldSpaceAR(
cc.v2(targetNode.x, targetNode.y)
)
);
if (mx === px && my > py) {
// 鼠标在y轴负方向上
angle = 180;
}
export function RandomInt(a, b = 0) {
let max = Math.max(a, b);
let min = Math.min(a, b);
return Math.floor(Math.random() * (max - min) + min);
if (mx > px && my === py) {
// 鼠标在x轴正方向上
angle = 90;
}
export function Between(a, b, c) {
return [a, b, c].sort((a, b) => a - b)[1];
if (mx < px && my > py) {
// 鼠标在第三象限
angle = 180 + angle;
}
export function randomSortByArr(arr) {
const newArr = [];
const tmpArr = arr.concat();
while (tmpArr.length > 0) {
const randomIndex = Math.floor(tmpArr.length * Math.random());
newArr.push(tmpArr[randomIndex]);
tmpArr.splice(randomIndex, 1);
}
return newArr;
if (mx < px && my === py) {
// 鼠标在x轴负方向
angle = 270;
}
export async function asyncTweenTo(node, duration, obj, ease = undefined) {
return new Promise((resolve, reject) => {
cc.tween(node)
.to(duration, obj, ease)
.call(() => {
resolve();
})
.start();
});
if (mx < px && my < py) {
// 鼠标在第二象限
angle = 360 - angle;
}
export async function asyncTweenBy(node, duration, obj, ease = undefined) {
return new Promise((resolve, reject) => {
cc.tween(node)
.by(duration, obj, ease)
.call(() => {
resolve();
})
.start();
});
}
// console.log('angle: ', angle);
return angle;
}
export function exchangeNodePos(baseNode, targetNode) {
return baseNode.convertToNodeSpaceAR(
targetNode._parent.convertToWorldSpaceAR(cc.v2(targetNode.x, targetNode.y))
);
}
export async function asyncPlayDragonBoneAnimation(
node,
animationName,
time = 1,
onFrameEvent
) {
return new Promise((resolve, reject) => {
node
.getComponent(dragonBones.ArmatureDisplay)
.once(dragonBones.EventObject.COMPLETE, () => {
resolve();
});
export function RandomInt(a, b = 0) {
let max = Math.max(a, b);
let min = Math.min(a, b);
return Math.floor(Math.random() * (max - min) + min);
}
node
.getComponent(dragonBones.ArmatureDisplay)
.on(dragonBones.EventObject.FRAME_EVENT, ({ name }) => {
if (onFrameEvent && typeof onFrameEvent == "function") {
onFrameEvent(name);
}
});
export function Between(a, b, c) {
return [a, b, c].sort((a, b) => a - b)[1];
}
node
.getComponent(dragonBones.ArmatureDisplay)
.playAnimation(animationName, time);
});
export function randomSortByArr(arr) {
const newArr = [];
const tmpArr = arr.concat();
while (tmpArr.length > 0) {
const randomIndex = Math.floor(tmpArr.length * Math.random());
newArr.push(tmpArr[randomIndex]);
tmpArr.splice(randomIndex, 1);
}
return newArr;
}
export async function asyncPlayEffectByUrl(url, loop = false) {
return new Promise((resolve, reject) => {
cc.assetManager.loadRemote(url, (err, clip) => {
console.log(clip);
cc.audioEngine.playEffect(clip, loop);
export async function asyncTweenTo(node, duration, obj, ease = undefined) {
return new Promise((resolve, reject) => {
cc.tween(node)
.to(duration, obj, ease)
.call(() => {
resolve();
});
});
}
})
.start();
});
}
export async function jelly(node) {
return new Promise((resolve, reject) => {
cc.tween(node)
.to(0.1, { scaleX: 0.9, scaleY: 1.1 })
.to(0.1, { scaleX: 1.1, scaleY: 0.9 })
.to(0.1, { scaleX: 1, scaleY: 1 })
.call(resolve)
.start();
});
}
export async function asyncTweenBy(node, duration, obj, ease = undefined) {
return new Promise((resolve, reject) => {
cc.tween(node)
.by(duration, obj, ease)
.call(() => {
resolve();
})
.start();
});
}
export async function asyncDelay(time) {
return new Promise((resolve, reject) => {
setTimeout(() => {
export async function asyncPlayDragonBoneAnimation(
node,
animationName,
time = 1,
onFrameEvent
) {
return new Promise((resolve, reject) => {
node
.getComponent(dragonBones.ArmatureDisplay)
.once(dragonBones.EventObject.COMPLETE, () => {
resolve();
}, time * 1000);
});
node
.getComponent(dragonBones.ArmatureDisplay)
.on(dragonBones.EventObject.FRAME_EVENT, ({ name }) => {
if (onFrameEvent && typeof onFrameEvent == "function") {
onFrameEvent(name);
}
});
node
.getComponent(dragonBones.ArmatureDisplay)
.playAnimation(animationName, time);
});
}
export async function asyncPlayEffectByUrl(url, loop = false) {
return new Promise((resolve, reject) => {
cc.assetManager.loadRemote(url, (err, clip) => {
console.log(clip);
cc.audioEngine.playEffect(clip, loop);
resolve();
});
}
});
}
export async function showFireworks(
baseNode,
nodeList,
pos = cc.v2(0, 0),
side = cc.v2(0, 100),
range = 50,
number = 100
) {
new Array(number).fill(" ").forEach(async (_, i) => {
let rabbonNode = new cc.Node();
rabbonNode.parent = baseNode;
rabbonNode.x = pos.x;
rabbonNode.y = pos.y;
rabbonNode.angle = 60 * Math.random() - 30;
export async function jelly(node) {
return new Promise((resolve, reject) => {
cc.tween(node)
.to(0.1, { scaleX: 0.9, scaleY: 1.1 })
.to(0.1, { scaleX: 1.1, scaleY: 0.9 })
.to(0.1, { scaleX: 1, scaleY: 1 })
.call(resolve)
.start();
});
}
let node = cc.instantiate(nodeList[RandomInt(nodeList.length)]);
node.parent = rabbonNode;
node.active = true;
node.x = 0;
node.y = 0;
node.angle = 0;
export async function asyncDelay(time) {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve();
}, time * 1000);
});
}
const rate = Math.random();
const angle = Math.PI * (Math.random() * 2 - 1);
export async function showFireworks(
baseNode,
nodeList,
pos = cc.v2(0, 0),
side = cc.v2(0, 100),
range = 50,
number = 100
) {
new Array(number).fill(" ").forEach(async (_, i) => {
let rabbonNode = new cc.Node();
rabbonNode.parent = baseNode;
rabbonNode.x = pos.x;
rabbonNode.y = pos.y;
rabbonNode.angle = 60 * Math.random() - 30;
await asyncTweenBy(
rabbonNode,
0.3,
{
x: side.x * rate + Math.cos(angle) * range * rate,
y: side.y * rate + Math.sin(angle) * range * rate,
},
{
easing: "quadIn",
}
);
let node = cc.instantiate(nodeList[RandomInt(nodeList.length)]);
node.parent = rabbonNode;
node.active = true;
node.x = 0;
node.y = 0;
node.angle = 0;
const rate = Math.random();
const angle = Math.PI * (Math.random() * 2 - 1);
await asyncTweenBy(
rabbonNode,
0.3,
{
x: side.x * rate + Math.cos(angle) * range * rate,
y: side.y * rate + Math.sin(angle) * range * rate,
},
{
easing: "quadIn",
}
);
cc.tween(rabbonNode).by(8, { y: -2000 }).start();
cc.tween(rabbonNode).by(8, { y: -2000 }).start();
rabbonFall(rabbonNode);
rabbonFall(rabbonNode);
await asyncDelay(Math.random());
cc.tween(node)
.by(0.15, { x: -10, angle: -10 })
.by(0.3, { x: 20, angle: 20 })
.by(0.15, { x: -10, angle: -10 })
.union()
.repeatForever()
.start();
await asyncDelay(Math.random());
cc.tween(node)
.by(0.15, { x: -10, angle: -10 })
.by(0.3, { x: 20, angle: 20 })
.by(0.15, { x: -10, angle: -10 })
.union()
.repeatForever()
.start();
cc.tween(rabbonNode)
.delay(5)
.to(0.3, { opacity: 0 })
.call(() => {
node.stopAllActions();
node.active = false;
node.parent = null;
node = null;
})
.start();
});
}
cc.tween(rabbonNode)
.delay(5)
.to(0.3, { opacity: 0 })
.call(() => {
node.stopAllActions();
node.active = false;
node.parent = null;
node = null;
})
.start();
});
}
async function rabbonFall(node) {
const time = 1 + Math.random();
const offsetX = RandomInt(-200, 200) * time;
await asyncTweenBy(node, time, { x: offsetX, angle: (offsetX * 60) / 200 });
rabbonFall(node);
}
async function rabbonFall(node) {
const time = 1 + Math.random();
const offsetX = RandomInt(-200, 200) * time;
await asyncTweenBy(node, time, { x: offsetX, angle: (offsetX * 60) / 200 });
rabbonFall(node);
}
g.enum = {
E_Audio: {
Star: 0,//大星星
BtnCommom: 1,//按钮
Flowers: 2,//撒花
Right: 3,//正确
Error: 4,//错误
Question: 5,//题数
}
export function initEnumMgr_NGT_02() {
g.enum = {
E_Audio: {
Star: 0, //大星星
BtnCommom: 1, //按钮
Flowers: 2, //撒花
Right: 3, //正确
Error: 4, //错误
Question: 5, //题数
},
};
}
/**
* 音效
*/
var speaker = cc.Class({
extends: cc.Component,
extends: cc.Component,
properties: {
eff_audio: {
default: [],
type: cc.AudioClip,
displayName: "音效列表"
},
},
properties: {
eff_audio: {
default: [],
type: cc.AudioClip,
displayName: "音效列表",
},
},
ctor: function () {
speaker.inst = this;
g.speaker = speaker;
},
ctor: function () {
speaker.inst = this;
g.speaker = speaker;
},
// //播放音效
// playEffect: function (num, cb) {
// g.snd_mgr.playEffect(this.eff_audio[num], cb);
// },
// //播放音效
// playEffect: function (num, cb) {
// g.snd_mgr.playEffect(this.eff_audio[num], cb);
// },
playEffect: function (num, cb) {
g.snd_mgr.playMusic(this.eff_audio[num], 1, cb);
},
playEffect: function (num, cb) {
g.snd_mgr.playMusic(this.eff_audio[num], 1, cb);
},
});
/**
* 数据管理器
*/
function initDataMgr_NGT_02() {
export function initDataMgr_NGT_02() {
g.data_mgr = {
data: null, //表所有数据
......
function initEventMgr_NGT_02() {
export function initEventMgr_NGT_02() {
// 事件汞
let eventList = {}; // 响应列表(元素结构:eventName,[[target:cb]])
g.event_mgr = {
......
function initStorageMgr_NGT_02() {
export function initStorageMgr_NGT_02() {
// localStorage封装
g.local_storage = {
// 背景音乐音量
......
function initResMgr_NGT_02() {
export function initResMgr_NGT_02() {
/**
* 资源管理器
*/
......
function initSndMgr_NGT_02() {
export function initSndMgr_NGT_02() {
// 声音管理器
g.snd_mgr = {
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