Commit 6a5753de authored by 李维's avatar 李维

dev commit

parent 907b27de
...@@ -95,7 +95,8 @@ export default class GameLogic { ...@@ -95,7 +95,8 @@ export default class GameLogic {
initImageCards() { initImageCards() {
let newIndex = this.getRandomArray(10) let newIndex = this.getRandomArray(10)
this.m_currentQuestionArray = [1,2,3,4,5,6,7,8,9,10] console.log("正确序号:", newIndex)
this.m_currentQuestionArray = [0,1,2,3,4,5,6,7,8,9]
for (let index = 0; index < 10; index++) { for (let index = 0; index < 10; index++) {
let dataItem = this.g_formData.dataArray[newIndex[index]]; let dataItem = this.g_formData.dataArray[newIndex[index]];
let card = this.g_cartoon.getCartoonElement(`card_${index+1}`) let card = this.g_cartoon.getCartoonElement(`card_${index+1}`)
...@@ -106,7 +107,6 @@ export default class GameLogic { ...@@ -106,7 +107,6 @@ export default class GameLogic {
imageContainer.correctIndex = newIndex[index]; imageContainer.correctIndex = newIndex[index];
let bellOutline = this.g_cartoon.getCartoonElement(`card_${index+1}_bell_outline`) let bellOutline = this.g_cartoon.getCartoonElement(`card_${index+1}_bell_outline`)
let bellText = this.g_cartoon.getCartoonElement(`card_${index+1}_bell_text`) let bellText = this.g_cartoon.getCartoonElement(`card_${index+1}_bell_text`)
bellText.node.getComponent(cc.Label).font = this.g_cartoon.getFontFamily("Comic Sans MS") bellText.node.getComponent(cc.Label).font = this.g_cartoon.getFontFamily("Comic Sans MS")
bellText.node.getComponent(cc.Label).fontSize = 20 bellText.node.getComponent(cc.Label).fontSize = 20
...@@ -137,9 +137,8 @@ export default class GameLogic { ...@@ -137,9 +137,8 @@ export default class GameLogic {
this.g_cartoon.getCartoonElement(`card_${i+1}_selected`).node.opacity = 255; this.g_cartoon.getCartoonElement(`card_${i+1}_selected`).node.opacity = 255;
} }
} }
console.log(this.m_currentQuestion, imageContainer.correctIndex)
if(this.m_currentQuestion == imageContainer.correctIndex ) { if(this.m_currentQuestion == imageContainer.correctIndex ) {
this.switchCard(imageContainer.correctIndex, imageContainer.cardIndex) this.switchCard(this.m_currentQuestion, imageContainer.cardIndex)
this.loadQuestion() this.loadQuestion()
} }
}) })
...@@ -173,11 +172,11 @@ export default class GameLogic { ...@@ -173,11 +172,11 @@ export default class GameLogic {
} }
switchCard(fromIndex, toIndex) { switchCard(fromIndex, toIndex) {
fromIndex = this.getCurrentIndex(fromIndex+1) let i1 = this.m_currentQuestionArray[fromIndex]+1;
toIndex = this.getCurrentIndex(toIndex+1) let i2 = this.m_currentQuestionArray[toIndex]
let card_1 = this.g_cartoon.getCartoonElement(`card_${i1}`)
let card_1 = this.g_cartoon.getCartoonElement(`card_${fromIndex+1}`)
let card_2 = this.g_cartoon.getCartoonElement(`card_${toIndex+1}`) let card_2 = this.g_cartoon.getCartoonElement(`card_${toIndex+1}`)
console.log("交换",`card_${i1}`,`card_${toIndex+1}`)
let x = card_1.node.x let x = card_1.node.x
let y = card_1.node.y let y = card_1.node.y
card_1.node.x = card_2.node.x card_1.node.x = card_2.node.x
...@@ -185,11 +184,16 @@ export default class GameLogic { ...@@ -185,11 +184,16 @@ export default class GameLogic {
card_2.node.x = x; card_2.node.x = x;
card_2.node.y = y; card_2.node.y = y;
console.log("A", fromIndex, toIndex) toIndex = this.getCurrentIndex(toIndex)
let bellText1 = this.g_cartoon.getCartoonElement(`card_${i1}_bell_text`)
let bellText2 = this.g_cartoon.getCartoonElement(`card_${toIndex+1}_bell_text`)
bellText1.node.getComponent(cc.Label).string = "" + (toIndex+1)
bellText2.node.getComponent(cc.Label).string = "" + (fromIndex+1)
let temp = this.m_currentQuestionArray[fromIndex] let temp = this.m_currentQuestionArray[fromIndex]
this.m_currentQuestionArray[fromIndex] = this.m_currentQuestionArray[toIndex] this.m_currentQuestionArray[fromIndex] = this.m_currentQuestionArray[toIndex]
this.m_currentQuestionArray[toIndex] = temp; this.m_currentQuestionArray[toIndex] = temp;
console.log("B", this.m_currentQuestionArray)
} }
getCurrentIndex(index) { getCurrentIndex(index) {
...@@ -286,18 +290,15 @@ export default class GameLogic { ...@@ -286,18 +290,15 @@ export default class GameLogic {
} }
loadQuestion() { loadQuestion() {
let index = this.m_currentQuestionArray[this.m_currentQuestion] let index = null;
console.log("loadQuestion", index, this.m_currentQuestion) for(let i=0; i<10; i++) {
if(this.m_currentQuestion != -1) { this.g_cartoon.getCartoonElement(`card_${i+1}_normal`).node.opacity = 255;
index = this.m_currentQuestionArray[this.m_currentQuestion]; this.g_cartoon.getCartoonElement(`card_${i+1}_selected`).node.opacity = 0;
this.g_cartoon.getCartoonElement(`card_${index}_normal`).node.opacity = 255;
this.g_cartoon.getCartoonElement(`card_${index}_selected`).node.opacity = 0;
} }
this.m_currentQuestion++; this.m_currentQuestion++;
index = this.m_currentQuestionArray[this.m_currentQuestion] index = this.m_currentQuestionArray[this.m_currentQuestion]
console.log("loadQuestion", index, this.m_currentQuestion) this.g_cartoon.getCartoonElement(`card_${index+1}_normal`).node.opacity = 0;
this.g_cartoon.getCartoonElement(`card_${index}_normal`).node.opacity = 0; this.g_cartoon.getCartoonElement(`card_${index+1}_selected`).node.opacity = 255;
this.g_cartoon.getCartoonElement(`card_${index}_selected`).node.opacity = 255;
} }
initQuestionPannel() { initQuestionPannel() {
......
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