Commit 808f229f authored by 李维's avatar 李维

dev commit

parent cef31024
...@@ -139,7 +139,7 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -139,7 +139,7 @@ export class PlayComponent implements OnInit, OnDestroy {
m_hasActiveBlock = false; m_hasActiveBlock = false;
m_hasErrorLetter = false; m_hasErrorLetter = false;
m_currentInputIndex = 0; m_currentInputIndex = 0;
m_submited = false; m_submitedTimes = 0;
m_wordLetterInputCatch = []; m_wordLetterInputCatch = [];
m_canInput = true; m_canInput = true;
// ------------------------------------ // ------------------------------------
...@@ -297,6 +297,10 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -297,6 +297,10 @@ export class PlayComponent implements OnInit, OnDestroy {
y: 35 y: 35
} }
}) })
btnNext.active = (status) => {
btnNext.ref.visible = status;
btnNextShadow.ref.visible = status;
}
let btnPre = this.g_cartoon.createCartoonElementImageFunc("question_pre", "btn_pre", (w, h)=>{ let btnPre = this.g_cartoon.createCartoonElementImageFunc("question_pre", "btn_pre", (w, h)=>{
return { return {
...@@ -321,7 +325,11 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -321,7 +325,11 @@ export class PlayComponent implements OnInit, OnDestroy {
y: 35 y: 35
} }
}) })
btnPre.active = (status) => {
btnPre.ref.visible = status;
btnPreShadow.ref.visible = status;
}
let labelIndex = this.g_cartoon.createCartoonElementLabelFunc("question_index", "", "Aileron-Bold", "#3e9b31", 48, (w, h)=>{ let labelIndex = this.g_cartoon.createCartoonElementLabelFunc("question_index", "", "Aileron-Bold", "#3e9b31", 48, (w, h)=>{
return { return {
x: 0, x: 0,
...@@ -338,19 +346,16 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -338,19 +346,16 @@ export class PlayComponent implements OnInit, OnDestroy {
}) })
questionText.ref.text = "a fish whose head look like those of a horse" questionText.ref.text = "a fish whose head look like those of a horse"
this.subscribeMapDownEvent(btnNext.id, ()=>{ this.subscribeMapDownEvent(btnNext.id, async ()=>{
this.switchQuestion(this.m_currentQuestionIndex, this.m_currentQuestionIndex + 1); this.switchQuestion(this.m_currentQuestionIndex, this.m_currentQuestionIndex + 1);
this.showJellyAnimation(btnNext.id, ()=>{ await this.buttonPressAnimation(btnNext.id, btnNextShadow.id)
this.g_enableMapDown = true; this.g_enableMapDown = true;
})
}) })
this.subscribeMapDownEvent(btnPre.id, ()=>{ this.subscribeMapDownEvent(btnPre.id, async ()=>{
this.switchQuestion(this.m_currentQuestionIndex, this.m_currentQuestionIndex - 1); this.switchQuestion(this.m_currentQuestionIndex, this.m_currentQuestionIndex - 1);
this.showJellyAnimation(btnPre.id, ()=>{ await this.buttonPressAnimation(btnPre.id, btnPreShadow.id)
this.g_enableMapDown = true; this.g_enableMapDown = true;
})
}) })
element.ref.addChild(labelIndex.ref) element.ref.addChild(labelIndex.ref)
...@@ -404,11 +409,7 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -404,11 +409,7 @@ export class PlayComponent implements OnInit, OnDestroy {
let baseY = -820 / 2; let baseY = -820 / 2;
for(let i=1; i<=letttes.length; i++) { for(let i=1; i<=letttes.length; i++) {
let le = createWord(letttes[i-1], baseX, baseY) let le = createWord(letttes[i-1], baseX, baseY)
this.subscribeMapDownEvent(le.id, ()=>{ this.subscribeMapDownEvent(le.id, async ()=>{
this.showJellyAnimation(le.id, ()=>{
this.g_enableMapDown = true;
})
if(!this.m_canInput) { if(!this.m_canInput) {
return return
} }
...@@ -418,6 +419,8 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -418,6 +419,8 @@ export class PlayComponent implements OnInit, OnDestroy {
} else { } else {
target.setContentText(letttes[i-1].toLocaleLowerCase()) target.setContentText(letttes[i-1].toLocaleLowerCase())
} }
await this.buttonPressAnimation(le.id)
this.g_enableMapDown = true;
this.jumpToNextActive(this.m_currentQuestionIndex); this.jumpToNextActive(this.m_currentQuestionIndex);
}) })
allLetterRefs.push(le.ref.children[1]) allLetterRefs.push(le.ref.children[1])
...@@ -455,7 +458,7 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -455,7 +458,7 @@ export class PlayComponent implements OnInit, OnDestroy {
}) })
element.ref.addChild(btnShiftShadow.ref) element.ref.addChild(btnShiftShadow.ref)
element.ref.addChild(btnShift.ref) element.ref.addChild(btnShift.ref)
this.subscribeMapDownEvent(btnShift.id, ()=>{ this.subscribeMapDownEvent(btnShift.id, async ()=>{
this.m_openShift = !this.m_openShift; this.m_openShift = !this.m_openShift;
if(this.m_openShift) { if(this.m_openShift) {
allLetterRefs.forEach(le=>{ allLetterRefs.forEach(le=>{
...@@ -466,9 +469,8 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -466,9 +469,8 @@ export class PlayComponent implements OnInit, OnDestroy {
le.text = le.text.toLocaleLowerCase() le.text = le.text.toLocaleLowerCase()
}) })
} }
this.showJellyAnimation(btnShift.id, ()=>{ await this.buttonPressAnimation(btnShift.id, btnShiftShadow.id);
this.g_enableMapDown = true; this.g_enableMapDown = true;
})
}) })
this.render(element.ref) this.render(element.ref)
...@@ -626,16 +628,10 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -626,16 +628,10 @@ export class PlayComponent implements OnInit, OnDestroy {
} }
container.canSetActive = () => { container.canSetActive = () => {
return true if(container.isCorrect) {
// if(bgRight.ref.alpha == 1) { return false;
// return false;
// }
if(bgFocus.ref.alpha == 1 && this.m_blockFirstSubmit[this.m_currentQuestionIndex]) {
return true;
}
if(bgWrong.ref.alpha == 1) {
return true;
} }
return true
} }
container.setContentText = (letter) => { container.setContentText = (letter) => {
...@@ -652,13 +648,7 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -652,13 +648,7 @@ export class PlayComponent implements OnInit, OnDestroy {
container.checkStatus = (withRed=false, groupIndex) => { container.checkStatus = (withRed=false, groupIndex) => {
container.active(false); container.active(false);
if(container.getContentText() == "") { if(letter != container.getContentText()) {
container.switchStatus("focus");
if(!this.m_hasActiveBlock) {
this.m_hasActiveBlock = true;
container.active(true)
}
} else if(withRed && (letter != container.getContentText())) {
this.m_hasErrorLetter = true; this.m_hasErrorLetter = true;
container.switchStatus("wrong"); container.switchStatus("wrong");
if(!this.m_hasActiveBlock) { if(!this.m_hasActiveBlock) {
...@@ -674,36 +664,13 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -674,36 +664,13 @@ export class PlayComponent implements OnInit, OnDestroy {
container.checkWhenSwitchQuestion = (withRed, fromIndex, groupIndex, contentSaved?) => { container.checkWhenSwitchQuestion = (withRed, fromIndex, groupIndex, contentSaved?) => {
container.active(false); container.active(false);
// 没有点击提交就切换,清空
// if(!this.m_submited && questionIndex==fromIndex) {
// container.setContentText(contentSaved)
// }
if(groupIndex!= this.m_currentQuestionIndex) { if(groupIndex!= this.m_currentQuestionIndex) {
if(container.getContentText() == "") { if(container.getContentText() == "") {
container.switchStatus("init") container.switchStatus("init")
} else { } else {
container.switchStatus("disable") container.switchStatus("disable")
} }
// if(container.getContentText() == "") {
// container.switchStatus("init")
// } else if(letter != container.getContentText()) {
// container.switchStatus("wrong")
// } else {
// container.switchStatus("right")
// }
} else { } else {
// if(container.getContentText() == "") {
// container.switchStatus("right");
// } else {
// container.switchStatus("right");
// this.m_hasErrorLetter = true;
// container.switchStatus("wrong");
// if(!this.m_hasActiveBlock) {
// this.m_hasActiveBlock = true;
// this.m_currentInputIndex = groupIndex;
// container.active(true)
// }
// }
container.switchStatus("right") container.switchStatus("right")
if(!this.m_hasActiveBlock) { if(!this.m_hasActiveBlock) {
this.m_hasActiveBlock = true; this.m_hasActiveBlock = true;
...@@ -713,12 +680,14 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -713,12 +680,14 @@ export class PlayComponent implements OnInit, OnDestroy {
} }
this.subscribeMapDownEvent(container.id, ()=>{ this.subscribeMapDownEvent(container.id, ()=>{
if(this.m_currentQuestionIndex != questionIndex) {
this.switchQuestion(this.m_currentQuestionIndex, questionIndex)
}
if(container.canSetActive()) { if(container.canSetActive()) {
if(this.m_currentInput) { if(this.m_currentInput) {
let currentAcitveNode = this.g_cartoon.getCartoonElement(this.m_currentInput) let currentAcitveNode = this.g_cartoon.getCartoonElement(this.m_currentInput)
currentAcitveNode.active(false) currentAcitveNode.active(false)
this.m_currentInputIndex = li this.m_currentInputIndex = li
console.log(this.m_currentInputIndex)
} }
container.active(true); container.active(true);
} }
...@@ -773,11 +742,9 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -773,11 +742,9 @@ export class PlayComponent implements OnInit, OnDestroy {
} }
} }
} }
console.log(indexArr)
this.render(element.ref) this.render(element.ref)
} }
//
initSubmit() { initSubmit() {
let submit = this.g_cartoon.createCartoonElementImageFunc(`button_submit`, "btn_submit", (w, h)=>{ let submit = this.g_cartoon.createCartoonElementImageFunc(`button_submit`, "btn_submit", (w, h)=>{
return { return {
...@@ -803,11 +770,24 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -803,11 +770,24 @@ export class PlayComponent implements OnInit, OnDestroy {
} }
const handleSubmit = () => { const handleSubmit = () => {
this.m_submited = true; this.m_submitedTimes++;
this.m_submitTimes[this.m_currentQuestionIndex]++; this.m_submitTimes[this.m_currentQuestionIndex]++;
this.m_blockFirstSubmit[this.m_currentQuestionIndex] = false; this.m_blockFirstSubmit[this.m_currentQuestionIndex] = false;
this.m_currentInputIndex = 0; this.m_currentInputIndex = 0;
let status = this.updateStatusByGroupIndex(this.m_currentQuestionIndex); let hasIncorrect = false;
let status = false;
this.m_hasActiveBlock = false;
this.m_blockGroup.forEach((group, index) => {
status = this.updateStatusByGroupIndex(index)
if(!hasIncorrect && !status) {
hasIncorrect = true;
}
})
if(hasIncorrect) {
console.log("有错误")
} else{
console.log("全部正确")
}
// console.log(status) // console.log(status)
// this.switchQuestion(this.m_currentQuestionIndex, this.m_currentQuestionIndex+1) // this.switchQuestion(this.m_currentQuestionIndex, this.m_currentQuestionIndex+1)
submit.switchActive(false) submit.switchActive(false)
...@@ -848,39 +828,30 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -848,39 +828,30 @@ export class PlayComponent implements OnInit, OnDestroy {
}); });
/* /*
this.m_wordLetterInputCatch = []
this.m_blockGroup[toIndex].forEach(block => {
this.m_wordLetterInputCatch.push(block.getContentText())
});
let indexText = this.g_cartoon.getCartoonElement("IndexText") let indexText = this.g_cartoon.getCartoonElement("IndexText")
indexText.setIndex(toIndex); indexText.setIndex(toIndex);
let questionText = this.g_cartoon.getCartoonElement("QuestionText"); let questionText = this.g_cartoon.getCartoonElement("QuestionText");
questionText.setContent(this.g_formData.dataArray[toIndex].text) questionText.setContent(this.g_formData.dataArray[toIndex].text)
*/
let nextButton = this.g_cartoon.getCartoonElement("NextButton") let nextButton = this.g_cartoon.getCartoonElement("question_next")
if(this.g_formData.dataArray.length>toIndex+1) { if(this.g_formData.dataArray.length>toIndex+1) {
nextButton.active(true) nextButton.active(true)
} else { } else {
nextButton.active(false) nextButton.active(false)
} }
let preButton = this.g_cartoon.getCartoonElement("PreButton") let preButton = this.g_cartoon.getCartoonElement("question_pre")
if(toIndex>0) { if(toIndex>0) {
preButton.active(true) preButton.active(true)
} else { } else {
preButton.active(false) preButton.active(false)
} }
this.m_submited = false;
// this.setKeyboard(this.m_wordAll[toIndex])
*/
} }
// submit响应事件,会标红错误 // submit响应事件,会标红错误
updateStatusByGroupIndex(index) { updateStatusByGroupIndex(index) {
let blocks = this.m_blockGroup[index]; let blocks = this.m_blockGroup[index];
this.m_hasActiveBlock = false;
this.m_hasErrorLetter = false; this.m_hasErrorLetter = false;
blocks.forEach((item, index) => { blocks.forEach((item, index) => {
item.checkStatus(true, index) item.checkStatus(true, index)
...@@ -898,7 +869,6 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -898,7 +869,6 @@ export class PlayComponent implements OnInit, OnDestroy {
// 跳转下一个焦点输入框 // 跳转下一个焦点输入框
jumpToNextActive(index) { jumpToNextActive(index) {
console.log("jumpToNextActive m_currentInputIndex", this.m_currentInputIndex)
let blocks = this.m_blockGroup[index]; let blocks = this.m_blockGroup[index];
this.m_hasActiveBlock = false; this.m_hasActiveBlock = false;
...@@ -1977,6 +1947,42 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -1977,6 +1947,42 @@ export class PlayComponent implements OnInit, OnDestroy {
return petal; return petal;
} }
buttonPressAnimation(buttonID, shadowID?, callback?) {
let button = buttonID ? this.g_cartoon.getCartoonElement(buttonID).ref : null;
let shadow = shadowID ? this.g_cartoon.getCartoonElement(shadowID).ref : null;
let pAll = []
pAll.push(new Promise((resovle, reject) => {
let initY = button.y
button.y += 10
tweenChange(button,{ scaleX: button.initScaleX * 1.02 , scaleY: button.initScaleY * 1.02 }, 0.05, ()=>{
tweenChange(button,{ scaleX: button.initScaleX * 0.98 , scaleY: button.initScaleY * 0.98 }, 0.05, ()=>{
tweenChange(button,{ scaleX: button.initScaleX , scaleY: button.initScaleY }, 0.1, ()=>{
button.y = initY;
callback && callback()
resovle(null)
})
})
})
}))
if(shadow) {
pAll.push(new Promise((resovle, reject) => {
let initY = shadow.y
shadow.y -= 10
tweenChange(shadow,{ scaleX: shadow.initScaleX * 1.02 , scaleY: shadow.initScaleY * 1.02 }, 0.05, ()=>{
tweenChange(shadow,{ scaleX: shadow.initScaleX * 0.98 , scaleY: shadow.initScaleY * 0.98 }, 0.05, ()=>{
tweenChange(shadow,{ scaleX: shadow.initScaleX , scaleY: shadow.initScaleY }, 0.1, ()=>{
shadow.y = initY;
callback && callback()
resovle(null)
})
})
})
}))
}
return Promise.all(pAll)
}
showJellyAnimation(element_id, callback?){ showJellyAnimation(element_id, callback?){
let element = this.g_cartoon.getCartoonElement(element_id).ref let element = this.g_cartoon.getCartoonElement(element_id).ref
......
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