Commit a716cdba authored by huoshizhe's avatar huoshizhe

feat:

parent 37bc2229
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html // - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
// import { getSprNode } from "./util"; // import { getSprNode } from "./util";
import { getSprNode, playAudioByUrl, showBtnAnima, getScaleRateBy2Node, localPosTolocalPos, randomSortByArr, loadDragonBones, playAudio, showTrebleFirework, getSprNodeByUrl, setSprNodeMaxLen, delayCall, asyncDelay, RandomInt, exchangeNodePos, onHomeworkFinish} from "./util"; import { getSprNode, playAudioByUrl, showBtnAnima, getScaleRateBy2Node, localPosTolocalPos, randomSortByArr, loadDragonBones, playAudio, showTrebleFirework, getSprNodeByUrl, setSprNodeMaxLen, delayCall, asyncDelay, RandomInt, exchangeNodePos, onHomeworkFinish } from "./util";
cc.Class({ cc.Class({
extends: cc.Component, extends: cc.Component,
...@@ -99,14 +99,14 @@ cc.Class({ ...@@ -99,14 +99,14 @@ cc.Class({
window.courseware.getData(func, 'dfzx_cocos_dqq'); window.courseware.getData(func, 'dfzx_cocos_dqq');
return; return;
} }
const middleLayer = cc.find('middleLayer'); const middleLayer = cc.find('middleLayer');
if (middleLayer) { if (middleLayer) {
const middleLayerComponent = middleLayer.getComponent('middleLayer'); const middleLayerComponent = middleLayer.getComponent('middleLayer');
middleLayerComponent.getData(func); middleLayerComponent.getData(func);
return; return;
} }
func(this.getDefaultData()); func(this.getDefaultData());
}, },
...@@ -184,7 +184,7 @@ cc.Class({ ...@@ -184,7 +184,7 @@ cc.Class({
}, },
addPreloadImage() { addPreloadImage() {
if (this.data.pic_url) { if (this.data.pic_url) {
this._imageResList.push({ url: this.data.pic_url }); this._imageResList.push({ url: this.data.pic_url });
} }
...@@ -206,9 +206,9 @@ cc.Class({ ...@@ -206,9 +206,9 @@ cc.Class({
if (this.data.questionArr) { if (this.data.questionArr) {
const arr = this.data.questionArr; const arr = this.data.questionArr;
for (let i=0 ;i<arr.length; i++) { for (let i = 0; i < arr.length; i++) {
this._audioResList.push({url: arr[i].audio_url || ''}); this._audioResList.push({ url: arr[i].audio_url || '' });
this._audioResList.push({url: arr[i].video_url || ''}); this._audioResList.push({ url: arr[i].video_url || '' });
} }
} }
...@@ -221,8 +221,8 @@ cc.Class({ ...@@ -221,8 +221,8 @@ cc.Class({
this.data.hotZoneItemArr.forEach((item) => { this.data.hotZoneItemArr.forEach((item) => {
if (item.skeJsonData) { if (item.skeJsonData) {
this._animaResList.push({ url: item.skeJsonData.url || '' }); this._animaResList.push({ url: item.skeJsonData.url || '' });
this._animaResList.push({ url: item.texJsonData.url || ''}); this._animaResList.push({ url: item.texJsonData.url || '' });
this._animaResList.push({ url: item.texPngData.url || ''}); this._animaResList.push({ url: item.texPngData.url || '' });
} }
}) })
}, },
...@@ -361,7 +361,7 @@ cc.Class({ ...@@ -361,7 +361,7 @@ cc.Class({
cleanStar() { cleanStar() {
if (this.bigStarArr && this.bigStarArr.length > 0) { if (this.bigStarArr && this.bigStarArr.length > 0) {
for (let i=0; i<this.bigStarArr.length; i++) { for (let i = 0; i < this.bigStarArr.length; i++) {
this.bigStarArr[i].removeFromParent(); this.bigStarArr[i].removeFromParent();
} }
} }
...@@ -420,8 +420,8 @@ cc.Class({ ...@@ -420,8 +420,8 @@ cc.Class({
}, },
checkGameEnd() { checkGameEnd() {
this.curGroupIndex ++; this.curGroupIndex++;
this.setCurGroupAndQuestion(); this.setCurGroupAndQuestion();
...@@ -462,7 +462,7 @@ cc.Class({ ...@@ -462,7 +462,7 @@ cc.Class({
this.checkBtn.opacity = 0; this.checkBtn.opacity = 0;
const arr = this.curOptionArr; const arr = this.curOptionArr;
for (let i=0; i<arr.length; i++) { for (let i = 0; i < arr.length; i++) {
if (arr[i].light.opacity > 254) { if (arr[i].light.opacity > 254) {
this.checkBtn.opacity = 255; this.checkBtn.opacity = 255;
return; return;
...@@ -483,9 +483,9 @@ cc.Class({ ...@@ -483,9 +483,9 @@ cc.Class({
showTryAgain() { showTryAgain() {
const time = 0.3; const time = 0.3;
cc.tween(this.tryagain) cc.tween(this.tryagain)
.to(time, {opacity: 255}, {easing: "cubicOut"}) .to(time, { opacity: 255 }, { easing: "cubicOut" })
.delay(0.3) .delay(0.3)
.to(time, {opacity: 0}, {easing: "cubicIn"}) .to(time, { opacity: 0 }, { easing: "cubicIn" })
.start(); .start();
}, },
...@@ -529,7 +529,7 @@ cc.Class({ ...@@ -529,7 +529,7 @@ cc.Class({
label.horizontalAlign = cc.macro.TextAlignment.CENTER label.horizontalAlign = cc.macro.TextAlignment.CENTER
label.maxWidth = 648; label.maxWidth = 648;
picBg.label = label; picBg.label = label;
picBg.active = false; picBg.active = false;
...@@ -596,7 +596,7 @@ cc.Class({ ...@@ -596,7 +596,7 @@ cc.Class({
quesAudioBg: null, quesAudioBg: null,
initAudioQuestion() { initAudioQuestion() {
const audioNode = new cc.Node(); const audioNode = new cc.Node();
audioNode.active = false; audioNode.active = false;
...@@ -604,7 +604,7 @@ cc.Class({ ...@@ -604,7 +604,7 @@ cc.Class({
audioNode.x = 440 * this._mapScaleMin; audioNode.x = 440 * this._mapScaleMin;
audioNode.y = -60 * this._mapScaleMin; audioNode.y = -60 * this._mapScaleMin;
this.quesAudioBg = audioNode; this.quesAudioBg = audioNode;
const audioAnimNode = cc.instantiate(cc.find("Canvas/res/anim/audio_big")); const audioAnimNode = cc.instantiate(cc.find("Canvas/res/anim/audio_big"));
audioNode.addChild(audioAnimNode); audioNode.addChild(audioAnimNode);
...@@ -689,15 +689,15 @@ cc.Class({ ...@@ -689,15 +689,15 @@ cc.Class({
initPicOption() { initPicOption() {
// console.log('this.data: ', this.data); // console.log('this.data: ', this.data);
this.optionPicBgArr = []; this.optionPicBgArr = [];
for (let i=0; i<4; i++) { for (let i = 0; i < 4; i++) {
const pic = this.getOnePicOption(); const pic = this.getOnePicOption();
this.canvas.addChild(pic); this.canvas.addChild(pic);
pic.scale = this._mapScaleMin; pic.scale = this._mapScaleMin;
pic.y = -235 * this._mapScaleMin; pic.y = -235 * this._mapScaleMin;
this.optionPicBgArr.push(pic); this.optionPicBgArr.push(pic);
} }
}, },
optionPicBgBigArr: null, optionPicBgBigArr: null,
...@@ -711,9 +711,9 @@ cc.Class({ ...@@ -711,9 +711,9 @@ cc.Class({
let count = 0; let count = 0;
for (let i=0; i<4; i++) { for (let i = 0; i < 4; i++) {
if (i==2) { if (i == 2) {
count = 0; count = 0;
baseY -= disH; baseY -= disH;
} }
...@@ -724,8 +724,8 @@ cc.Class({ ...@@ -724,8 +724,8 @@ cc.Class({
pic.y = baseY; pic.y = baseY;
this.optionPicBgBigArr.push(pic); this.optionPicBgBigArr.push(pic);
count ++; count++;
} }
}, },
getOnePicOption(isBig = false) { getOnePicOption(isBig = false) {
...@@ -772,7 +772,7 @@ cc.Class({ ...@@ -772,7 +772,7 @@ cc.Class({
picBgParent.on(cc.Node.EventType.TOUCH_START, () => { picBgParent.on(cc.Node.EventType.TOUCH_START, () => {
if( light.opacity == 0 ) { if (light.opacity == 0) {
light.opacity = 255; light.opacity = 255;
playAudio(this.selectClip); playAudio(this.selectClip);
} else { } else {
...@@ -805,7 +805,7 @@ cc.Class({ ...@@ -805,7 +805,7 @@ cc.Class({
addIconRight(bg) { addIconRight(bg) {
const px = bg.width / 2; const px = bg.width / 2;
const py = -bg.height / 2 ; const py = -bg.height / 2;
const worldPos = bg.convertToWorldSpaceAR(cc.v2(px, py)); const worldPos = bg.convertToWorldSpaceAR(cc.v2(px, py));
const localPos = this.canvas.convertToNodeSpaceAR(worldPos); const localPos = this.canvas.convertToNodeSpaceAR(worldPos);
...@@ -826,14 +826,14 @@ cc.Class({ ...@@ -826,14 +826,14 @@ cc.Class({
optionAudioBgArr: null, optionAudioBgArr: null,
initAudioOption() { initAudioOption() {
this.optionAudioBgArr = []; this.optionAudioBgArr = [];
for (let i=0; i<4; i++) { for (let i = 0; i < 4; i++) {
const audio = this.getOneAudioOption(); const audio = this.getOneAudioOption();
this.canvas.addChild(audio); this.canvas.addChild(audio);
audio.scale = this._mapScaleMin; audio.scale = this._mapScaleMin;
audio.y = -235 * this._mapScaleMin; audio.y = -235 * this._mapScaleMin;
this.optionAudioBgArr.push(audio); this.optionAudioBgArr.push(audio);
} }
}, },
optionAudioBgBigArr: null, optionAudioBgBigArr: null,
...@@ -847,9 +847,9 @@ cc.Class({ ...@@ -847,9 +847,9 @@ cc.Class({
const disH = 350 * this._mapScaleMin; const disH = 350 * this._mapScaleMin;
let count = 0; let count = 0;
for (let i=0; i<4; i++) { for (let i = 0; i < 4; i++) {
if (i==2) { if (i == 2) {
count = 0; count = 0;
baseY -= disH; baseY -= disH;
} }
...@@ -861,22 +861,22 @@ cc.Class({ ...@@ -861,22 +861,22 @@ cc.Class({
audio.y = baseY; audio.y = baseY;
this.optionAudioBgBigArr.push(audio); this.optionAudioBgBigArr.push(audio);
count ++; count++;
} }
}, },
optionTextBgArr: null, optionTextBgArr: null,
initTextOption() { initTextOption() {
this.optionTextBgArr = []; this.optionTextBgArr = [];
for (let i=0; i<4; i++) { for (let i = 0; i < 4; i++) {
const textOption = this.getOneTextOption(); const textOption = this.getOneTextOption();
this.canvas.addChild(textOption); this.canvas.addChild(textOption);
textOption.scale = this._mapScaleMin; textOption.scale = this._mapScaleMin;
// textOption.y = -235 * this._mapScaleMin; // textOption.y = -235 * this._mapScaleMin;
this.optionTextBgArr.push(textOption); this.optionTextBgArr.push(textOption);
} }
}, },
optionTextBgBigArr: null, optionTextBgBigArr: null,
...@@ -888,8 +888,8 @@ cc.Class({ ...@@ -888,8 +888,8 @@ cc.Class({
const disH = 150 * this._mapScaleMin; const disH = 150 * this._mapScaleMin;
this.optionTextBgBigArr = []; this.optionTextBgBigArr = [];
for (let i=0; i<4; i++) { for (let i = 0; i < 4; i++) {
const textOption = this.getOneTextOption(true); const textOption = this.getOneTextOption(true);
this.canvas.addChild(textOption); this.canvas.addChild(textOption);
textOption.scale = this._mapScaleMin; textOption.scale = this._mapScaleMin;
...@@ -899,7 +899,7 @@ cc.Class({ ...@@ -899,7 +899,7 @@ cc.Class({
} }
}, },
getOneAudioOption(isBig=false) { getOneAudioOption(isBig = false) {
let lightResName = "option_pic_bg_l"; let lightResName = "option_pic_bg_l";
let bgResName = "option_pic_bg"; let bgResName = "option_pic_bg";
...@@ -937,7 +937,7 @@ cc.Class({ ...@@ -937,7 +937,7 @@ cc.Class({
audioBgNode.anim = anim; audioBgNode.anim = anim;
audioBgNode.animNode = animNode; audioBgNode.animNode = animNode;
audioBgNode.animTop = animTop; audioBgNode.animTop = animTop;
audioBgNode.showAnim = () => { audioBgNode.showAnim = () => {
this.playItemAnim(audioBgNode); this.playItemAnim(audioBgNode);
cc.audioEngine.stop(audioBgNode.audioId); cc.audioEngine.stop(audioBgNode.audioId);
...@@ -948,10 +948,10 @@ cc.Class({ ...@@ -948,10 +948,10 @@ cc.Class({
} }
audioBgNode.on(cc.Node.EventType.TOUCH_START, () => { audioBgNode.on(cc.Node.EventType.TOUCH_START, () => {
if( light.opacity == 0 ) { if (light.opacity == 0) {
light.opacity = 255; light.opacity = 255;
playAudio(this.selectClip); playAudio(this.selectClip);
audioBgNode.showAnim(); audioBgNode.showAnim();
if (audioBgNode.audioClip) { if (audioBgNode.audioClip) {
audioBgNode.audioId = playAudio(audioBgNode.audioClip, () => { audioBgNode.audioId = playAudio(audioBgNode.audioClip, () => {
...@@ -973,7 +973,7 @@ cc.Class({ ...@@ -973,7 +973,7 @@ cc.Class({
return audioBgNode; return audioBgNode;
}, },
getOneTextOption(isBig=false) { getOneTextOption(isBig = false) {
let lightResName = "option_text_bg_l"; let lightResName = "option_text_bg_l";
let bgResName = "option_text_bg"; let bgResName = "option_text_bg";
...@@ -1012,7 +1012,7 @@ cc.Class({ ...@@ -1012,7 +1012,7 @@ cc.Class({
textBgParent.label = label; textBgParent.label = label;
const color = new cc.Color(); const color = new cc.Color();
cc.Color.fromHEX(color, '#023659' ); cc.Color.fromHEX(color, '#023659');
labelNode.color = color; labelNode.color = color;
...@@ -1034,7 +1034,7 @@ cc.Class({ ...@@ -1034,7 +1034,7 @@ cc.Class({
textBgParent.on(cc.Node.EventType.TOUCH_START, () => { textBgParent.on(cc.Node.EventType.TOUCH_START, () => {
if( light.opacity == 0 ) { if (light.opacity == 0) {
light.opacity = 255; light.opacity = 255;
playAudio(this.selectClip); playAudio(this.selectClip);
} else { } else {
...@@ -1075,8 +1075,8 @@ cc.Class({ ...@@ -1075,8 +1075,8 @@ cc.Class({
}, },
setCurQuestion() { setCurQuestion() {
switch(this.curQuestionData.questionType) { switch (this.curQuestionData.questionType) {
case "pic": case "pic":
this.setQuestionPic(); this.setQuestionPic();
break; break;
...@@ -1123,14 +1123,14 @@ cc.Class({ ...@@ -1123,14 +1123,14 @@ cc.Class({
this.quesPicBg.pic = sprNode; this.quesPicBg.pic = sprNode;
}) })
} }
const audioNode = this.quesPicBg.audioNode; const audioNode = this.quesPicBg.audioNode;
audioNode.active = false; audioNode.active = false;
audioNode.audioClip = null; audioNode.audioClip = null;
if (this.curQuestionData.audio_url) { if (this.curQuestionData.audio_url) {
cc.assetManager.loadRemote(this.curQuestionData.audio_url, (err, audioClip) => { cc.assetManager.loadRemote(this.curQuestionData.audio_url, (err, audioClip) => {
audioNode.audioClip = audioClip; audioNode.audioClip = audioClip;
}); });
audioNode.active = true; audioNode.active = true;
} }
}, },
...@@ -1139,9 +1139,9 @@ cc.Class({ ...@@ -1139,9 +1139,9 @@ cc.Class({
this.curQuesBg = this.quesTextBg; this.curQuesBg = this.quesTextBg;
this.curQuesBg.active = true; this.curQuesBg.active = true;
const label = this.curQuesBg.label; const label = this.curQuesBg.label;
const size = 80; const size = 80;
label.string = `<size=${size}><color=#fff4b6>${this.curQuestionData.text}</color></size>` label.string = `<size=${size}><color=#fff4b6>${this.curQuestionData.text}</color></size>`
const maxH = this.curQuesBg.height * 0.98; const maxH = this.curQuesBg.height * 0.98;
...@@ -1159,7 +1159,7 @@ cc.Class({ ...@@ -1159,7 +1159,7 @@ cc.Class({
if (this.curQuestionData.audio_url) { if (this.curQuestionData.audio_url) {
cc.assetManager.loadRemote(this.curQuestionData.audio_url, (err, audioClip) => { cc.assetManager.loadRemote(this.curQuestionData.audio_url, (err, audioClip) => {
audioNode.audioClip = audioClip; audioNode.audioClip = audioClip;
}); });
audioNode.active = true; audioNode.active = true;
} }
}, },
...@@ -1194,7 +1194,7 @@ cc.Class({ ...@@ -1194,7 +1194,7 @@ cc.Class({
const isBig = this.curQuestionData.questionType == 'audio'; const isBig = this.curQuestionData.questionType == 'audio';
switch(this.curQuestionData.answerType) { switch (this.curQuestionData.answerType) {
case "pic": case "pic":
this.setOptionPic(arr, isBig); this.setOptionPic(arr, isBig);
break; break;
...@@ -1205,13 +1205,13 @@ cc.Class({ ...@@ -1205,13 +1205,13 @@ cc.Class({
this.setOptionText(arr, isBig); this.setOptionText(arr, isBig);
break; break;
} }
}, },
curOptionArr: null, curOptionArr: null,
setOptionPic(arr, isBig=false) { setOptionPic(arr, isBig = false) {
let opItemArr = this.optionPicBgArr; let opItemArr = this.optionPicBgArr;
if (isBig) { if (isBig) {
...@@ -1220,8 +1220,8 @@ cc.Class({ ...@@ -1220,8 +1220,8 @@ cc.Class({
this.curOptionArr = []; this.curOptionArr = [];
const disW = 158 * this._mapScaleMin; const disW = 158 * this._mapScaleMin;
const baseX = -(arr.length - 1) * disW; const baseX = -(arr.length - 1) * disW;
for (let i=0; i<arr.length; i++) { for (let i = 0; i < arr.length; i++) {
opItemArr[i].active = true; opItemArr[i].active = true;
if (!isBig) { if (!isBig) {
opItemArr[i].x = baseX + i * disW * 2; opItemArr[i].x = baseX + i * disW * 2;
...@@ -1229,7 +1229,7 @@ cc.Class({ ...@@ -1229,7 +1229,7 @@ cc.Class({
const picBg = opItemArr[i].picBg; const picBg = opItemArr[i].picBg;
picBg.removeAllChildren(); picBg.removeAllChildren();
const data = arr[i]; const data = arr[i];
if (data.pic_url) { if (data.pic_url) {
getSprNodeByUrl, getSprNodeByUrl(data.pic_url, (spr) => { getSprNodeByUrl, getSprNodeByUrl(data.pic_url, (spr) => {
...@@ -1255,7 +1255,7 @@ cc.Class({ ...@@ -1255,7 +1255,7 @@ cc.Class({
soundIcon.audioClip = audioClip; soundIcon.audioClip = audioClip;
opItemArr[i].audioClip = audioClip; opItemArr[i].audioClip = audioClip;
}); });
soundIcon.active = true; soundIcon.active = true;
} }
...@@ -1265,7 +1265,7 @@ cc.Class({ ...@@ -1265,7 +1265,7 @@ cc.Class({
}, },
setOptionAudio(arr, isBig=false) { setOptionAudio(arr, isBig = false) {
let opItemArr = this.optionAudioBgArr; let opItemArr = this.optionAudioBgArr;
if (isBig) { if (isBig) {
...@@ -1275,10 +1275,10 @@ cc.Class({ ...@@ -1275,10 +1275,10 @@ cc.Class({
this.curOptionArr = []; this.curOptionArr = [];
const disW = 158 * this._mapScaleMin; const disW = 158 * this._mapScaleMin;
const baseX = -(arr.length - 1) * disW; const baseX = -(arr.length - 1) * disW;
for (let i=0; i<arr.length; i++) { for (let i = 0; i < arr.length; i++) {
opItemArr[i].active = true; opItemArr[i].active = true;
if(!isBig) { if (!isBig) {
opItemArr[i].x = baseX + i * disW * 2; opItemArr[i].x = baseX + i * disW * 2;
} }
...@@ -1298,8 +1298,8 @@ cc.Class({ ...@@ -1298,8 +1298,8 @@ cc.Class({
setOptionAudioBig(arr) { setOptionAudioBig(arr) {
this.curOptionArr = []; this.curOptionArr = [];
for (let i=0; i<arr.length; i++) { for (let i = 0; i < arr.length; i++) {
this.optionAudioBgArr[i].active = true; this.optionAudioBgArr[i].active = true;
const data = arr[i]; const data = arr[i];
...@@ -1317,7 +1317,7 @@ cc.Class({ ...@@ -1317,7 +1317,7 @@ cc.Class({
}, },
setOptionText(options, isBig=false) { setOptionText(options, isBig = false) {
console.log(' in setOptionText, isBig: ', isBig); console.log(' in setOptionText, isBig: ', isBig);
...@@ -1329,25 +1329,25 @@ cc.Class({ ...@@ -1329,25 +1329,25 @@ cc.Class({
this.curOptionArr = []; this.curOptionArr = [];
const disW = 315 * this._mapScaleMin; const disW = 315 * this._mapScaleMin;
const disH = 120 * this._mapScaleMin; const disH = 120 * this._mapScaleMin;
const baseX = - disW ; const baseX = - disW;
let baseY = -235 * this._mapScaleMin; let baseY = -235 * this._mapScaleMin;
if (options.length > 2) { if (options.length > 2) {
baseY = -170 * this._mapScaleMin; baseY = -170 * this._mapScaleMin;
} }
let count = 0; let count = 0;
for (let i=0; i<options.length; i++) { for (let i = 0; i < options.length; i++) {
if ( i == 2 ) { if (i == 2) {
baseY -= disH; baseY -= disH;
count = 0; count = 0;
} }
opItemArr[i].active = true; opItemArr[i].active = true;
if (!isBig) { if (!isBig) {
opItemArr[i].x = baseX + count * disW * 2; opItemArr[i].x = baseX + count * disW * 2;
opItemArr[i].y = baseY; opItemArr[i].y = baseY;
} }
const data = options[i]; const data = options[i];
opItemArr[i].label.string = data.text; opItemArr[i].label.string = data.text;
...@@ -1357,7 +1357,7 @@ cc.Class({ ...@@ -1357,7 +1357,7 @@ cc.Class({
} else { } else {
opItemArr[i].label.node.scale = 1; opItemArr[i].label.node.scale = 1;
} }
const soundIcon = opItemArr[i].soundIcon; const soundIcon = opItemArr[i].soundIcon;
soundIcon.active = false; soundIcon.active = false;
...@@ -1368,7 +1368,7 @@ cc.Class({ ...@@ -1368,7 +1368,7 @@ cc.Class({
soundIcon.audioClip = audioClip; soundIcon.audioClip = audioClip;
opItemArr[i].audioClip = audioClip; opItemArr[i].audioClip = audioClip;
}); });
soundIcon.active = true; soundIcon.active = true;
} }
...@@ -1412,7 +1412,7 @@ cc.Class({ ...@@ -1412,7 +1412,7 @@ cc.Class({
playAudio(this.rightClip, () => { playAudio(this.rightClip, () => {
this.playAnswerAudio(0); this.playAnswerAudio(0);
}) })
}, },
playAnswerAudio(index) { playAnswerAudio(index) {
...@@ -1420,11 +1420,11 @@ cc.Class({ ...@@ -1420,11 +1420,11 @@ cc.Class({
if (!arr[index]) { if (!arr[index]) {
// delayCall(0.5, () => { // delayCall(0.5, () => {
this.changeNextQuestion(); this.changeNextQuestion();
// }) // })
} else { } else {
if ( arr[index].light.opacity > 254 && arr[index].audioClip ) { if (arr[index].light.opacity > 254 && arr[index].audioClip) {
playAudio(arr[index].audioClip, () => { playAudio(arr[index].audioClip, () => {
this.playAnswerAudio(index + 1); this.playAnswerAudio(index + 1);
}) })
...@@ -1438,7 +1438,7 @@ cc.Class({ ...@@ -1438,7 +1438,7 @@ cc.Class({
checkItemWrong() { checkItemWrong() {
const arr = this.curOptionArr; const arr = this.curOptionArr;
console.log('arr: ', arr); console.log('arr: ', arr);
for (let i=0; i<arr.length; i++) { for (let i = 0; i < arr.length; i++) {
const itemBg = arr[i]; const itemBg = arr[i];
if (itemBg.light.opacity >= 254) { if (itemBg.light.opacity >= 254) {
this.shakeArr.push(itemBg); this.shakeArr.push(itemBg);
...@@ -1453,17 +1453,17 @@ cc.Class({ ...@@ -1453,17 +1453,17 @@ cc.Class({
checkItemRightCount() { checkItemRightCount() {
let rightTotalCount = 0; let rightTotalCount = 0;
const answerArr = this.curQuestionData.answerArr; const answerArr = this.curQuestionData.answerArr;
for (let i=0; i<answerArr.length; i++) { for (let i = 0; i < answerArr.length; i++) {
if (answerArr[i].answerRight == '1') { if (answerArr[i].answerRight == '1') {
rightTotalCount ++; rightTotalCount++;
} }
} }
let curRightCount = 0; let curRightCount = 0;
const curOptionArr = this.curOptionArr; const curOptionArr = this.curOptionArr;
for (let i=0; i<curOptionArr.length; i++) { for (let i = 0; i < curOptionArr.length; i++) {
if (curOptionArr[i].light.opacity > 254) { if (curOptionArr[i].light.opacity > 254) {
curRightCount ++; curRightCount++;
} }
} }
...@@ -1477,7 +1477,7 @@ cc.Class({ ...@@ -1477,7 +1477,7 @@ cc.Class({
} }
const arr = this.shakeArr; const arr = this.shakeArr;
for (let i=0; i<arr.length; i++) { for (let i = 0; i < arr.length; i++) {
this.rotateShake(arr[i], rate); this.rotateShake(arr[i], rate);
if (arr[i].stopAnim) { if (arr[i].stopAnim) {
arr[i].stopAnim(); arr[i].stopAnim();
...@@ -1489,7 +1489,7 @@ cc.Class({ ...@@ -1489,7 +1489,7 @@ cc.Class({
hideLight() { hideLight() {
const arr = this.curOptionArr; const arr = this.curOptionArr;
for (let i=0; i<arr.length; i++) { for (let i = 0; i < arr.length; i++) {
arr[i].light.opacity = 0; arr[i].light.opacity = 0;
} }
this.checkBtn.opacity = 0; this.checkBtn.opacity = 0;
...@@ -1499,20 +1499,20 @@ cc.Class({ ...@@ -1499,20 +1499,20 @@ cc.Class({
const time = 0.9; const time = 0.9;
cc.tween(item) cc.tween(item)
.to(time / 6 / 2, {angle: -20 * rate}, {easing: 'sineInOut'}) .to(time / 6 / 2, { angle: -20 * rate }, { easing: 'sineInOut' })
.to(time / 6, {angle: 12 * rate}, {easing: 'sineInOut'}) .to(time / 6, { angle: 12 * rate }, { easing: 'sineInOut' })
.to(time / 6, {angle: -7 * rate}, {easing: 'sineInOut'}) .to(time / 6, { angle: -7 * rate }, { easing: 'sineInOut' })
.to(time / 6, {angle: 4 * rate}, {easing: 'sineInOut'}) .to(time / 6, { angle: 4 * rate }, { easing: 'sineInOut' })
.to(time / 6, {angle: -2 * rate}, {easing: 'sineInOut'}) .to(time / 6, { angle: -2 * rate }, { easing: 'sineInOut' })
.to(time / 6, {angle: 1 * rate}, {easing: 'sineInOut'}) .to(time / 6, { angle: 1 * rate }, { easing: 'sineInOut' })
.to(time / 6, {angle: 0 * rate}, {easing: 'sineInOut'}) .to(time / 6, { angle: 0 * rate }, { easing: 'sineInOut' })
.start(); .start();
}, },
showAllRight() { showAllRight() {
const curOptionArr = this.curOptionArr; const curOptionArr = this.curOptionArr;
for (let i=0; i<curOptionArr.length; i++) { for (let i = 0; i < curOptionArr.length; i++) {
if (curOptionArr[i].light.opacity > 254) { if (curOptionArr[i].light.opacity > 254) {
this.addIconRight(curOptionArr[i]); this.addIconRight(curOptionArr[i]);
} }
...@@ -1522,7 +1522,7 @@ cc.Class({ ...@@ -1522,7 +1522,7 @@ cc.Class({
changeNextQuestion() { changeNextQuestion() {
console.log(' in changeNextQuestion') console.log(' in changeNextQuestion')
this.curQuestionIndex ++ ; this.curQuestionIndex++;
this.setCurQuestionData(); this.setCurQuestionData();
if (!this.curQuestionData) { if (!this.curQuestionData) {
...@@ -1531,7 +1531,7 @@ cc.Class({ ...@@ -1531,7 +1531,7 @@ cc.Class({
} }
this.showChangeQuesAnim(); this.showChangeQuesAnim();
}, },
showChangeQuesAnim() { showChangeQuesAnim() {
...@@ -1573,13 +1573,13 @@ cc.Class({ ...@@ -1573,13 +1573,13 @@ cc.Class({
hideCurOptionAnim(cb) { hideCurOptionAnim(cb) {
const arr = this.curOptionArr; const arr = this.curOptionArr;
const time = 0.5; const time = 0.5;
for (let i=0; i<arr.length; i++) { for (let i = 0; i < arr.length; i++) {
if (arr[i].iconRight) { if (arr[i].iconRight) {
arr[i].iconRight.removeFromParent(); arr[i].iconRight.removeFromParent();
arr[i].iconRight = null; arr[i].iconRight = null;
} }
cc.tween(arr[i]) cc.tween(arr[i])
.to(time, {opacity: 0}, {easing: "cubicOut"}) .to(time, { opacity: 0 }, { easing: "cubicOut" })
.call(() => { .call(() => {
arr[i].active = false; arr[i].active = false;
}) })
...@@ -1590,13 +1590,13 @@ cc.Class({ ...@@ -1590,13 +1590,13 @@ cc.Class({
}) })
}, },
showCurOptionAnim(cb=null) { showCurOptionAnim(cb = null) {
const arr = this.curOptionArr; const arr = this.curOptionArr;
const time = 0.5; const time = 0.5;
for (let i=0; i<arr.length; i++) { for (let i = 0; i < arr.length; i++) {
arr[i].opacity = 0; arr[i].opacity = 0;
cc.tween(arr[i]) cc.tween(arr[i])
.to(time, {opacity: 255}, {easing: "cubicIn"}) .to(time, { opacity: 255 }, { easing: "cubicIn" })
.start(); .start();
} }
...@@ -1605,13 +1605,13 @@ cc.Class({ ...@@ -1605,13 +1605,13 @@ cc.Class({
cb(); cb();
}) })
} }
}, },
hideCurQuestion(cb) { hideCurQuestion(cb) {
const time = 0.5; const time = 0.5;
cc.tween(this.curQuesBg) cc.tween(this.curQuesBg)
.to(time, {opacity: 0}, {easing: "cubicOut"}) .to(time, { opacity: 0 }, { easing: "cubicOut" })
.call(() => { .call(() => {
this.curQuesBg.active = false; this.curQuesBg.active = false;
cb(); cb();
...@@ -1626,7 +1626,7 @@ cc.Class({ ...@@ -1626,7 +1626,7 @@ cc.Class({
const time = 0.5; const time = 0.5;
cc.tween(this.curQuesBg) cc.tween(this.curQuesBg)
.to(time, {opacity: 255}, {easing: "cubicIn"}) .to(time, { opacity: 255 }, { easing: "cubicIn" })
.start(); .start();
}, },
...@@ -1645,7 +1645,12 @@ cc.Class({ ...@@ -1645,7 +1645,12 @@ cc.Class({
showTrebleFirework(camera, cc.find('RibbonNodeBase').children); showTrebleFirework(camera, cc.find('RibbonNodeBase').children);
onHomeworkFinish(); cc.tween(this.node)
.delay(3)
.call(() => {
onHomeworkFinish();
})
.start();
}, },
showRestart() { showRestart() {
...@@ -1667,80 +1672,80 @@ cc.Class({ ...@@ -1667,80 +1672,80 @@ cc.Class({
btn.scale = 0; btn.scale = 0;
cc.tween(btn) cc.tween(btn)
.delay(1) .delay(1)
.to(time, {scale: btn.baseS}, {easing: "elasticOut"}) .to(time, { scale: btn.baseS }, { easing: "elasticOut" })
.start(); .start();
}, },
async showOneFirework(pos, parentNode, nodeList, w, h, n, timeRate=1) { async showOneFirework(pos, parentNode, nodeList, w, h, n, timeRate = 1) {
for (let i = 0; i < 3; i++) { for (let i = 0; i < 3; i++) {
this.showFirework(pos, parentNode, nodeList, w, h, n, timeRate); this.showFirework(pos, parentNode, nodeList, w, h, n, timeRate);
await asyncDelay(0.1); await asyncDelay(0.1);
} }
}, },
showFirework(pos, parentNode, nodeList, width = 200, height = 500, number = 30, timeRate=1) { showFirework(pos, parentNode, nodeList, width = 200, height = 500, number = 30, timeRate = 1) {
const subTime = 1; const subTime = 1;
for (let i = 0; i < number; i++) { for (let i = 0; i < number; i++) {
const quad = this.createQuads(pos, parentNode, nodeList); const quad = this.createQuads(pos, parentNode, nodeList);
const targetX = RandomInt(width / 2, -width / 2); const targetX = RandomInt(width / 2, -width / 2);
const targetY = RandomInt(height); const targetY = RandomInt(height);
cc.tween(quad) cc.tween(quad)
.by(0.5 * timeRate, { x: targetX }) .by(0.5 * timeRate, { x: targetX })
.by((2 + subTime * Math.random()) * timeRate, { x: targetX * 2 }) .by((2 + subTime * Math.random()) * timeRate, { x: targetX * 2 })
.start(); .start();
cc.tween(quad) cc.tween(quad)
.by(0.5 * timeRate, { y: targetY }, { easing: 'quadOut' }) .by(0.5 * timeRate, { y: targetY }, { easing: 'quadOut' })
.to((3 + subTime * Math.random()) * timeRate, { y: -parentNode.height * 2 }, { easing: 'quadIn' }) .to((3 + subTime * Math.random()) * timeRate, { y: -parentNode.height * 2 }, { easing: 'quadIn' })
.removeSelf() .removeSelf()
.start(); .start();
cc.tween(quad) cc.tween(quad)
.delay(1 * timeRate) .delay(1 * timeRate)
.to((0.5 + subTime * Math.random()) * timeRate , { opacity: 0 }) .to((0.5 + subTime * Math.random()) * timeRate, { opacity: 0 })
.start(); .start();
} }
}, },
createQuads(pos, parentNode, nodeList) { createQuads(pos, parentNode, nodeList) {
const quadBase = cc.instantiate(nodeList[RandomInt(nodeList.length)]); const quadBase = cc.instantiate(nodeList[RandomInt(nodeList.length)]);
quadBase.x = pos.x; quadBase.x = pos.x;
quadBase.y = pos.y; quadBase.y = pos.y;
quadBase.z = pos.z; quadBase.z = pos.z;
quadBase.angle = RandomInt(180); quadBase.angle = RandomInt(180);
quadBase.parent = parentNode; quadBase.parent = parentNode;
const quad = quadBase.getChildByName('quad'); const quad = quadBase.getChildByName('quad');
quad.x = 0; quad.x = 0;
quad.y = 0; quad.y = 0;
quad.angle = RandomInt(180); quad.angle = RandomInt(180);
const paper = quad.getChildByName('paper'); const paper = quad.getChildByName('paper');
paper.scaleX = Math.random() * 0.8 + 0.2; paper.scaleX = Math.random() * 0.8 + 0.2;
paper.scaleY = Math.random() * 0.8 + 0.2; paper.scaleY = Math.random() * 0.8 + 0.2;
quadBase.scaleX = Math.random(); quadBase.scaleX = Math.random();
cc.tween(quadBase) cc.tween(quadBase)
.to((1 - quadBase.scaleX) * 0.3, { scaleX: 1 }) .to((1 - quadBase.scaleX) * 0.3, { scaleX: 1 })
.call(() => { .call(() => {
const time = Math.random() * 0.2; const time = Math.random() * 0.2;
cc.tween(quadBase) cc.tween(quadBase)
.to(0.1 + time, { scaleX: -1 }) .to(0.1 + time, { scaleX: -1 })
.to(0.1 + time, { scaleX: 1 }) .to(0.1 + time, { scaleX: 1 })
.union() .union()
.repeatForever() .repeatForever()
.start();
})
.start(); .start();
})
.start();
return quadBase; return quadBase;
}, },
...@@ -1758,7 +1763,7 @@ cc.Class({ ...@@ -1758,7 +1763,7 @@ cc.Class({
restart() { restart() {
}, },
...@@ -1788,7 +1793,7 @@ cc.Class({ ...@@ -1788,7 +1793,7 @@ cc.Class({
const label = labelNode.addComponent(cc.RichText); const label = labelNode.addComponent(cc.RichText);
const size = 42 const size = 42
label.font = cc.find('Canvas/res/font/aharoni').getComponent(cc.Label).font; label.font = cc.find('Canvas/res/font/aharoni').getComponent(cc.Label).font;
label.string = `<outline color=#a83c13 width=2><size=${size}><color=#ffffff>${this.data.title || " " }</color></size></outline>` label.string = `<outline color=#a83c13 width=2><size=${size}><color=#ffffff>${this.data.title || " "}</color></size></outline>`
// label.string = `<size=${size}><color=#751e00>${this.curGroup.title }</color></size>` // label.string = `<size=${size}><color=#751e00>${this.curGroup.title }</color></size>`
label.lineHeight = size; label.lineHeight = size;
label.horizontalAlign = cc.macro.TextAlignment.LEFT label.horizontalAlign = cc.macro.TextAlignment.LEFT
...@@ -1807,7 +1812,7 @@ cc.Class({ ...@@ -1807,7 +1812,7 @@ cc.Class({
initBg() { initBg() {
// if (!this.data.pic_url) { // if (!this.data.pic_url) {
// return; // return;
// } // }
...@@ -1836,7 +1841,7 @@ cc.Class({ ...@@ -1836,7 +1841,7 @@ cc.Class({
return; return;
} }
cc.loader.load({url: this.data.bgItem.url}, (err, img) => { cc.loader.load({ url: this.data.bgItem.url }, (err, img) => {
// this.addMask(this.hotZoneBg); // this.addMask(this.hotZoneBg);
...@@ -1854,7 +1859,7 @@ cc.Class({ ...@@ -1854,7 +1859,7 @@ cc.Class({
sprNode.width = this.hotZoneBg.width; sprNode.width = this.hotZoneBg.width;
sprNode.height = this.hotZoneBg.height; sprNode.height = this.hotZoneBg.height;
sprNode.parent = this.hotZoneBg; sprNode.parent = this.hotZoneBg;
window['bg'] =sprNode window['bg'] = sprNode
const sx = this.canvas.width / this.hotZoneBg.width; const sx = this.canvas.width / this.hotZoneBg.width;
...@@ -1866,7 +1871,7 @@ cc.Class({ ...@@ -1866,7 +1871,7 @@ cc.Class({
this.initHotZoneItem(); this.initHotZoneItem();
}); });
}, },
...@@ -1883,7 +1888,7 @@ cc.Class({ ...@@ -1883,7 +1888,7 @@ cc.Class({
break; break;
case "2": case "2":
this.setOneRect(item); this.setOneRect(item);
break; break;
default: default:
break; break;
} }
...@@ -1901,7 +1906,7 @@ cc.Class({ ...@@ -1901,7 +1906,7 @@ cc.Class({
setOneDragAction(data) { setOneDragAction(data) {
const rate = (this.hotZoneBg.scale * this.hotZoneBg.width) / this.data.bgItem.rect.width; const rate = (this.hotZoneBg.scale * this.hotZoneBg.width) / this.data.bgItem.rect.width;
const rectNode = new cc.Node(); const rectNode = new cc.Node();
rectNode.name = 'rect' + data.index; rectNode.name = 'rect' + data.index;
this.hotZoneBg.addChild(rectNode); this.hotZoneBg.addChild(rectNode);
...@@ -1912,13 +1917,13 @@ cc.Class({ ...@@ -1912,13 +1917,13 @@ cc.Class({
ctx.strokeColor = cc.Color.BLACK; ctx.strokeColor = cc.Color.BLACK;
ctx.fillColor = cc.Color.WHITE.setA(100); ctx.fillColor = cc.Color.WHITE.setA(100);
const scale = rate / this.hotZoneBg.scaleY ; const scale = rate / this.hotZoneBg.scaleY;
rectNode.width = data.rect.width * scale; rectNode.width = data.rect.width * scale;
rectNode.height = data.rect.height * scale; rectNode.height = data.rect.height * scale;
rectNode.x = -this.hotZoneBg.width / 2 + data.rect.x * scale; rectNode.x = -this.hotZoneBg.width / 2 + data.rect.x * scale;
rectNode.y = this.hotZoneBg.height / 2 - data.rect.height * scale - data.rect.y * scale; rectNode.y = this.hotZoneBg.height / 2 - data.rect.height * scale - data.rect.y * scale;
const {x, y, width, height} = rectNode; const { x, y, width, height } = rectNode;
// rectNode.anchorX = rectNode.anchorY = 0; // rectNode.anchorX = rectNode.anchorY = 0;
if (this.data.bgItem.isShowDebugLine) { if (this.data.bgItem.isShowDebugLine) {
...@@ -1944,10 +1949,10 @@ cc.Class({ ...@@ -1944,10 +1949,10 @@ cc.Class({
} }
this._curShowItem = rectNode; this._curShowItem = rectNode;
}) })
const realRate = this.hotZoneBg.width / this.data.bgItem.rect.width; const realRate = this.hotZoneBg.width / this.data.bgItem.rect.width;
rectNode.targetPx = -this.hotZoneBg.width / 2 + ( data.dragDot.x - this.data.bgItem.rect.x ) * realRate; rectNode.targetPx = -this.hotZoneBg.width / 2 + (data.dragDot.x - this.data.bgItem.rect.x) * realRate;
rectNode.targetPy = this.hotZoneBg.height / 2 - (data.dragDot.y - this.data.bgItem.rect.y) * realRate; rectNode.targetPy = this.hotZoneBg.height / 2 - (data.dragDot.y - this.data.bgItem.rect.y) * realRate;
...@@ -1969,14 +1974,14 @@ cc.Class({ ...@@ -1969,14 +1974,14 @@ cc.Class({
label.node.scale = scale * data.fontScale; label.node.scale = scale * data.fontScale;
label.node.targetOff(); label.node.targetOff();
// label.overflow = cc.Label.Overflow.NONE; // label.overflow = cc.Label.Overflow.NONE;
// label.node.setContentSize(new cc.Size(0, lineHeight)); // label.node.setContentSize(new cc.Size(0, lineHeight));
label["_forceUpdateRenderData"](true); label["_forceUpdateRenderData"](true);
} else if (actionData.type == 'pic') { } else if (actionData.type == 'pic') {
const pic = this.setOneActionPic(rectNode, actionData); const pic = this.setOneActionPic(rectNode, actionData);
...@@ -1991,7 +1996,7 @@ cc.Class({ ...@@ -1991,7 +1996,7 @@ cc.Class({
setOneAction(data) { setOneAction(data) {
const rate = (this.hotZoneBg.scale * this.hotZoneBg.width) / this.data.bgItem.rect.width; const rate = (this.hotZoneBg.scale * this.hotZoneBg.width) / this.data.bgItem.rect.width;
const rectNode = new cc.Node(); const rectNode = new cc.Node();
rectNode.name = 'rect' + data.index; rectNode.name = 'rect' + data.index;
this.hotZoneBg.addChild(rectNode); this.hotZoneBg.addChild(rectNode);
...@@ -2002,13 +2007,13 @@ cc.Class({ ...@@ -2002,13 +2007,13 @@ cc.Class({
ctx.strokeColor = cc.Color.BLACK; ctx.strokeColor = cc.Color.BLACK;
ctx.fillColor = cc.Color.WHITE.setA(100); ctx.fillColor = cc.Color.WHITE.setA(100);
const scale = rate / this.hotZoneBg.scaleY ; const scale = rate / this.hotZoneBg.scaleY;
rectNode.width = data.rect.width * scale; rectNode.width = data.rect.width * scale;
rectNode.height = data.rect.height * scale; rectNode.height = data.rect.height * scale;
rectNode.x = -this.hotZoneBg.width / 2 + data.rect.x * scale; rectNode.x = -this.hotZoneBg.width / 2 + data.rect.x * scale;
rectNode.y = this.hotZoneBg.height / 2 - data.rect.height * scale - data.rect.y * scale; rectNode.y = this.hotZoneBg.height / 2 - data.rect.height * scale - data.rect.y * scale;
const {x, y, width, height} = rectNode; const { x, y, width, height } = rectNode;
rectNode.anchorX = rectNode.anchorY = 0; rectNode.anchorX = rectNode.anchorY = 0;
if (this.data.bgItem.isShowDebugLine) { if (this.data.bgItem.isShowDebugLine) {
...@@ -2031,8 +2036,8 @@ cc.Class({ ...@@ -2031,8 +2036,8 @@ cc.Class({
// label.overflow = cc.Label.Overflow.NONE; // label.overflow = cc.Label.Overflow.NONE;
// label.node.setContentSize(new cc.Size(0, lineHeight)); // label.node.setContentSize(new cc.Size(0, lineHeight));
label["_forceUpdateRenderData"](true); label["_forceUpdateRenderData"](true);
} else if (actionData.type == 'pic') { } else if (actionData.type == 'pic') {
const pic = this.setOneActionPic(rectNode, actionData); const pic = this.setOneActionPic(rectNode, actionData);
...@@ -2066,24 +2071,24 @@ cc.Class({ ...@@ -2066,24 +2071,24 @@ cc.Class({
const tweenArr = []; const tweenArr = [];
for (let i = 0; i < opArr.length; i++ ) { for (let i = 0; i < opArr.length; i++) {
const opData = opArr[i]; const opData = opArr[i];
console.log('opArr[0]', opArr[i]) console.log('opArr[0]', opArr[i])
if (opData[0] == 'fontColor') { if (opData[0] == 'fontColor') {
const color = new cc.Color(); const color = new cc.Color();
cc.Color.fromHEX(color, opData[1] ); cc.Color.fromHEX(color, opData[1]);
labelNode.color = color; labelNode.color = color;
} else if (opData[0] == 'opacity') { } else if (opData[0] == 'opacity') {
// console.log('opData: ', opData) // console.log('opData: ', opData)
labelNode.opacity = Number( opData[1] / 100 * 255 ) + 0.1; labelNode.opacity = Number(opData[1] / 100 * 255) + 0.1;
// console.log(labelNode.opacity); // console.log(labelNode.opacity);
tweenArr.push({item: labelNode , option: `{"${opData[0]}" : ${opData[2] / 100 * 255}}`, optionName: opData[0]},) tweenArr.push({ item: labelNode, option: `{"${opData[0]}" : ${opData[2] / 100 * 255}}`, optionName: opData[0] },)
} else { } else {
label[opData[0]] = opData[1]; label[opData[0]] = opData[1];
tweenArr.push({item: label, option: `{"${opData[0]}" : ${opData[2]}}`, optionName: opData[0]}) tweenArr.push({ item: label, option: `{"${opData[0]}" : ${opData[2]}}`, optionName: opData[0] })
} }
} }
...@@ -2100,7 +2105,7 @@ cc.Class({ ...@@ -2100,7 +2105,7 @@ cc.Class({
// labelNode.y += rectNode.height / 2; // labelNode.y += rectNode.height / 2;
// labelNode.x += rectNode.width / 2; // labelNode.x += rectNode.width / 2;
// rectNode.addComponent(cc.Button); // rectNode.addComponent(cc.Button);
// rectNode.on('click', () => { // rectNode.on('click', () => {
...@@ -2125,7 +2130,7 @@ cc.Class({ ...@@ -2125,7 +2130,7 @@ cc.Class({
// .to(actionData.changeTime, JSON.parse(tweenData.option) ) // .to(actionData.changeTime, JSON.parse(tweenData.option) )
// .start(); // .start();
// } // }
// } // }
...@@ -2141,7 +2146,7 @@ cc.Class({ ...@@ -2141,7 +2146,7 @@ cc.Class({
const picNode = new cc.Node(); const picNode = new cc.Node();
rectNode.addChild(picNode); rectNode.addChild(picNode);
cc.loader.load({url: actionData.pic_url}, (err, img) => { cc.loader.load({ url: actionData.pic_url }, (err, img) => {
const spr = picNode.addComponent(cc.Sprite); const spr = picNode.addComponent(cc.Sprite);
spr.spriteFrame = new cc.SpriteFrame(img) spr.spriteFrame = new cc.SpriteFrame(img)
...@@ -2152,31 +2157,31 @@ cc.Class({ ...@@ -2152,31 +2157,31 @@ cc.Class({
picNode.scaleX = rectNode.width / picNode.width; picNode.scaleX = rectNode.width / picNode.width;
picNode.scaleY = rectNode.height / picNode.height; picNode.scaleY = rectNode.height / picNode.height;
const opArr = actionData.changeOption const opArr = actionData.changeOption
const tweenArr = []; const tweenArr = [];
for (let i = 0; i < opArr.length; i++ ) { for (let i = 0; i < opArr.length; i++) {
const opData = opArr[i]; const opData = opArr[i];
console.log('opData: ~~~ ', opData); console.log('opData: ~~~ ', opData);
if (opData[0] == 'opacity') { if (opData[0] == 'opacity') {
picNode.opacity = Number( opData[1] / 100 * 255 ) + 0.1; picNode.opacity = Number(opData[1] / 100 * 255) + 0.1;
console.log(picNode.opacity); console.log(picNode.opacity);
tweenArr.push({item: picNode , option: `{"${opData[0]}" : ${opData[2] / 100 * 255}}`, optionName: opData[0]},) tweenArr.push({ item: picNode, option: `{"${opData[0]}" : ${opData[2] / 100 * 255}}`, optionName: opData[0] },)
} else { } else {
// picNode[opData[0]] = Number(opData[1]); // picNode[opData[0]] = Number(opData[1]);
// tweenArr.push({item: picNode, option: `{"${opData[0]}" : ${opData[2]}}`, optionName: opData[0]}) // tweenArr.push({item: picNode, option: `{"${opData[0]}" : ${opData[2]}}`, optionName: opData[0]})
} }
if (actionData.audio_url) { if (actionData.audio_url) {
cc.assetManager.loadRemote(actionData.audio_url, (err, audioClip) => { cc.assetManager.loadRemote(actionData.audio_url, (err, audioClip) => {
rectNode.audioClip = audioClip; rectNode.audioClip = audioClip;
}); });
} }
rectNode.addComponent(cc.Button); rectNode.addComponent(cc.Button);
rectNode.on('click', () => { rectNode.on('click', () => {
...@@ -2185,22 +2190,22 @@ cc.Class({ ...@@ -2185,22 +2190,22 @@ cc.Class({
cc.audioEngine.stopAllEffects(); cc.audioEngine.stopAllEffects();
cc.audioEngine.playEffect(rectNode.audioClip, false, 0.8); cc.audioEngine.playEffect(rectNode.audioClip, false, 0.8);
} }
if (rectNode.isClicked) { if (rectNode.isClicked) {
// return; // return;
} }
rectNode.isClicked = true; rectNode.isClicked = true;
for (let i=0; i<tweenArr.length; i++) { for (let i = 0; i < tweenArr.length; i++) {
const tweenData = tweenArr[i]; const tweenData = tweenArr[i];
if (tweenData.optionName == 'opacity') { if (tweenData.optionName == 'opacity') {
cc.tween(tweenData.item) cc.tween(tweenData.item)
.to(actionData.changeTime, JSON.parse(tweenData.option) ) .to(actionData.changeTime, JSON.parse(tweenData.option))
.start(); .start();
} }
} }
}); });
} }
...@@ -2233,9 +2238,9 @@ cc.Class({ ...@@ -2233,9 +2238,9 @@ cc.Class({
const atlas = data.texJsonData.url//"http://staging-teach.cdn.ireadabc.com/246f8991b729fa3e5a7f4802de828efa.json"; const atlas = data.texJsonData.url//"http://staging-teach.cdn.ireadabc.com/246f8991b729fa3e5a7f4802de828efa.json";
cc.loader.load(image, (error, texture) => { cc.loader.load(image, (error, texture) => {
cc.loader.load({url: atlas, type: 'txt'}, (error, atlasJson) => { cc.loader.load({ url: atlas, type: 'txt' }, (error, atlasJson) => {
cc.loader.load({url: ske, type: 'txt'}, (error, dragonBonesJson) => { cc.loader.load({ url: ske, type: 'txt' }, (error, dragonBonesJson) => {
const atlas = new dragonBones.DragonBonesAtlasAsset(); const atlas = new dragonBones.DragonBonesAtlasAsset();
atlas.atlasJson = atlasJson; atlas.atlasJson = atlasJson;
...@@ -2296,10 +2301,10 @@ cc.Class({ ...@@ -2296,10 +2301,10 @@ cc.Class({
// const sy = rectNode.height / animaNode.height; // const sy = rectNode.height / animaNode.height;
// const scale = Math.min(sx, sy); // const scale = Math.min(sx, sy);
// animaNode.scale = scale; // animaNode.scale = scale;
animaNode.y += rectNode.height / 2; animaNode.y += rectNode.height / 2;
...@@ -2307,75 +2312,75 @@ cc.Class({ ...@@ -2307,75 +2312,75 @@ cc.Class({
animaNode.scaleX = rectNode.width / animaNode.width; animaNode.scaleX = rectNode.width / animaNode.width;
animaNode.scaleY = rectNode.height / animaNode.height; animaNode.scaleY = rectNode.height / animaNode.height;
const opArr = actionData.changeOption const opArr = actionData.changeOption
const tweenArr = []; const tweenArr = [];
for (let i = 0; i < opArr.length; i++ ) { for (let i = 0; i < opArr.length; i++) {
const opData = opArr[i]; const opData = opArr[i];
console.log('opData: ~~~ ', opData); console.log('opData: ~~~ ', opData);
if (opData[0] == 'opacity') { if (opData[0] == 'opacity') {
animaNode.opacity = Number( opData[1] / 100 * 255 ) + 0.1; animaNode.opacity = Number(opData[1] / 100 * 255) + 0.1;
console.log(animaNode.opacity); console.log(animaNode.opacity);
tweenArr.push({item: animaNode , option: `{"${opData[0]}" : ${opData[2] / 100 * 255}}`, optionName: opData[2] == null ? '' : opData[0]},) tweenArr.push({ item: animaNode, option: `{"${opData[0]}" : ${opData[2] / 100 * 255}}`, optionName: opData[2] == null ? '' : opData[0] },)
} else { } else {
// animaNode[opData[0]] = Number(opData[1]); // animaNode[opData[0]] = Number(opData[1]);
// tweenArr.push({item: animaNode, option: `{"${opData[0]}" : ${opData[2]}}`, optionName: opData[2] == null ? '' : opData[0]}) // tweenArr.push({item: animaNode, option: `{"${opData[0]}" : ${opData[2]}}`, optionName: opData[2] == null ? '' : opData[0]})
} }
if (actionData.audio_url) { if (actionData.audio_url) {
cc.assetManager.loadRemote(actionData.audio_url, (err, audioClip) => { cc.assetManager.loadRemote(actionData.audio_url, (err, audioClip) => {
rectNode.audioClip = audioClip; rectNode.audioClip = audioClip;
}); });
} }
rectNode.addComponent(cc.Button); rectNode.addComponent(cc.Button);
rectNode.on('click', () => { rectNode.on('click', () => {
if (rectNode.audioClip) { if (rectNode.audioClip) {
cc.audioEngine.stopAllEffects(); cc.audioEngine.stopAllEffects();
cc.audioEngine.playEffect(rectNode.audioClip, false, 0.8); cc.audioEngine.playEffect(rectNode.audioClip, false, 0.8);
} }
if (rectNode.isClicked) { if (rectNode.isClicked) {
// return; // return;
} }
rectNode.isClicked = true; rectNode.isClicked = true;
for (let j=0; j<tweenArr.length; j++) { for (let j = 0; j < tweenArr.length; j++) {
const tweenData = tweenArr[j]; const tweenData = tweenArr[j];
console.log('tweenData: ', tweenData); console.log('tweenData: ', tweenData);
if (tweenData.optionName) { if (tweenData.optionName) {
cc.tween(tweenData.item) cc.tween(tweenData.item)
.to(actionData.changeTime, JSON.parse(tweenData.option)) .to(actionData.changeTime, JSON.parse(tweenData.option))
.start(); .start();
} }
} }
if (animationNames.length > 0) { if (animationNames.length > 0) {
dragonDisplay.playAnimation(animationNames[0], 1); dragonDisplay.playAnimation(animationNames[0], 1);
} }
}); });
} }
}); });
}); });
}); });
}, },
...@@ -2431,15 +2436,15 @@ cc.Class({ ...@@ -2431,15 +2436,15 @@ cc.Class({
if (!data.texPngData) { if (!data.texPngData) {
return return
} }
const image = data.texPngData.url//"http://staging-teach.cdn.ireadabc.com/5a0c5af3e952acd0ac83a6e5c6f03ff1.png"; const image = data.texPngData.url//"http://staging-teach.cdn.ireadabc.com/5a0c5af3e952acd0ac83a6e5c6f03ff1.png";
const ske = data.skeJsonData.url//"http://staging-teach.cdn.ireadabc.com/bd825dcceea298d1146be8067ae3d17f.json"; const ske = data.skeJsonData.url//"http://staging-teach.cdn.ireadabc.com/bd825dcceea298d1146be8067ae3d17f.json";
const atlas = data.texJsonData.url//"http://staging-teach.cdn.ireadabc.com/246f8991b729fa3e5a7f4802de828efa.json"; const atlas = data.texJsonData.url//"http://staging-teach.cdn.ireadabc.com/246f8991b729fa3e5a7f4802de828efa.json";
cc.loader.load(image, (error, texture) => { cc.loader.load(image, (error, texture) => {
cc.loader.load({url: atlas, type: 'txt'}, (error, atlasJson) => { cc.loader.load({ url: atlas, type: 'txt' }, (error, atlasJson) => {
cc.loader.load({url: ske, type: 'txt'}, (error, dragonBonesJson) => { cc.loader.load({ url: ske, type: 'txt' }, (error, dragonBonesJson) => {
const atlas = new dragonBones.DragonBonesAtlasAsset(); const atlas = new dragonBones.DragonBonesAtlasAsset();
atlas.atlasJson = atlasJson; atlas.atlasJson = atlasJson;
...@@ -2451,7 +2456,7 @@ cc.Class({ ...@@ -2451,7 +2456,7 @@ cc.Class({
dragonDisplay.dragonAtlasAsset = atlas; dragonDisplay.dragonAtlasAsset = atlas;
dragonDisplay.dragonAsset = asset; dragonDisplay.dragonAsset = asset;
let json = JSON.parse(asset.dragonBonesJson); let json = JSON.parse(asset.dragonBonesJson);
let armatures = json["armature"]; let armatures = json["armature"];
...@@ -2500,7 +2505,7 @@ cc.Class({ ...@@ -2500,7 +2505,7 @@ cc.Class({
const sy = rectNode.height / animaNode.height; const sy = rectNode.height / animaNode.height;
const scale = Math.min(sx, sy); const scale = Math.min(sx, sy);
animaNode.scale = scale; animaNode.scale = scale;
}); });
}); });
}); });
...@@ -2511,11 +2516,11 @@ cc.Class({ ...@@ -2511,11 +2516,11 @@ cc.Class({
const rate = (this.hotZoneBg.scale * this.hotZoneBg.width) / this.data.bgItem.rect.width; const rate = (this.hotZoneBg.scale * this.hotZoneBg.width) / this.data.bgItem.rect.width;
const picNode = new cc.Node(); const picNode = new cc.Node();
picNode.name= 'pic' + data.index; picNode.name = 'pic' + data.index;
picNode.data = data; picNode.data = data;
this.hotZoneBg.addChild(picNode); this.hotZoneBg.addChild(picNode);
cc.loader.load({url: data.pic_url}, (err, img) => { cc.loader.load({ url: data.pic_url }, (err, img) => {
const spr = picNode.addComponent(cc.Sprite); const spr = picNode.addComponent(cc.Sprite);
spr.spriteFrame = new cc.SpriteFrame(img) spr.spriteFrame = new cc.SpriteFrame(img)
...@@ -2548,7 +2553,7 @@ cc.Class({ ...@@ -2548,7 +2553,7 @@ cc.Class({
picNode.baseY = picNode.y; picNode.baseY = picNode.y;
const realRate = this.hotZoneBg.width / this.data.bgItem.rect.width; const realRate = this.hotZoneBg.width / this.data.bgItem.rect.width;
picNode.targetPx = -this.hotZoneBg.width / 2 + ( data.dragDot.x - this.data.bgItem.rect.x ) * realRate; picNode.targetPx = -this.hotZoneBg.width / 2 + (data.dragDot.x - this.data.bgItem.rect.x) * realRate;
picNode.targetPy = this.hotZoneBg.height / 2 - (data.dragDot.y - this.data.bgItem.rect.y) * realRate; picNode.targetPy = this.hotZoneBg.height / 2 - (data.dragDot.y - this.data.bgItem.rect.y) * realRate;
...@@ -2580,11 +2585,11 @@ cc.Class({ ...@@ -2580,11 +2585,11 @@ cc.Class({
const rate = (this.hotZoneBg.scale * this.hotZoneBg.width) / this.data.bgItem.rect.width; const rate = (this.hotZoneBg.scale * this.hotZoneBg.width) / this.data.bgItem.rect.width;
const picNode = new cc.Node(); const picNode = new cc.Node();
picNode.name= 'pic' + data.index; picNode.name = 'pic' + data.index;
picNode.data = data; picNode.data = data;
this.hotZoneBg.addChild(picNode); this.hotZoneBg.addChild(picNode);
cc.loader.load({url: data.pic_url}, (err, img) => { cc.loader.load({ url: data.pic_url }, (err, img) => {
const spr = picNode.addComponent(cc.Sprite); const spr = picNode.addComponent(cc.Sprite);
spr.spriteFrame = new cc.SpriteFrame(img) spr.spriteFrame = new cc.SpriteFrame(img)
...@@ -2669,17 +2674,17 @@ cc.Class({ ...@@ -2669,17 +2674,17 @@ cc.Class({
addPicAudio(picNode) { addPicAudio(picNode) {
const data = picNode.data; const data = picNode.data;
cc.assetManager.loadRemote(data.audio_url, (err, audioClip) => { cc.assetManager.loadRemote(data.audio_url, (err, audioClip) => {
picNode.audioClip = audioClip; picNode.audioClip = audioClip;
}); });
picNode.addComponent(cc.Button); picNode.addComponent(cc.Button);
picNode.on('click', () => { picNode.on('click', () => {
if (picNode.audioClip) { if (picNode.audioClip) {
cc.audioEngine.stopAllEffects(); cc.audioEngine.stopAllEffects();
cc.audioEngine.playEffect(picNode.audioClip, false, 0.8); cc.audioEngine.playEffect(picNode.audioClip, false, 0.8);
} }
}); });
}, },
...@@ -2687,7 +2692,7 @@ cc.Class({ ...@@ -2687,7 +2692,7 @@ cc.Class({
initListener() { initListener() {
const canvas = cc.find('Canvas'); const canvas = cc.find('Canvas');
let downFlag = false; let downFlag = false;
const touchMove = (e) => { const touchMove = (e) => {
...@@ -2709,7 +2714,7 @@ cc.Class({ ...@@ -2709,7 +2714,7 @@ cc.Class({
} }
const touchEnd = (e) => { const touchEnd = (e) => {
downFlag = false; downFlag = false;
this.canvasTouchEnd(e); this.canvasTouchEnd(e);
...@@ -2723,7 +2728,7 @@ cc.Class({ ...@@ -2723,7 +2728,7 @@ cc.Class({
} }
const mouseUp = (e) => { const mouseUp = (e) => {
downFlag = false; downFlag = false;
this.canvasTouchEnd(e); this.canvasTouchEnd(e);
...@@ -2735,7 +2740,7 @@ cc.Class({ ...@@ -2735,7 +2740,7 @@ cc.Class({
canvas.off(cc.Node.EventType.TOUCH_CANCEL, touchEnd) canvas.off(cc.Node.EventType.TOUCH_CANCEL, touchEnd)
} }
} }
canvas.on(cc.Node.EventType.TOUCH_MOVE, touchMove) canvas.on(cc.Node.EventType.TOUCH_MOVE, touchMove)
canvas.on(cc.Node.EventType.MOUSE_MOVE, mouseMove) canvas.on(cc.Node.EventType.MOUSE_MOVE, mouseMove)
...@@ -2748,8 +2753,8 @@ cc.Class({ ...@@ -2748,8 +2753,8 @@ cc.Class({
removeHtmlCanvasListener(type) { removeHtmlCanvasListener(type) {
const canvasHtml = document.querySelector('canvas'); const canvasHtml = document.querySelector('canvas');
canvasHtml.addEventListener(type, (e) => {}) canvasHtml.addEventListener(type, (e) => { })
}, },
removeHtmlTouchEnd() { removeHtmlTouchEnd() {
const canvasHtml = document.querySelector('canvas'); const canvasHtml = document.querySelector('canvas');
canvasHtml.removeEventListener('touchend', this.htmlCanvasTouchendFunc, this); canvasHtml.removeEventListener('touchend', this.htmlCanvasTouchendFunc, this);
...@@ -2780,7 +2785,7 @@ cc.Class({ ...@@ -2780,7 +2785,7 @@ cc.Class({
checkOnDragEndRect() { checkOnDragEndRect() {
console.log('emptyGroupArr: ', this.emptyGroupArr); console.log('emptyGroupArr: ', this.emptyGroupArr);
for (let i = 0; i < this.dragEndRectArr.length; i++) { for (let i = 0; i < this.dragEndRectArr.length; i++) {
const rect = this.dragEndRectArr[i]; const rect = this.dragEndRectArr[i];
...@@ -2788,7 +2793,7 @@ cc.Class({ ...@@ -2788,7 +2793,7 @@ cc.Class({
const worldPos = this._curShowItem.parent.convertToWorldSpaceAR(cc.v2(this._curShowItem.x, this._curShowItem.y)); const worldPos = this._curShowItem.parent.convertToWorldSpaceAR(cc.v2(this._curShowItem.x, this._curShowItem.y));
const worldRect = rect.getBoundingBoxToWorld(); const worldRect = rect.getBoundingBoxToWorld();
if (worldRect.contains(worldPos)) { if (worldRect.contains(worldPos)) {
console.log('rect in ') console.log('rect in ')
this.checkIsDragEndTarget(rect); this.checkIsDragEndTarget(rect);
// removeItemFromArr(this.emptyGroupArr, letterGroup); // removeItemFromArr(this.emptyGroupArr, letterGroup);
...@@ -2796,7 +2801,7 @@ cc.Class({ ...@@ -2796,7 +2801,7 @@ cc.Class({
// this.checkGroupEnd(); // this.checkGroupEnd();
return; return;
} }
} }
this.itemBack(); this.itemBack();
...@@ -2807,7 +2812,7 @@ cc.Class({ ...@@ -2807,7 +2812,7 @@ cc.Class({
cc.audioEngine.playEffect(this.wrongClip, false, 0.8); cc.audioEngine.playEffect(this.wrongClip, false, 0.8);
cc.tween(this._curShowItem) cc.tween(this._curShowItem)
.to(0.5, {x: this._curShowItem.baseX, y: this._curShowItem.baseY}, {easing: "elasticOut"}) .to(0.5, { x: this._curShowItem.baseX, y: this._curShowItem.baseY }, { easing: "elasticOut" })
.start(); .start();
}, },
......
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