Commit fb9c688e authored by Lwd's avatar Lwd

aaaa

parent 2ee5c039
This diff is collapsed.
...@@ -39,7 +39,12 @@ var game = cc.Class({ ...@@ -39,7 +39,12 @@ var game = cc.Class({
default: null, default: null,
type: cc.Label, type: cc.Label,
displayName: "标题" displayName: "标题"
} },
btnList: {
default: [],
type: cc.Button,
displayName: "上下页"
},
}, },
ctor: function () { ctor: function () {
...@@ -81,11 +86,54 @@ var game = cc.Class({ ...@@ -81,11 +86,54 @@ var game = cc.Class({
//游戏开始 //游戏开始
gameStart: function () { gameStart: function () {
//设置上下页按钮状态
this.setButtonState();
console.log("游戏开始:" + g.data_mgr); console.log("游戏开始:" + g.data_mgr);
//播放一个上面的音乐 //播放一个上面的音乐
this.setAudioInfo(1); this.setAudioInfo(1);
}, },
//设置上下页按钮状态
setButtonState: function () {
//先判断题目长度
if (g.data_mgr.data.contentObj.pageArr.length < 2) {
this.btnList[0].node.active = false;
this.btnList[1].node.active = false;
} else {
//如果第一页
if (g.data_mgr.pageId == 0) {
this.btnList[1].node.opacity = 255;
this.btnList[1].interactable = true;
this.btnList[0].node.opacity = 255 / 2;
this.btnList[0].interactable = false;
}
if (g.data_mgr.pageId == g.data_mgr.data.contentObj.pageArr.length - 1) {
this.btnList[0].node.opacity = 255;
this.btnList[0].interactable = true;
this.btnList[1].node.opacity = 255 / 2;
this.btnList[1].interactable = false;
}
}
},
//上一关
onBtnLastPage: function () {
if (g.data_mgr.pageId - 1 >= 0) {
g.data_mgr.pageId -= 1;
this.setButtonState();
this.onBtnReStart();
}
},
//下一关
onBtnNextPage: function () {
if (g.data_mgr.pageId + 1 < g.data_mgr.data.contentObj.pageArr.length) {
g.data_mgr.pageId += 1;
this.setButtonState();
this.onBtnReStart();
}
},
//获得随机播放的音乐并播放 //获得随机播放的音乐并播放
setAudioInfo: function (type) { setAudioInfo: function (type) {
//随机一个数字 播放这个数字的上段部分 //随机一个数字 播放这个数字的上段部分
...@@ -146,21 +194,6 @@ var game = cc.Class({ ...@@ -146,21 +194,6 @@ var game = cc.Class({
g.result.inst.updateUI(Info); g.result.inst.updateUI(Info);
}, },
//上一关
onBtnLastPage: function () {
if (g.data_mgr.pageId - 1 >= 0) {
g.data_mgr.pageId -= 1;
this.onBtnReStart();
}
},
//下一关
onBtnNextPage: function () {
if (g.data_mgr.pageId + 1 < g.data_mgr.data.contentObj.pageArr.length) {
g.data_mgr.pageId += 1;
this.onBtnReStart();
}
},
//播放音乐 //播放音乐
PlayAudio: function () { PlayAudio: function () {
......
...@@ -67,8 +67,8 @@ var result = cc.Class({ ...@@ -67,8 +67,8 @@ var result = cc.Class({
if (Info.type == "Spine") { if (Info.type == "Spine") {
g.res_mgr.loadSpine(this.Armature, Info); g.res_mgr.loadSpine(this.Armature, Info);
} }
this.initRichText(Info.groupLabel); this.initRichText(Info.groupLabel);
this.wellDone.active = false; this.wellDone.active = false;
this.frame_tips.active = true; this.frame_tips.active = true;
this.eff_sahua.node.active = false; this.eff_sahua.node.active = false;
...@@ -114,8 +114,8 @@ var result = cc.Class({ ...@@ -114,8 +114,8 @@ var result = cc.Class({
this.layoutText.getComponent(cc.Layout).updateLayout(); this.layoutText.getComponent(cc.Layout).updateLayout();
let width = this.layoutText.width; let width = this.layoutText.width;
if (width > 1000) { if (width > 850) {
let scale = 1000 / width; let scale = 850 / width;
this.layoutText.scale = scale; this.layoutText.scale = scale;
} }
}, },
...@@ -179,14 +179,21 @@ var result = cc.Class({ ...@@ -179,14 +179,21 @@ var result = cc.Class({
if (!this.layoutText.children[this.textIndex] || this.textIndex == this.layoutText.childrenCount) { if (!this.layoutText.children[this.textIndex] || this.textIndex == this.layoutText.childrenCount) {
this.isPlaying = false; this.isPlaying = false;
this.unschedule(this.chengeTextColor); this.unschedule(this.chengeTextColor);
if (g.data_mgr.temPlayAudio.length < 1) {
if (g.data_mgr.pageId == g.data_mgr.data.contentObj.pageArr.length - 1) {
//显示结算撒花
g.game.inst.showResult();
}
}
} }
this.layoutText.children[this.textIndex] && (this.layoutText.children[this.textIndex].color = new cc.Color().fromHEX(Color_texts[3])); this.layoutText.children[this.textIndex] && (this.layoutText.children[this.textIndex].color = new cc.Color().fromHEX(Color_texts[1]));
this.layoutText.children[this.textIndex - 1] && (this.layoutText.children[this.textIndex - 1].color = new cc.Color().fromHEX(Color_texts[1])); this.layoutText.children[this.textIndex - 1] && (this.layoutText.children[this.textIndex - 1].color = new cc.Color().fromHEX(Color_texts[3]));
this.textIndex++; this.textIndex++;
}, },
clearTextColor() { clearTextColor() {
for (let i = 0; i < this.layoutText.children.length; i++) { for (let i = 0; i < this.layoutText.children.length; i++) {
this.layoutText.children[i].color = new cc.Color().fromHEX(Color_texts[1]); this.layoutText.children[i].color = new cc.Color().fromHEX(Color_texts[3]);
} }
}, },
...@@ -201,6 +208,9 @@ var result = cc.Class({ ...@@ -201,6 +208,9 @@ var result = cc.Class({
//点击关闭 //点击关闭
onBtnClose: function () { onBtnClose: function () {
this.node.active = false; this.node.active = false;
this.stopSpine();
this.clearTextColor();
this.stopAudio();
//如果播放列表少于1则显示 //如果播放列表少于1则显示
if (this.End == false) { if (this.End == false) {
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