Commit d81a3efd authored by limingzhe's avatar limingzhe

fix: debug

parent 2c6cd2bf
...@@ -305,6 +305,8 @@ cc.Class({ ...@@ -305,6 +305,8 @@ cc.Class({
loadEnd() { loadEnd() {
console.log(' in loadEnd'); console.log(' in loadEnd');
// this.data.isDebug = true;
this.initData(); this.initData();
this.initView(); this.initView();
// this.initMusic(); // this.initMusic();
...@@ -2292,10 +2294,13 @@ cc.Class({ ...@@ -2292,10 +2294,13 @@ cc.Class({
const oneRegin = this.signRegions[i]; const oneRegin = this.signRegions[i];
const reginRect = new cc.Rect(); const reginRect = new cc.Rect();
reginRect.x = oneRegin.left; reginRect.x = oneRegin.left;
reginRect.y = oneRegin.bottom; reginRect.y = -oneRegin.bottom;
reginRect.width = oneRegin.right - oneRegin.left; reginRect.width = oneRegin.right - oneRegin.left;
reginRect.height = oneRegin.bottom - oneRegin.top; reginRect.height = oneRegin.bottom - oneRegin.top;
const centerP = new cc.Vec2((reginRect.x + reginRect.width / 2) , (reginRect.y + reginRect.height / 2) );
reginRect.centerP = centerP;
this.signRegionRectArr.push(reginRect); this.signRegionRectArr.push(reginRect);
} }
} }
...@@ -2306,29 +2311,48 @@ cc.Class({ ...@@ -2306,29 +2311,48 @@ cc.Class({
const newSymbol = []; const newSymbol = [];
for (let j=0; j<signRegionRectArr.length; j++) { for (let j=0; j<signRegionRectArr.length; j++) {
const reginRect = signRegionRectArr[j]; newSymbol[j] = -1;
newSymbol[j] = -1; }
for(let i=0; i<poly.length; i++) { for(let i=0; i<poly.length; i++) {
const oneSymbol = symbol[i];
const onePoly = poly[i];
const oneSymbol = symbol[i]; const polyRect = new cc.Rect();
const onePoly = poly[i]; polyRect.x = onePoly.left;
polyRect.y = -onePoly.bottom;
polyRect.width = onePoly.right - onePoly.left;
const polyRect = new cc.Rect(); polyRect.height = onePoly.bottom - onePoly.top;
polyRect.x = onePoly.left;
polyRect.y = onePoly.bottom;
polyRect.width = onePoly.right - onePoly.left;
polyRect.height = onePoly.bottom - onePoly.top;
if (reginRect.intersects(polyRect)) { const polyCenterP = new cc.Vec2( (polyRect.x + polyRect.width / 2) , (polyRect.y + polyRect.height / 2) );
newSymbol[i] = oneSymbol let minDisRectIndex;
break; let minLen;
for (let j=0; j<signRegionRectArr.length; j++) {
const reginRect = signRegionRectArr[j];
const reginRectCenterP = reginRect.centerP;
const distance = cc.Vec2.distance(polyCenterP, reginRectCenterP);
console.log('~polyCenterP: ', polyCenterP);
console.log('~reginRectCenterP: ', reginRectCenterP);
console.log('~distance: ', distance);
if (minLen == null || minLen > distance) {
minLen = distance;
minDisRectIndex = j;
// minDisRect = reginRect;
} }
} }
newSymbol[minDisRectIndex] = oneSymbol
const colorRect = this.getColorRect(polyRect, "red");
this.debugDrawLayer.addChild(colorRect, 1);
} }
console.log('newSymbol: ' + JSON.stringify(newSymbol)); console.log('newSymbol: ' + JSON.stringify(newSymbol));
......
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