Commit d81a3efd authored by limingzhe's avatar limingzhe

fix: debug

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