Commit a716cdba authored by huoshizhe's avatar huoshizhe

feat:

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