Commit fa626045 authored by limingzhe's avatar limingzhe

feat: 完成

parent 3e9e5d67
{ {"ver":"1.1.2","uuid":"18a7f4f5-c833-41a4-91de-4df7e6332ef4","isBundle":false,"bundleName":"","priority":1,"compressionType":{},"optimizeHotUpdate":{},"inlineSpriteFrames":{},"isRemoteBundle":{"ios":false,"android":false},"subMetas":{}}
"ver": "1.1.2", \ No newline at end of file
"uuid": "18a7f4f5-c833-41a4-91de-4df7e6332ef4",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {
"ios": false,
"android": false
},
"subMetas": {}
}
\ No newline at end of file
...@@ -112,7 +112,7 @@ cc.Class({ ...@@ -112,7 +112,7 @@ cc.Class({
getDefaultData() { getDefaultData() {
return {"bgItem":{"url":"http://staging-teach.cdn.ireadabc.com/4ab167a9b89834b922c351aa42760e13.png","rect":{"x":518.48,"y":0,"width":387.03,"height":543}},"hotZoneItemArr":[{"id":"1644991839086","index":0,"pic_url":"http://staging-teach.cdn.ireadabc.com/6625fbc69c267f1d071958c1a33e4701.png","itemType":"pic","fontScale":1.1125,"imgScale":0.15171835708298406,"imgSizeW":112,"imgSizeH":208,"mapScale":1.1125,"dragDot":{"x":712,"y":271.5},"gIdx":"0","labelText":"A","rect":{"x":72.02,"y":290.72,"width":16.99,"height":31.56},"pointItem":3,"answer_pic_url":"http://staging-teach.cdn.ireadabc.com/7e3643677a1db5e4f6993a0ddcda8824.png"},{"id":"1644991898042","index":1,"pic_url":"http://staging-teach.cdn.ireadabc.com/da06fee7c6b9b172c05bff99dba65b3f.png","itemType":"pic","fontScale":1.1125,"imgScale":0.15171835708298406,"imgSizeW":116,"imgSizeH":185,"mapScale":1.1125,"dragDot":{"x":712,"y":271.5},"gIdx":"0","labelText":"a","rect":{"x":153.72,"y":295.47,"width":17.6,"height":28.07},"pointItem":4,"answer_pic_url":"http://staging-teach.cdn.ireadabc.com/42dee84ecedf0f8706592128eeb5dc11.png"}],"bgItem2":{"url":"http://staging-teach.cdn.ireadabc.com/4ab167a9b89834b922c351aa42760e13.png","rect":{"x":184.55,"y":0,"width":1054.9,"height":1480}},"hotZoneItemArr2":[{"id":"1644991954749","index":0,"itemType":"rect","fontScale":1.1125,"imgScale":1,"imgSizeW":0,"imgSizeH":0,"mapScale":1.1125,"dragDot":{"x":712,"y":740},"gIdx":"0","labelText":"T and te","posX":405,"posY":577,"rect":{"x":81.45,"y":559,"width":278,"height":36}},{"id":"1644992227827","index":1,"itemType":"rect","fontScale":1.1125,"imgScale":1,"imgSizeW":0,"imgSizeH":0,"mapScale":1.1125,"dragDot":{"x":712,"y":740},"gIdx":"1","labelText":"W and ad","posX":399,"posY":1106,"rect":{"x":85.45,"y":1087,"width":258,"height":38}},{"id":"1644992741604","index":2,"itemType":"rect","fontScale":1.1125,"imgScale":1,"imgSizeW":0,"imgSizeH":0,"mapScale":1.1125,"dragDot":{"x":712,"y":740},"gIdx":"2","labelText":"A","posX":409.00056980727067,"posY":846.9984391417997,"rect":{"x":207.45,"y":830,"width":34,"height":34}},{"id":"1644992763471","index":3,"itemType":"rect","fontScale":1.1125,"imgScale":1,"imgSizeW":0,"imgSizeH":0,"mapScale":1.1125,"dragDot":{"x":712,"y":740},"gIdx":"2","labelText":"a","posX":620,"posY":848,"rect":{"x":418.45,"y":831,"width":34,"height":34}}]} return {"bgItem":{"url":"http://staging-teach.cdn.ireadabc.com/4ab167a9b89834b922c351aa42760e13.png","rect":{"x":415.19,"y":0,"width":313.62,"height":440}},"hotZoneItemArr":[{"id":"1644991839086","index":0,"pic_url":"http://staging-teach.cdn.ireadabc.com/6625fbc69c267f1d071958c1a33e4701.png","itemType":"pic","fontScale":0.89375,"imgScale":0.15171835708298406,"imgSizeW":112,"imgSizeH":208,"mapScale":0.89375,"dragDot":{"x":572,"y":218.11516853932588},"gIdx":"0","labelText":"A","rect":{"x":56.75,"y":232.59,"width":16.99,"height":31.56},"pointItem":2,"answer_pic_url":"http://staging-teach.cdn.ireadabc.com/7e3643677a1db5e4f6993a0ddcda8824.png"},{"id":"1644991898042","index":1,"pic_url":"http://staging-teach.cdn.ireadabc.com/da06fee7c6b9b172c05bff99dba65b3f.png","itemType":"pic","fontScale":0.89375,"imgScale":0.15171835708298406,"imgSizeW":116,"imgSizeH":185,"mapScale":0.89375,"dragDot":{"x":572,"y":218.11516853932588},"gIdx":"0","labelText":"a","rect":{"x":122.89,"y":236.76,"width":17.6,"height":28.07},"pointItem":3,"answer_pic_url":"http://staging-teach.cdn.ireadabc.com/42dee84ecedf0f8706592128eeb5dc11.png"},{"id":"1645600368731","index":2,"pic_url":"http://staging-teach.cdn.ireadabc.com/6625fbc69c267f1d071958c1a33e4701.png","itemType":"pic","fontScale":0.89375,"imgScale":0.16317407096954456,"imgSizeW":112,"imgSizeH":208,"mapScale":0.89375,"dragDot":{"x":572,"y":217.47916666666669},"gIdx":"0","rect":{"x":56.51,"y":268.58,"width":18.28,"height":33.94},"pointItem":4,"answer_pic_url":"http://staging-teach.cdn.ireadabc.com/7e3643677a1db5e4f6993a0ddcda8824.png"},{"id":"1645600443974","index":3,"pic_url":"http://staging-teach.cdn.ireadabc.com/da06fee7c6b9b172c05bff99dba65b3f.png","itemType":"pic","fontScale":0.89375,"imgScale":0.16317407096954456,"imgSizeW":116,"imgSizeH":185,"mapScale":0.89375,"dragDot":{"x":572,"y":217.47916666666669},"gIdx":"0","rect":{"x":116.46,"y":276.48,"width":18.93,"height":30.19},"pointItem":5,"answer_pic_url":"http://staging-teach.cdn.ireadabc.com/42dee84ecedf0f8706592128eeb5dc11.png"},{"id":"1645605934351","index":4,"pic_url":"http://staging-teach.cdn.ireadabc.com/b16ada1d5b044c7bdb5fcd979fa962a3.png","itemType":"pic","fontScale":0.89375,"imgScale":0.08620689655172414,"imgSizeW":244,"imgSizeH":232,"mapScale":0.89375,"dragDot":{"x":572,"y":220},"gIdx":"0","rect":{"x":182.29,"y":193,"width":21.03,"height":20},"pointItem":7,"answer_pic_url":"http://staging-teach.cdn.ireadabc.com/f5354f7a488cc670b59925bf71663225.png"},{"id":"1645605991029","index":5,"pic_url":"http://staging-teach.cdn.ireadabc.com/4e0cb39a874646e1a2e4027b6dace434.png","itemType":"pic","fontScale":0.89375,"imgScale":0.12293936853869795,"imgSizeW":183,"imgSizeH":162,"mapScale":0.89375,"dragDot":{"x":572,"y":220},"gIdx":"0","rect":{"x":245.56,"y":192.04,"width":22.5,"height":19.92},"pointItem":8,"answer_pic_url":"http://staging-teach.cdn.ireadabc.com/b87bddc8c4197b2de399cc02ccec328a.png"},{"id":"1645606024735","index":6,"pic_url":"http://staging-teach.cdn.ireadabc.com/b16ada1d5b044c7bdb5fcd979fa962a3.png","itemType":"pic","fontScale":0.89375,"imgScale":0.08620689655172414,"imgSizeW":244,"imgSizeH":232,"mapScale":0.89375,"dragDot":{"x":572,"y":220},"gIdx":"0","rect":{"x":185.29,"y":277,"width":21.03,"height":20},"pointItem":9,"answer_pic_url":"http://staging-teach.cdn.ireadabc.com/f5354f7a488cc670b59925bf71663225.png"},{"id":"1645606030023","index":7,"pic_url":"http://staging-teach.cdn.ireadabc.com/4e0cb39a874646e1a2e4027b6dace434.png","itemType":"pic","fontScale":0.89375,"imgScale":0.12293936853869795,"imgSizeW":183,"imgSizeH":162,"mapScale":0.89375,"dragDot":{"x":572,"y":220},"gIdx":"0","rect":{"x":243.56,"y":274.04,"width":22.5,"height":19.92},"pointItem":10,"answer_pic_url":"http://staging-teach.cdn.ireadabc.com/b87bddc8c4197b2de399cc02ccec328a.png"}],"bgItem2":{"url":"http://staging-teach.cdn.ireadabc.com/4ab167a9b89834b922c351aa42760e13.png","rect":{"x":144.34,"y":0,"width":855.32,"height":1200}},"hotZoneItemArr2":[{"id":"1644991954749","index":0,"itemType":"rect","fontScale":0.89375,"imgScale":1,"imgSizeW":0,"imgSizeH":0,"mapScale":0.89375,"dragDot":{"x":572,"y":594.4943820224719},"gIdx":"0","labelText":"T and te","posX":405,"posY":577,"rect":{"x":66.04,"y":453.24,"width":225.41,"height":29.19}},{"id":"1644992741604","index":1,"itemType":"rect","fontScale":0.89375,"imgScale":1,"imgSizeW":0,"imgSizeH":0,"mapScale":0.89375,"dragDot":{"x":572,"y":594.4943820224719},"gIdx":"3","labelText":"A","posX":409.00056980727067,"posY":846.9984391417997,"rect":{"x":168.19,"y":672.97,"width":27.57,"height":27.57}},{"id":"1644992763471","index":2,"itemType":"rect","fontScale":0.89375,"imgScale":1,"imgSizeW":0,"imgSizeH":0,"mapScale":0.89375,"dragDot":{"x":572,"y":594.4943820224719},"gIdx":"3","labelText":"a","posX":620,"posY":848,"rect":{"x":339.28,"y":673.78,"width":27.57,"height":27.57}},{"id":"1645600546594","index":3,"itemType":"rect","fontScale":0.89375,"imgScale":1,"imgSizeW":0,"imgSizeH":0,"mapScale":0.89375,"dragDot":{"x":572,"y":592.8541666666667},"gIdx":"3","labelText":"A","posX":441,"posY":1058,"rect":{"x":163.08,"y":779.4,"width":36.18,"height":36.18}},{"id":"1645600571581","index":4,"itemType":"rect","fontScale":0.89375,"imgScale":1,"imgSizeW":0,"imgSizeH":0,"mapScale":0.89375,"dragDot":{"x":572,"y":592.8541666666667},"gIdx":"3","labelText":"a","posX":667,"posY":1063,"rect":{"x":334.94,"y":784.67,"width":33.17,"height":33.17}},{"id":"1645600965532","index":5,"itemType":"rect","fontScale":0.89375,"imgScale":1,"imgSizeW":0,"imgSizeH":0,"mapScale":0.89375,"dragDot":{"x":572,"y":592.8541666666667},"gIdx":"2","labelText":"A","posX":444,"posY":736,"rect":{"x":158.56,"y":524.62,"width":49.75,"height":60.3}},{"id":"1645606103521","index":6,"itemType":"rect","fontScale":0.89375,"imgScale":1,"imgSizeW":0,"imgSizeH":0,"mapScale":0.89375,"dragDot":{"x":572,"y":600},"gIdx":"3","labelText":"B","posX":669,"posY":563,"rect":{"x":505.66,"y":544,"width":38,"height":38}},{"id":"1645606143517","index":7,"itemType":"rect","fontScale":0.89375,"imgScale":1,"imgSizeW":0,"imgSizeH":0,"mapScale":0.89375,"dragDot":{"x":572,"y":600},"gIdx":"3","labelText":"b","posX":832,"posY":564,"rect":{"x":664.66,"y":541,"width":46,"height":46}},{"id":"1645606172146","index":8,"itemType":"rect","fontScale":0.89375,"imgScale":1,"imgSizeW":0,"imgSizeH":0,"mapScale":0.89375,"dragDot":{"x":572,"y":600},"gIdx":"3","labelText":"B","posX":668,"posY":796,"rect":{"x":503.66,"y":776,"width":40,"height":40}},{"id":"1645606190696","index":9,"itemType":"rect","fontScale":0.89375,"imgScale":1,"imgSizeW":0,"imgSizeH":0,"mapScale":0.89375,"dragDot":{"x":572,"y":600},"gIdx":"3","labelText":"b","posX":830,"posY":794,"rect":{"x":659.66,"y":768,"width":52,"height":52}}],"isDebug":true}
}, },
preload() { preload() {
...@@ -179,6 +179,11 @@ cc.Class({ ...@@ -179,6 +179,11 @@ cc.Class({
if (this.data.bgItem) { if (this.data.bgItem) {
this._imageResList.push({ url: this.data.bgItem.url || ''}); this._imageResList.push({ url: this.data.bgItem.url || ''});
} }
if (this.data.bgItem2) {
this._imageResList.push({ url: this.data.bgItem2.url || ''});
}
if (!this.data.hotZoneItemArr) { if (!this.data.hotZoneItemArr) {
return; return;
} }
...@@ -233,6 +238,10 @@ cc.Class({ ...@@ -233,6 +238,10 @@ cc.Class({
picNodeArr: null, picNodeArr: null,
firstItemData: null,
bottomItemData: null,
initData() { initData() {
// this.curGroupIndex = 0; // this.curGroupIndex = 0;
// this.curQuestionIndex = 0; // this.curQuestionIndex = 0;
...@@ -245,7 +254,8 @@ cc.Class({ ...@@ -245,7 +254,8 @@ cc.Class({
this.topItemData = this.getGroupArrByGIdx(this.data.hotZoneItemArr2, '0')[0]; this.topItemData = this.getGroupArrByGIdx(this.data.hotZoneItemArr2, '0')[0];
this.bottomItemData = this.getGroupArrByGIdx(this.data.hotZoneItemArr2, '1')[0]; this.bottomItemData = this.getGroupArrByGIdx(this.data.hotZoneItemArr2, '1')[0];
this.centerItemArr = this.getGroupArrByGIdx(this.data.hotZoneItemArr2, '2'); this.firstItemData = this.getGroupArrByGIdx(this.data.hotZoneItemArr2, '2')[0];
this.centerItemArr = this.getGroupArrByGIdx(this.data.hotZoneItemArr2, '3');
this.initCheckBase(); this.initCheckBase();
}, },
...@@ -254,12 +264,19 @@ cc.Class({ ...@@ -254,12 +264,19 @@ cc.Class({
console.log('topItemData: ', this.topItemData); console.log('topItemData: ', this.topItemData);
console.log('centerItemArr: ', this.centerItemArr); console.log('centerItemArr: ', this.centerItemArr);
let bottomRect;
if (this.bottomItemData) {
bottomRect = this.bottomItemData.rect;
} else {
bottomRect = this.firstItemData.rect;
}
const topRect = this.topItemData.rect; const topRect = this.topItemData.rect;
const bottomRect = this.bottomItemData.rect;
const topCenterY = (topRect.y - topRect.height / 2); const topCenterY = (topRect.y + topRect.height / 2);
const bottomCenterY = (bottomRect.y - bottomRect.height / 2); const bottomCenterY = (bottomRect.y + bottomRect.height / 2);
const unitH = topRect.height // bottomCenterY - topCenterY; const unitH = bottomCenterY - topCenterY;
const unitW = topRect.width; const unitW = topRect.width;
const baseX = topRect.x; const baseX = topRect.x;
const baseY = topRect.y + topRect.height / 2; const baseY = topRect.y + topRect.height / 2;
...@@ -272,14 +289,14 @@ cc.Class({ ...@@ -272,14 +289,14 @@ cc.Class({
const unitX = (x - baseX) / unitW; const unitX = (x - baseX) / unitW;
const unitY = (y - baseY) / unitH; const unitY = (y - baseY) / unitH;
const unitW = itemRect.width / unitW; const unitW2 = itemRect.width / unitW;
const unitH = itemRect.height / unitH; const unitH2 = itemRect.height / unitH;
this.centerItemArr[i].unitX = unitX; this.centerItemArr[i].unitX = unitX;
this.centerItemArr[i].unitY = unitY; this.centerItemArr[i].unitY = unitY;
this.centerItemArr[i].unitW = unitW; this.centerItemArr[i].unitW = unitW2;
this.centerItemArr[i].unitH = unitH; this.centerItemArr[i].unitH = unitH2;
} }
console.log('unitH: ', unitH) console.log('unitH: ', unitH)
...@@ -287,6 +304,8 @@ cc.Class({ ...@@ -287,6 +304,8 @@ cc.Class({
console.log('baseX: ', baseX) console.log('baseX: ', baseX)
console.log('baseY: ', baseY) console.log('baseY: ', baseY)
const centerX = this.data.bgItem2.rect.width / 2;
this.centerUnitW = (centerX - baseX) / unitW;
}, },
...@@ -444,6 +463,7 @@ cc.Class({ ...@@ -444,6 +463,7 @@ cc.Class({
...@@ -453,7 +473,7 @@ cc.Class({ ...@@ -453,7 +473,7 @@ cc.Class({
const answerData = this.getAnswerData(data); const answerData = this.getAnswerData(data);
return;
this.showUserRight(answerData); this.showUserRight(answerData);
...@@ -509,34 +529,97 @@ cc.Class({ ...@@ -509,34 +529,97 @@ cc.Class({
this.topLabelData = topLabelData; this.topLabelData = topLabelData;
console.log('topLabelData: ', topLabelData); console.log('topLabelData: ', topLabelData);
return topLabelData;
const bottomText = this.bottomItemData.labelText if (this.bottomItemData) {
const bottomTextArr = bottomText.split(' ');
console.log('bottomTextArr: ', bottomTextArr); const bottomText = this.bottomItemData.labelText
const bottomTextArr = bottomText.split(' ');
const bottomLabelData = this.getPhotoLabelData(bottomTextArr, block);
if (!bottomLabelData) {
return false;
}
this.bottomLabelData = bottomLabelData;
return true
const bottomLabelData = this.getPhotoLabelData(bottomTextArr, block); } else if (this.firstItemData) {
if (!bottomLabelData) {
console.log('!bottomLabelData')
return false; const topLeftLetter = this.getTopLeftLetter(this.firstItemData.labelText, block, topLabelData);
if (!topLeftLetter) {
return false;
}
this.topLeftLetter = topLeftLetter;
return true;
} }
this.bottomLabelData = bottomLabelData;
return topLabelData && bottomLabelData;
return false;
let topLeftLetter = this.getTopLeftLetter(letter, block, topLabelData); // const bottomText = this.bottomItemData.labelText
this.topLeftLetter = topLeftLetter; // const bottomTextArr = bottomText.split(' ');
// console.log('bottomTextArr: ', bottomTextArr);
// const bottomLabelData = this.getPhotoLabelData(bottomTextArr, block);
// if (!bottomLabelData) {
// console.log('!bottomLabelData')
// return false;
// }
console.log('topLabelData: ', topLabelData); // this.bottomLabelData = bottomLabelData;
console.log('topLeftLetter: ', topLeftLetter);
// return topLabelData && bottomLabelData;
// let topLeftLetter = this.getTopLeftLetter(letter, block, topLabelData);
// this.topLeftLetter = topLeftLetter;
// console.log('topLabelData: ', topLabelData);
// console.log('topLeftLetter: ', topLeftLetter);
// return topLeftLetter;
},
getTopLeftLetter(text, block, topLabelData) {
let topLeftLetter;
const wordDataArr = this.getPhotoWordArr(text, block, topLabelData);
for (let i=0; i<wordDataArr.length; i++) {
const tempWordArr = wordDataArr[i].word;
for (let k=0; k<tempWordArr.length; k++) {
const {location , content} = tempWordArr[k];
wordDataArr[i].tmpLen = this.getToZeroLen(location)
if (!topLeftLetter) {
topLeftLetter = wordDataArr[i];
} else {
if (topLeftLetter.tmpLen > wordDataArr[i].tmpLen) {
topLeftLetter = wordDataArr[i];
}
}
}
}
return topLeftLetter; return topLeftLetter;
},
getToZeroLen(location) {
const {top, left} = location;
const len = Math.sqrt( Math.pow(left, 2) + Math.pow(top, 2) );
return len;
}, },
getPhotoLabelData(textArr, block) { getPhotoLabelData(textArr, block) {
for(let j=0; j<block.length; j++) { for(let j=0; j<block.length; j++) {
...@@ -610,16 +693,7 @@ cc.Class({ ...@@ -610,16 +693,7 @@ cc.Class({
} }
} }
// for (let i = 4; i < 9; i++) {
// const key = i.toString();
// if (answerData[key]) {
// this.showLetter(i - 4);
// } else {
// let writeRect = this.writeNodeArr[i - 4];
// writeRect.hitCount = 0;
// }
// }
}, },
showLetter(picNode) { showLetter(picNode) {
...@@ -696,6 +770,12 @@ cc.Class({ ...@@ -696,6 +770,12 @@ cc.Class({
const topLabelData = this.topLabelData; const topLabelData = this.topLabelData;
let bottomLabelData ;
if (this.bottomLabelData) {
bottomLabelData = this.bottomLabelData;
} else {
bottomLabelData = this.topLeftLetter;
}
// const bottomLabelData = this.bottomLabelData; // const bottomLabelData = this.bottomLabelData;
const centerItemArr = this.centerItemArr; const centerItemArr = this.centerItemArr;
...@@ -709,28 +789,43 @@ cc.Class({ ...@@ -709,28 +789,43 @@ cc.Class({
const topLocationBottom = lastTopWordLocation.bottom; const topLocationBottom = lastTopWordLocation.bottom;
// const bottomLocation = bottomLabelData.word[0].location; const bottomLocation = bottomLabelData.word[0].location;
const baseX = topLocationLeft; const baseX = topLocationLeft;
const baseY = topLocationTop + (topLocationBottom - topLocationTop) / 2; const baseY = topLocationTop + (topLocationBottom - topLocationTop) / 2;
const unitW = topLocationRight - topLocationLeft; const unitW = topLocationRight - topLocationLeft;
const unitH = topLocationBottom - topLocationTop //bottomLocation.top + (bottomLocation.bottom - bottomLocation.top) / 2 - baseY; const unitH = bottomLocation.top + (bottomLocation.bottom - bottomLocation.top) / 2 - baseY;
console.log(' unitW ~~~ ', unitW);
console.log(' unitH ~~~ ', unitH);
const dotArr = []; const dotArr = [];
for (let i=0; i<this.centerItemArr.length; i++) { for (let i=0; i<this.centerItemArr.length; i++) {
const checkLetter = this.centerItemArr[i]; const checkLetter = this.centerItemArr[i];
const x = baseX + checkLetter.unitX * unitW; let x = baseX + checkLetter.unitX * unitW;
const y = baseY + checkLetter.unitY * unitH; const y = baseY + checkLetter.unitY * unitH;
const w = checkLetter.unitW * unitW; const w = checkLetter.unitW * unitW;
const h = checkLetter.unitH * unitH; const h = checkLetter.unitH * unitH;
// const r = Math.min(w, h) const r = Math.min(w, h)
console.log('w: ', w); console.log('w: ', w);
console.log('h: ', h); console.log('h: ', h);
const dot = this.getColorDot(x, -y, 5);
console.log('centerX - x: ', centerX - x);
console.log('y: ', y);
const centerX = baseX + this.centerUnitW * unitW;
x += (centerX - x) * 0.005 * (y * 0.05);
const dot = this.getColorDot(x, -y, r);
this.debugDrawLayer.addChild(dot,5); this.debugDrawLayer.addChild(dot,5);
dot.labelText = checkLetter.labelText;
dotArr.push(dot); dotArr.push(dot);
...@@ -739,6 +834,7 @@ cc.Class({ ...@@ -739,6 +834,7 @@ cc.Class({
console.log('topLabelData: ', topLabelData); console.log('topLabelData: ', topLabelData);
const answerData = {};
for (let j=0; j<this.centerItemArr.length; j++) { for (let j=0; j<this.centerItemArr.length; j++) {
const checkLetter = this.centerItemArr[j]; const checkLetter = this.centerItemArr[j];
...@@ -749,13 +845,13 @@ cc.Class({ ...@@ -749,13 +845,13 @@ cc.Class({
console.log('wordDataArr: ', wordDataArr); console.log('wordDataArr: ', wordDataArr);
const answerData = {};
for (let i=0; i<wordDataArr.length; i++) { for (let i=0; i<wordDataArr.length; i++) {
const tempWordArr = wordDataArr[i].word;; const tempWordArr = wordDataArr[i].word;
for (let k=0; k<tempWordArr.length; k++) { for (let k=0; k<tempWordArr.length; k++) {
const {location , content} = tempWordArr[k]; const {location , content} = tempWordArr[k];
const rect = { const rect = {
x: location.left, x: location.left,
y: -location.bottom, y: -location.bottom,
...@@ -763,16 +859,17 @@ cc.Class({ ...@@ -763,16 +859,17 @@ cc.Class({
height: Math.abs( location.bottom - location.top ), height: Math.abs( location.bottom - location.top ),
} }
const colorRect = this.getColorRect(rect); const colorRect = this.getColorRect(rect);
colorRect.labelText = content;
this.debugDrawLayer.addChild(colorRect); this.debugDrawLayer.addChild(colorRect);
const label = this.getLabel(content); const label = this.getLabel(content);
label.x = colorRect.x; label.x = colorRect.x + colorRect.width / 2 * colorRect.scaleX;
label.y = colorRect.y; label.y = colorRect.y - colorRect.height / 2 //* colorRect.scaleY;
label.color = cc.Color.GREEN; label.color = cc.Color.GREEN;
this.debugDrawLayer.addChild(label); this.debugDrawLayer.addChild(label);
console.log('colorRect: ', colorRect); // console.log('colorRect: ', colorRect);
this.setOneAnswerData(colorRect, dotArr, answerData); this.setOneAnswerData(colorRect, dotArr, answerData);
...@@ -799,7 +896,7 @@ cc.Class({ ...@@ -799,7 +896,7 @@ cc.Class({
this.debugDrawLayer.addChild(colorRectTop); this.debugDrawLayer.addChild(colorRectTop);
return; return answerData;
}, },
...@@ -807,19 +904,20 @@ cc.Class({ ...@@ -807,19 +904,20 @@ cc.Class({
setOneAnswerData(colorRect, dotArr, answerData) { setOneAnswerData(colorRect, dotArr, answerData) {
// console.log(' in setOneAnswerData') // console.log(' in setOneAnswerData')
console.log('colorRect: ', colorRect) // console.log('colorRect: ', colorRect)
// console.log('dotArr: ', dotArr) // console.log('dotArr: ', dotArr)
// console.log('answerData: ', answerData) // console.log('answerData: ', answerData)
const rect = colorRect.ccRect; const rect = colorRect.ccRect;
const targetLabelText = colorRect.labelText;
for (let i=0; i<dotArr.length; i++) { for (let i=0; i<dotArr.length; i++) {
const {dotRect} = dotArr[i]; const {dotRect, labelText} = dotArr[i];
// const {pos} = dotArr[i]; // const {pos} = dotArr[i];
// if (rect.contains(pos)) { // if (rect.contains(pos)) {
if (rect.intersects(dotRect)) { if (targetLabelText == labelText && rect.intersects(dotRect)) {
answerData[i.toString()] = colorRect; answerData[i.toString()] = colorRect;
return; return;
} }
...@@ -850,114 +948,6 @@ cc.Class({ ...@@ -850,114 +948,6 @@ cc.Class({
}, },
setTestRectDot(topLabelData, bottomLabelData, wordDataArr) {
// const topLocation = topLabelData.word[0].location;
// const bottomLocation = bottomLabelData.word[0].location;
// const baseX = topLocation.left;
// const baseY = topLocation.top + (topLocation.bottom - topLocation.top) / 2;
// const unitW = topLocation.right - topLocation.left;
// const unitH = bottomLocation.top + (bottomLocation.bottom - bottomLocation.top) / 2 - baseY;
// let col = 0;
// const dotArr = [];
// for (let i=0; i<6; i++) {
// const x = baseX + col * disW;
// const y = baseY;
// const dot = this.getColorDot(x, y, rectH);
// this.debugLayer.addChild(dot,5);
// dotArr.push(dot);
// col ++;
// if (i == 2) {
// baseY -= disH;
// col = 0;
// }
// }
// const letterLocation = topLeftLetter.word[0].location;
// const titleLocation = topLabelData.word[0].location;
const unitH = topLeftLetter.bottom - topLabelData.bottom;
console.log('unitH: ', unitH)
//49
// const topLeftPos = topLeftLetter.location.top_left;
const rectH = 0.469 * unitH//23
const rectW = 0.48 * unitH//41
// const disW = 1.65 * unitH //101
const disW = 1.13 * unitH //101
const disH = 1.1 * unitH //49
const baseX = topLeftLetter.right - rectW / 2;
let baseY = -(topLeftLetter.top - rectH / 2 );
// const baseX = 2.898 * unitH // 142
// let baseY = -( 5.612 * unitH ); // -275
console.log('baseX: ', baseX);
console.log('baseY: ', baseY);
// wordDataArr.forEach(item => {
// const pos = item.location.top_left;
// item.cLen = Math.sqrt ( Math.pow(pos.x, 2) + Math.pow(pos.y, 2) );
// })
wordDataArr.forEach(item => {
// const pos = item.location.top_left;
const posX = item.left;
const posY = item.top;
item.cLen = Math.sqrt ( Math.pow(posX, 2) + Math.pow(posY, 2) );
})
wordDataArr = wordDataArr.sort((a, b) => {
return a.cLen - b.cLen;
})
let col = 0;
const dotArr = [];
for (let i=0; i<6; i++) {
const x = baseX + col * disW;
const y = baseY;
const dot = this.getColorDot(x, y, rectH);
this.debugLayer.addChild(dot,5);
dotArr.push(dot);
col ++;
if (i == 2) {
baseY -= disH;
col = 0;
}
}
return dotArr;
},
getColorDot(x, y, r=100) { getColorDot(x, y, r=100) {
const node = new cc.Node(); const node = new cc.Node();
...@@ -1147,7 +1137,11 @@ cc.Class({ ...@@ -1147,7 +1137,11 @@ cc.Class({
console.log(' in initDebugLayer'); console.log(' in initDebugLayer');
const layer = new cc.Node(); const layer = new cc.Node();
layer.parent = cc.find('Canvas');
if (this.data.isDebug) {
layer.parent = cc.find('Canvas');
}
layer.zIndex = 100; layer.zIndex = 100;
layer.anchorX = 0; layer.anchorX = 0;
layer.anchorY = 1; layer.anchorY = 1;
...@@ -1162,25 +1156,27 @@ cc.Class({ ...@@ -1162,25 +1156,27 @@ cc.Class({
} }
// cc.loader.load({url: this.data.bgItem2.url}, (err, img) => { cc.loader.load({url: this.data.bgItem2.url}, (err, img) => {
// layer.width = img.width; this.debugBgImg = img;
// layer.height = img.height; // this.checkBg = img;
// layer.width = img.width;
// layer.height = img.height;
// const sprNode = layer; // const sprNode = layer;
// var sf = new cc.SpriteFrame(img); // var sf = new cc.SpriteFrame(img);
// const spr = sprNode.addComponent(cc.Sprite); // const spr = sprNode.addComponent(cc.Sprite);
// spr.spriteFrame = sf // spr.spriteFrame = sf
// const sx = this.canvas.width / 2 / layer.width; // const sx = this.canvas.width / 2 / layer.width;
// const sy = (this.canvas.height) / 2 / layer.height; // const sy = (this.canvas.height) / 2 / layer.height;
// const s = Math.min(sx, sy); // const s = Math.min(sx, sy);
// layer.scale = s; // layer.scale = s;
// }); });
layer.x = -this.canvas.width / 2 + 10; layer.x = -this.canvas.width / 2 + 10;
layer.y = this.canvas.height / 2 - 10; layer.y = this.canvas.height / 2 - 10;
...@@ -1193,6 +1189,9 @@ cc.Class({ ...@@ -1193,6 +1189,9 @@ cc.Class({
const drawLayer = new cc.Node(); const drawLayer = new cc.Node();
this.debugDrawLayer = drawLayer; this.debugDrawLayer = drawLayer;
this.debugLayer.addChild(drawLayer, 2); this.debugLayer.addChild(drawLayer, 2);
}, },
......
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
<nz-dropdown-menu #menu="nzDropdownMenu"> <nz-dropdown-menu #menu="nzDropdownMenu">
<ul nz-menu nzSelectable> <ul nz-menu nzSelectable>
<div *ngFor="let temp of item.hotZoneItemArr2; let j = index" (click)="savePointItem(hzItem, j+1)" > <div *ngFor="let temp of item.hotZoneItemArr2; let j = index" (click)="savePointItem(hzItem, j+1)" >
<li *ngIf="temp.gIdx == '2' " nz-menu-item>填空区 item-{{j+1}}</li> <li *ngIf="temp.gIdx == '3' " nz-menu-item>填空区 item-{{j+1}}</li>
</div> </div>
</ul> </ul>
</nz-dropdown-menu> </nz-dropdown-menu>
...@@ -57,7 +57,9 @@ ...@@ -57,7 +57,9 @@
</div> </div>
<div style="margin-top: 10px; width: 200px; height: 50px; border: 1px solid #ccc ; border-radius: 5px; display: flex; align-items: center; justify-content: center;">
<label nz-checkbox [(ngModel)]="item.isDebug" (ngModelChange)="save()">调试模式</label>
</div>
......
...@@ -54,6 +54,11 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy, AfterViewIni ...@@ -54,6 +54,11 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy, AfterViewIni
rect: true, rect: true,
label: '区域内容', label: '区域内容',
}, },
{
name: '首个参照物',
rect: true,
label: '区域内容',
},
{ {
name: '填空区', name: '填空区',
rect: true, rect: true,
......
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