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,
...@@ -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();
} }
} }
...@@ -421,7 +421,7 @@ cc.Class({ ...@@ -421,7 +421,7 @@ 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();
}, },
...@@ -689,7 +689,7 @@ cc.Class({ ...@@ -689,7 +689,7 @@ 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);
...@@ -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,7 +724,7 @@ cc.Class({ ...@@ -724,7 +724,7 @@ cc.Class({
pic.y = baseY; pic.y = baseY;
this.optionPicBgBigArr.push(pic); this.optionPicBgBigArr.push(pic);
count ++; count++;
} }
}, },
...@@ -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,7 +826,7 @@ cc.Class({ ...@@ -826,7 +826,7 @@ 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);
...@@ -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,7 +861,7 @@ cc.Class({ ...@@ -861,7 +861,7 @@ cc.Class({
audio.y = baseY; audio.y = baseY;
this.optionAudioBgBigArr.push(audio); this.optionAudioBgBigArr.push(audio);
count ++; count++;
} }
}, },
...@@ -869,7 +869,7 @@ cc.Class({ ...@@ -869,7 +869,7 @@ cc.Class({
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);
...@@ -888,7 +888,7 @@ cc.Class({ ...@@ -888,7 +888,7 @@ 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);
...@@ -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";
...@@ -948,7 +948,7 @@ cc.Class({ ...@@ -948,7 +948,7 @@ 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);
...@@ -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 {
...@@ -1076,7 +1076,7 @@ cc.Class({ ...@@ -1076,7 +1076,7 @@ cc.Class({
setCurQuestion() { setCurQuestion() {
switch(this.curQuestionData.questionType) { switch (this.curQuestionData.questionType) {
case "pic": case "pic":
this.setQuestionPic(); this.setQuestionPic();
break; break;
...@@ -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;
...@@ -1211,7 +1211,7 @@ cc.Class({ ...@@ -1211,7 +1211,7 @@ cc.Class({
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,7 +1220,7 @@ cc.Class({ ...@@ -1220,7 +1220,7 @@ 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) {
...@@ -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,7 +1298,7 @@ cc.Class({ ...@@ -1298,7 +1298,7 @@ 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;
...@@ -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,15 +1329,15 @@ cc.Class({ ...@@ -1329,15 +1329,15 @@ 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;
} }
...@@ -1424,7 +1424,7 @@ cc.Class({ ...@@ -1424,7 +1424,7 @@ cc.Class({
// }) // })
} 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) {
...@@ -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();
} }
...@@ -1611,7 +1611,7 @@ cc.Class({ ...@@ -1611,7 +1611,7 @@ cc.Class({
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);
cc.tween(this.node)
.delay(3)
.call(() => {
onHomeworkFinish(); onHomeworkFinish();
})
.start();
}, },
showRestart() { showRestart() {
...@@ -1667,14 +1672,14 @@ cc.Class({ ...@@ -1667,14 +1672,14 @@ 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);
...@@ -1682,7 +1687,7 @@ cc.Class({ ...@@ -1682,7 +1687,7 @@ cc.Class({
} }
}, },
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);
...@@ -1702,7 +1707,7 @@ cc.Class({ ...@@ -1702,7 +1707,7 @@ cc.Class({
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();
} }
}, },
...@@ -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
...@@ -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;
...@@ -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) {
...@@ -1947,7 +1952,7 @@ cc.Class({ ...@@ -1947,7 +1952,7 @@ cc.Class({
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;
...@@ -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) {
...@@ -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] })
} }
} }
...@@ -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)
...@@ -2155,15 +2160,15 @@ cc.Class({ ...@@ -2155,15 +2160,15 @@ cc.Class({
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]);
...@@ -2191,12 +2196,12 @@ cc.Class({ ...@@ -2191,12 +2196,12 @@ cc.Class({
} }
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;
...@@ -2311,15 +2316,15 @@ cc.Class({ ...@@ -2311,15 +2316,15 @@ cc.Class({
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]);
...@@ -2347,7 +2352,7 @@ cc.Class({ ...@@ -2347,7 +2352,7 @@ cc.Class({
} }
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);
...@@ -2437,9 +2442,9 @@ cc.Class({ ...@@ -2437,9 +2442,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;
...@@ -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)
...@@ -2748,7 +2753,7 @@ cc.Class({ ...@@ -2748,7 +2753,7 @@ 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');
...@@ -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