diff --git a/.DS_Store b/.DS_Store index 0d01e81977084ef521b9c873dea506d1beee236c..88029ec10d12be63ecf6a2af7c920057a86cd87d 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/assets/OP_18.meta b/assets/OP_18.meta index 92411c31a0f90e9bb65d57095fc10e488564cdd2..b41089ab405010e8312ba0a09496889c60167680 100644 --- a/assets/OP_18.meta +++ b/assets/OP_18.meta @@ -1,15 +1 @@ -{ - "ver": "1.1.2", - "uuid": "e9f579c0-59b7-4567-93ad-5b17f799e827", - "isBundle": false, - "bundleName": "", - "priority": 1, - "compressionType": {}, - "optimizeHotUpdate": {}, - "inlineSpriteFrames": {}, - "isRemoteBundle": { - "ios": false, - "android": false - }, - "subMetas": {} -} \ No newline at end of file +{"ver":"1.1.2","uuid":"e9f579c0-59b7-4567-93ad-5b17f799e827","isBundle":false,"bundleName":"","priority":1,"compressionType":{},"optimizeHotUpdate":{},"inlineSpriteFrames":{},"isRemoteBundle":{"ios":false,"android":false},"subMetas":{}} \ No newline at end of file diff --git a/assets/OP_18/scene/OP_18.js b/assets/OP_18/scene/OP_18.js index 82d7debeb4962c97d11c7a8219ef3d1a653bd87c..02ae0462330b061d175b59916f11f837465b115e 100644 --- a/assets/OP_18/scene/OP_18.js +++ b/assets/OP_18/scene/OP_18.js @@ -200,6 +200,8 @@ cc.Class({ console.log('loadEnd') + // this.data.isDebug = true; + this.initData(); this.initAudio(); this.initView(); @@ -491,7 +493,7 @@ cc.Class({ // this.getPhotoData((data) => { // this.photoEnd(data); // }); - // }, 300); + // }, 30); // return; @@ -1992,23 +1994,29 @@ cc.Class({ // return; - // if (this.isCanDraw) { - // return; - // } - // this.isCanDraw = true; + + if (this.debugLayer.parent && this.debugLayer.active) { - // delayCall(0.01, () => { - // this.isCanDraw = false; - // }) + if (this.isCanDraw) { + return; + } + this.isCanDraw = true; + + delayCall(0.1, () => { + this.isCanDraw = false; + }) + } + + this.pushNodePoolArr(); - if (this.debugLayer.parent && this.debugLayer.active) { - this.debugDrawLayer.removeAllChildren(); - } else { - this.pushNodePoolArr(); - } + // if (this.debugLayer.parent && this.debugLayer.active) { + // this.debugDrawLayer.removeAllChildren(); + // } else { + // this.pushNodePoolArr(); + // } @@ -2100,7 +2108,12 @@ cc.Class({ // this.debugLayer.removeAllChildren(); - this.sample.removeAllChildren(); + + delayCall(1, () => { + this.sample.removeAllChildren(); + }) + + for (let i=0; i<this.dotArr1.length; i++) { this.dotArr1[i].parent = this.sample; } @@ -2997,7 +3010,7 @@ cc.Class({ // console.log(' checkLetter: ', checkLetter); const dot = this.getColorDot(x, -y, r, r, 'blue'); - this.debugDrawLayer.addChild(dot, 5); + // this.debugDrawLayer.addChild(dot, 5); dot.labelText = checkLetter.labelText; @@ -3210,7 +3223,7 @@ cc.Class({ if (this.debugLayer.parent && this.debugLayer.active) { - this.debugDrawLayer.addChild(dot, 5); + // this.debugDrawLayer.addChild(dot, 5); } // dot.key = centerItemArr[i].index + 1; @@ -3337,7 +3350,7 @@ cc.Class({ const bbox = [{x1, y1}, {x2, y2}, {x3, y3}, {x4, y4}] - this.changeBboxPos(bbox); + // this.changeBboxPos(bbox); const content = text[j]; bboxTextArr.push({bbox, content, score}); @@ -3464,7 +3477,7 @@ cc.Class({ const x = baseX + col * disW; const y = baseY; const dot = this.getColorDot(x, y, rectW * 0.1); - this.debugLayer.addChild(dot,5); + // this.debugLayer.addChild(dot,5); dotArr.push(dot); col++; @@ -3636,14 +3649,18 @@ cc.Class({ if (this.debugLayer.parent && this.debugLayer.active) { - node = getSprNode(color); + // node = getSprNode(color); + + node = this.getNewNode(color); + node.anchorX = 0; node.anchorY = 0; node.x = rect.x; node.y = rect.y; node.scaleX = rect.width / node.width; node.scaleY = rect.height / node.height; - this.debugDrawLayer.addChild(node); + + } else { node = this.getNewNode(); @@ -3651,19 +3668,71 @@ cc.Class({ node.ccRect = new cc.Rect(rect.x, rect.y, rect.width, rect.height); + return node; }, - getNewNode() { + getNewNode(color = null) { + + const deleteItemByArr = (item, arr) => { + const index = arr.indexOf(item); + if (index != -1) { + arr.splice(index, 1); + } + } + + let node; + if (this.nodePoolArr.length > 0) { - const node = this.nodePoolArr.pop(); - return node; + + + if (color) { + + node = this.nodePoolArr.find((n) => { + return n.rectColor == color; + }) + + if (node) { + deleteItemByArr(node, this.nodePoolArr) + } else { + node = getSprNode(color); + this.debugDrawLayer.addChild(node); + } + + } else { + + node = this.nodePoolArr.find((n) => { + return n.rectColor == color; + }) + if (node) { + deleteItemByArr(node, this.nodePoolArr) + } else { + node = new cc.Node(); + this.debugDrawLayer.addChild(node); + } + + } + + } else { - const node = new cc.Node(); + + + if (color) { + + node = getSprNode(color); + } else { + + node = new cc.Node(); + } + this.debugDrawLayer.addChild(node); - node.isPoolNode = true; - return node; + } + + node.rectColor = color; + node.isPoolNode = true; + + return node; }, changeNumToInt(obj, opt, digit) { @@ -3682,7 +3751,7 @@ cc.Class({ getColorDot(x, y, w=100, h=100, color='red') { - const node = new cc.Node(); + const node = this.getNewNode(color)// new cc.Node(); if (!h) { h = w; @@ -3695,22 +3764,30 @@ cc.Class({ if (this.debugLayer.parent && this.debugLayer.active) { - const rect = { - x:- w/2, - y: - h/ 2, - width:w, - height:h - } + // const rect = { + // x:- w/2, + // y: - h/ 2, + // width:w, + // height:h + // } - const colorDot = getSprNode(color); + // const colorDot = getSprNode(color); - colorDot.scaleX = rect.width / colorDot.width; - colorDot.scaleY = rect.height / colorDot.height; - node.addChild(colorDot); + // colorDot.scaleX = rect.width / colorDot.width; + // colorDot.scaleY = rect.height / colorDot.height; + // node.addChild(colorDot); + + node.anchorX = 0; + node.anchorY = 0; + node.x = x; + node.y = y; + node.scaleX = w / node.width; + node.scaleY = h / node.height; + } node.x = x; @@ -3773,109 +3850,109 @@ cc.Class({ getPhotoData(cb) { - const tmpData1 = { - "result":{ - "text":[ - { - "left":0.07566666603088379, - "right":0.42733335494995117, - "top":0.07673195749521255, - "bottom":0.11539174616336823, - "score":1, - "content":"CTrace,write,and say.", - "characters":[ - { - "character":"C", - "centerLoc":[ - 0.109000005, - 0.096061856 - ], - "poly":[ - 0.09233334, - 0.08059794, - 0.12733334, - 0.08059794, - 0.12733334, - 0.11281443, - 0.09233334, - 0.11281443 - ] - }, - { - "character":"T", - "centerLoc":[ - 0.14233333, - 0.094773196 - ], - "poly":[ - 0.134, - 0.08575258, - 0.15066667, - 0.08575258, - 0.15066667, - 0.10508247, - 0.134, - 0.10508247 - ] - }, - { - "character":"r", - "centerLoc":[ - 0.15733334, - 0.098639175 - ], - "poly":[ - 0.15066667, - 0.090907216, - 0.164, - 0.090907216, - 0.164, - 0.10508247, - 0.15066667, - 0.10508247 - ] - }, - { - "character":"a", - "centerLoc":[ - 0.17066666, - 0.098639175 - ], - "poly":[ - 0.164, - 0.090907216, - 0.179, - 0.090907216, - 0.179, - 0.10508247, - 0.164, - 0.10508247 - ] - }, - { - "character":"c", - "centerLoc":[ - 0.18733335, - 0.097350515 - ], - "poly":[ - 0.18066667, - 0.089618556, - 0.194, - 0.090907216, - 0.194, - 0.10508247, - 0.18066667, - 0.10508247 - ] - } - ] - } - ] - } - } + // const tmpData1 = { + // "result":{ + // "text":[ + // { + // "left":0.07566666603088379, + // "right":0.42733335494995117, + // "top":0.07673195749521255, + // "bottom":0.11539174616336823, + // "score":1, + // "content":"CTrace,write,and say.", + // "characters":[ + // { + // "character":"C", + // "centerLoc":[ + // 0.109000005, + // 0.096061856 + // ], + // "poly":[ + // 0.09233334, + // 0.08059794, + // 0.12733334, + // 0.08059794, + // 0.12733334, + // 0.11281443, + // 0.09233334, + // 0.11281443 + // ] + // }, + // { + // "character":"T", + // "centerLoc":[ + // 0.14233333, + // 0.094773196 + // ], + // "poly":[ + // 0.134, + // 0.08575258, + // 0.15066667, + // 0.08575258, + // 0.15066667, + // 0.10508247, + // 0.134, + // 0.10508247 + // ] + // }, + // { + // "character":"r", + // "centerLoc":[ + // 0.15733334, + // 0.098639175 + // ], + // "poly":[ + // 0.15066667, + // 0.090907216, + // 0.164, + // 0.090907216, + // 0.164, + // 0.10508247, + // 0.15066667, + // 0.10508247 + // ] + // }, + // { + // "character":"a", + // "centerLoc":[ + // 0.17066666, + // 0.098639175 + // ], + // "poly":[ + // 0.164, + // 0.090907216, + // 0.179, + // 0.090907216, + // 0.179, + // 0.10508247, + // 0.164, + // 0.10508247 + // ] + // }, + // { + // "character":"c", + // "centerLoc":[ + // 0.18733335, + // 0.097350515 + // ], + // "poly":[ + // 0.18066667, + // 0.089618556, + // 0.194, + // 0.090907216, + // 0.194, + // 0.10508247, + // 0.18066667, + // 0.10508247 + // ] + // } + // ] + // } + // ] + // } + // } // const tmpData1 = { "result" : { "text" : [ { "bottom" : 0.12310344725847244, "top" : 0.0817241370677948, "score" : 6.4884182106673037e+28, "content" : "CTrace, write,and say.", "right" : 0.4464285671710968, "left" : 0.071428574621677399 }, { "bottom" : 0.21137930452823639, "top" : 0.12448275834321976, "score" : 6.4884182106673037e+28, "content" : "AAA AAA", "right" : 0.69285714626312256, "left" : 0.078571431338787079 }, { "bottom" : 0.30241379141807556, "top" : 0.25689655542373657, "score" : 6.4884182106673037e+28, "content" : "O1o", "right" : 0.39642858505249023, "left" : 0.19285714626312256 } ] }} - // const tmpData1 = {"result":{"text":[{"left":0.08800879865884781,"right":0.42794278264045715,"top":0.010067113675177097,"bottom":0.16778524219989777,"score":1,"content":"CTrace,write,and say."},{"left":0.09350935369729996,"right":0.48184818029403687,"top":0.1845637559890747,"bottom":0.46644294261932373,"score":0.9882554411888123,"content":"AAAA"},{"left":0.5731573104858398,"right":0.6347634792327881,"top":0.20469798147678375,"bottom":0.463087260723114,"score":0.9638504385948181,"content":"A"},{"left":0.751375138759613,"right":0.8129813075065613,"top":0.20134228467941284,"bottom":0.4563758373260498,"score":0.8285241723060608,"content":"A"},{"left":0.5665566325187683,"right":0.6281628012657166,"top":0.6677852272987366,"bottom":0.8791946172714233,"score":0.8251835703849792,"content":"a"}]}} + const tmpData1 = {"result":{"text":[{"left":0.08800879865884781,"right":0.42794278264045715,"top":0.010067113675177097,"bottom":0.16778524219989777,"score":1,"content":"CTrace,write,and say."},{"left":0.09350935369729996,"right":0.48184818029403687,"top":0.1845637559890747,"bottom":0.46644294261932373,"score":0.9882554411888123,"content":"AAAA"},{"left":0.5731573104858398,"right":0.6347634792327881,"top":0.20469798147678375,"bottom":0.463087260723114,"score":0.9638504385948181,"content":"A"},{"left":0.751375138759613,"right":0.8129813075065613,"top":0.20134228467941284,"bottom":0.4563758373260498,"score":0.8285241723060608,"content":"A"},{"left":0.5665566325187683,"right":0.6281628012657166,"top":0.6677852272987366,"bottom":0.8791946172714233,"score":0.8251835703849792,"content":"a"}]}} // const tmpData1 = {"result":{"text":[{"left":0,"right":0.33299797773361206,"top":0.0971250981092453,"bottom":0.12354312092065811,"content":1,"text":"race,write,and say."},{"left":0.14084507524967194,"right":0.9476861357688904,"top":0.13131313025951385,"bottom":0.21445220708847046,"content":0.9066159129142761,"text":"AAAA-A-AA"},{"left":0.28470826148986816,"right":0.9315895438194275,"top":0.2735042870044708,"bottom":0.32867133617401123,"content":0.9610617756843567,"text":"aaaq qa"},{"left":0.03018108569085598,"right":0.6438632011413574,"top":0.37995338439941406,"bottom":0.41025641560554504,"content":1,"text":"Listen. Then write Aa or cross it out. o5"},{"left":0.636820912361145,"right":0.7655935883522034,"top":0.4755244851112366,"bottom":0.5314685106277466,"content":0.8729087710380554,"text":"Aa"},{"left":0.10663983970880508,"right":0.11167001724243164,"top":0.5788655877113342,"bottom":0.6021755933761597,"content":0.7464486360549927,"text":"4"},{"left":0.1589537262916565,"right":0.29074445366859436,"top":0.5936285853385925,"bottom":0.6596736311912537,"content":0.8887001872062683,"text":"Aa"},{"left":0.6549295783042908,"right":0.7786720395088196,"top":0.5920745730400085,"bottom":0.6643356680870056,"content":0.9307805895805359,"text":"Aa"},{"left":0.11267605423927307,"right":0.4034205377101898,"top":0.7700077891349792,"bottom":0.807303786277771,"content":1,"text":"Lusten and chant, bd"},{"left":0.28973841667175293,"right":0.7162978053092957,"top":0.9254079461097717,"bottom":0.9712509512901306,"content":0.9342746138572693,"text":"户藤미 Ow"},{"left":0.8158953785896301,"right":0.7203219532966614,"top":0.9611499905586243,"bottom":0.9370629191398621,"content":0.7845855951309204,"text":"0ç« "}]}} cb(tmpData1); return;