Commit 96c2aee5 authored by 李维's avatar 李维

dev commit

parent 6a5753de
......@@ -216,7 +216,7 @@
"array": [
0,
0,
538.9790290334059,
527.4094709047232,
0,
0,
0,
......
......@@ -60,7 +60,8 @@ export default class GameLogic {
initNodes() {
this.g_cartoon.initCartoonElement("title_text", this.g_cartoon.getNodeByPath(`Canvas/title/text`))
for(let index=0; index<10; index++) {
this.g_cartoon.initCartoonElement(`card_${index+1}`, this.g_cartoon.getNodeByPath(`Canvas/card_${index+1}`))
const card = this.g_cartoon.initCartoonElement(`card_${index+1}`, this.g_cartoon.getNodeByPath(`Canvas/card_${index+1}`))
card.node.zIndex = 1
this.g_cartoon.initCartoonElement(`card_${index+1}_normal`, this.g_cartoon.getNodeByPath(`Canvas/card_${index+1}/normal`));
this.g_cartoon.initCartoonElement(`card_${index+1}_selected`, this.g_cartoon.getNodeByPath(`Canvas/card_${index+1}/selected`));
this.g_cartoon.initCartoonElement(`card_${index+1}_bell`, this.g_cartoon.getNodeByPath(`Canvas/card_${index+1}/bell`))
......@@ -100,11 +101,14 @@ export default class GameLogic {
for (let index = 0; index < 10; index++) {
let dataItem = this.g_formData.dataArray[newIndex[index]];
let card = this.g_cartoon.getCartoonElement(`card_${index+1}`)
card.open = false;
let cardNormal = this.g_cartoon.getCartoonElement(`card_${index+1}_normal`)
let cardSelected = this.g_cartoon.getCartoonElement(`card_${index+1}_selected`)
let imageContainer = this.g_cartoon.getCartoonElement(`card_${index+1}_image_container`)
imageContainer.cardIndex = index;
imageContainer.correctIndex = newIndex[index];
let bellOutline = this.g_cartoon.getCartoonElement(`card_${index+1}_bell_outline`)
let bellText = this.g_cartoon.getCartoonElement(`card_${index+1}_bell_text`)
bellText.node.getComponent(cc.Label).font = this.g_cartoon.getFontFamily("Comic Sans MS")
......@@ -128,18 +132,27 @@ export default class GameLogic {
bellOutline.node.setScale(0);
this.g_cartoon.subscribeTouchEvent(`card_${index+1}_image_container`, ()=>{
for(let i=0; i<10; i++) {
if(i!=index && i != this.m_currentQuestion) {
this.g_cartoon.getCartoonElement(`card_${i+1}_normal`).node.opacity = 255;
this.g_cartoon.getCartoonElement(`card_${i+1}_selected`).node.opacity = 0;
} else {
this.g_cartoon.getCartoonElement(`card_${i+1}_normal`).node.opacity = 0;
this.g_cartoon.getCartoonElement(`card_${i+1}_selected`).node.opacity = 255;
}
}
if(card.open) {
return;
}
// for(let i=0; i<10; i++) {
// if(i!=index && i != this.m_currentQuestion) {
// this.g_cartoon.getCartoonElement(`card_${i+1}_normal`).node.opacity = 255;
// this.g_cartoon.getCartoonElement(`card_${i+1}_selected`).node.opacity = 0;
// } else {
// this.g_cartoon.getCartoonElement(`card_${i+1}_normal`).node.opacity = 0;
// this.g_cartoon.getCartoonElement(`card_${i+1}_selected`).node.opacity = 255;
// }
// }
if(this.m_currentQuestion == imageContainer.correctIndex ) {
this.switchCard(this.m_currentQuestion, imageContainer.cardIndex)
this.loadQuestion()
card.open = true;
this.g_cartoon.getCartoonElement(`card_${imageContainer.cardIndex+1}_normal`).node.opacity = 0;
this.g_cartoon.getCartoonElement(`card_${imageContainer.cardIndex+1}_selected`).node.opacity = 255;
this.switchCard(this.m_currentQuestion, imageContainer.cardIndex, ()=>{
this.loadQuestion()
})
}
})
......@@ -171,23 +184,41 @@ export default class GameLogic {
}
}
switchCard(fromIndex, toIndex) {
switchCard(fromIndex, toIndex, callback) {
let i1 = this.m_currentQuestionArray[fromIndex]+1;
let i2 = this.m_currentQuestionArray[toIndex]
let card_1 = this.g_cartoon.getCartoonElement(`card_${i1}`)
let card_2 = this.g_cartoon.getCartoonElement(`card_${toIndex+1}`)
console.log("交换",`card_${i1}`,`card_${toIndex+1}`)
let x = card_1.node.x
let y = card_1.node.y
card_1.node.x = card_2.node.x
card_1.node.y = card_2.node.y
card_2.node.x = x;
card_2.node.y = y;
// console.log("交换",`card_${i1}`,`card_${toIndex+1}`)
let x_1 = card_1.node.x
let y_1 = card_1.node.y
let x_2 = card_2.node.x
let y_2 = card_2.node.y
toIndex = this.getCurrentIndex(toIndex)
let bellText1 = this.g_cartoon.getCartoonElement(`card_${i1}_bell_text`)
card_1.node.setSiblingIndex(100);
card_2.node.setSiblingIndex(100);
let bell1 = this.g_cartoon.getCartoonElement(`card_${i1}_bell`)
let bell2 = this.g_cartoon.getCartoonElement(`card_${toIndex+1}_bell`)
this.g_cartoon.tweenChange(bell1.node, {scaleX: 0, scaleY: 0}, 0.2, ()=>{
this.g_cartoon.tweenChange(card_1.node, {x: x_2, y: y_2}, 1, ()=>{
this.g_cartoon.tweenChange(bell1.node, {scaleX: 1, scaleY: 1}, 0.2);
});
});
this.g_cartoon.tweenChange(bell2.node, {scaleX: 0, scaleY: 0}, 0.2, ()=>{
this.g_cartoon.tweenChange(card_2.node, {x: x_1, y: y_1}, 1, ()=>{
this.g_cartoon.tweenChange(bell2.node, {scaleX: 1, scaleY: 1}, 0.2, ()=>{
if(callback) {
callback();
}
});
});
});
let bellText1 = this.g_cartoon.getCartoonElement(`card_${i1}_bell_text`)
let bellText2 = this.g_cartoon.getCartoonElement(`card_${toIndex+1}_bell_text`)
toIndex = this.getCurrentIndex(toIndex)
bellText1.node.getComponent(cc.Label).string = "" + (toIndex+1)
bellText2.node.getComponent(cc.Label).string = "" + (fromIndex+1)
......
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