Added more helper functions for backend collision debugging.

This commit is contained in:
genxium
2022-11-12 20:34:38 +08:00
parent 89a54211e1
commit bd9beec5e5
10 changed files with 152 additions and 129 deletions

View File

@@ -17,7 +17,7 @@
</objectgroup>
<layer id="3" name="FirsrtFloor" width="50" height="50">
<data encoding="base64" compression="zlib">
eJztwQENAAAAwqD3T20ON6AAAAAAAAAAAADg3wAnEAAB
eJzt1jEKgDAQRNE0GtD739fGaQIhqJHdCf81aSz2oyspBQAAAADWcUYPMIEaaugU37TvwbGl9y05tYz2wWFfaMiBhhyNKzRs99n7lzo0SG1OcWqQtsWxQdSwD57L3CCjO4dDg7zd+Yye7nxmajlCp5jD6Y4OAAAA4H8XE6wBrA==
</data>
</layer>
<objectgroup id="4" name="Barrier">

View File

@@ -100,7 +100,7 @@
"__id__": 1
},
"_children": [],
"_active": false,
"_active": true,
"_components": [
{
"__id__": 3
@@ -119,8 +119,8 @@
},
"_contentSize": {
"__type__": "cc.Size",
"width": 93.36,
"height": 40
"width": 46.68,
"height": 27.72
},
"_anchorPoint": {
"__type__": "cc.Vec2",
@@ -132,7 +132,7 @@
"ctor": "Float64Array",
"array": [
-5,
101,
50,
0,
0,
0,
@@ -164,12 +164,16 @@
"__id__": 2
},
"_enabled": true,
"_materials": [],
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_useOriginalSize": false,
"_string": "(0, 0)",
"_N$string": "(0, 0)",
"_fontSize": 40,
"_lineHeight": 40,
"_fontSize": 20,
"_lineHeight": 22,
"_enableWrapText": true,
"_N$file": null,
"_isSystemFontUsed": true,
@@ -557,15 +561,13 @@
},
"_enabled": true,
"animComp": null,
"baseSpeed": 50,
"speed": 50,
"lastMovedAt": 0,
"eps": 0.1,
"magicLeanLowerBound": 0.414,
"magicLeanUpperBound": 2.414,
"arrowTipNode": {
"__id__": 8
},
"coordLabel": {
"__id__": 3
},
"_id": ""
},
{

View File

@@ -100,7 +100,7 @@
"__id__": 1
},
"_children": [],
"_active": false,
"_active": true,
"_components": [
{
"__id__": 3
@@ -119,8 +119,8 @@
},
"_contentSize": {
"__type__": "cc.Size",
"width": 93.36,
"height": 40
"width": 46.68,
"height": 27.72
},
"_anchorPoint": {
"__type__": "cc.Vec2",
@@ -132,7 +132,7 @@
"ctor": "Float64Array",
"array": [
-5,
101,
50,
0,
0,
0,
@@ -164,12 +164,16 @@
"__id__": 2
},
"_enabled": true,
"_materials": [],
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_useOriginalSize": false,
"_string": "(0, 0)",
"_N$string": "(0, 0)",
"_fontSize": 40,
"_lineHeight": 40,
"_fontSize": 20,
"_lineHeight": 22,
"_enableWrapText": true,
"_N$file": null,
"_isSystemFontUsed": true,
@@ -557,15 +561,13 @@
},
"_enabled": true,
"animComp": null,
"baseSpeed": 50,
"speed": 50,
"lastMovedAt": 0,
"eps": 0.1,
"magicLeanLowerBound": 0.414,
"magicLeanUpperBound": 2.414,
"arrowTipNode": {
"__id__": 8
},
"coordLabel": {
"__id__": 3
},
"_id": ""
},
{

View File

@@ -6,30 +6,10 @@ module.export = cc.Class({
type: cc.Animation,
default: null,
},
baseSpeed: {
type: cc.Float,
default: 50,
},
speed: {
type: cc.Float,
default: 50
},
lastMovedAt: {
type: cc.Float,
default: 0 // In "GMT milliseconds"
},
eps: {
default: 0.10,
type: cc.Float
},
magicLeanLowerBound: {
default: 0.414, // Tangent of (PI/8).
type: cc.Float
},
magicLeanUpperBound: {
default: 2.414, // Tangent of (3*PI/8).
type: cc.Float
},
}
},
// LIFE-CYCLE CALLBACKS:
@@ -70,7 +50,7 @@ module.export = cc.Class({
this.activeDirection = newScheduledDirection;
this.activeDirection = newScheduledDirection;
const clipKey = newScheduledDirection.dx.toString() + newScheduledDirection.dy.toString();
const clips = (this.attacked ? this.attackedClips : this.clips);
const clips = (this.attacked ? this.attackedClips : this.clips);
let clip = clips[clipKey];
if (!clip) {
// Keep playing the current anim.
@@ -86,11 +66,9 @@ module.export = cc.Class({
}
},
update(dt) {
},
update(dt) {},
lateUpdate(dt) {
},
lateUpdate(dt) {},
_generateRandomDirection() {
return ALL_DISCRETE_DIRECTIONS_CLOCKWISE[Math.floor(Math.random() * ALL_DISCRETE_DIRECTIONS_CLOCKWISE.length)];
@@ -117,16 +95,16 @@ module.export = cc.Class({
updateSpeed(proposedSpeed) {
if (0 == proposedSpeed && 0 < this.speed) {
this.startFrozenDisplay();
}
this.startFrozenDisplay();
}
if (0 < proposedSpeed && 0 == this.speed) {
this.stopFrozenDisplay();
}
this.speed = proposedSpeed;
this.stopFrozenDisplay();
}
this.speed = proposedSpeed;
},
startFrozenDisplay() {
const self = this;
const self = this;
self.attacked = true;
},

View File

@@ -352,6 +352,8 @@ cc.Class({
window.mapIns = self;
window.forceBigEndianFloatingNumDecoding = self.forceBigEndianFloatingNumDecoding;
self.showCriticalCoordinateLabels = true;
console.warn("+++++++ Map onLoad()");
window.handleClientSessionError = function() {
console.warn('+++++++ Common handleClientSessionError()');
@@ -473,9 +475,36 @@ cc.Class({
const x0 = boundaryObj[0].x,
y0 = boundaryObj[0].y;
let pts = [];
// TODO: Simplify this redundant coordinate conversion within "extractBoundaryObjects", but since this routine is only called once per battle, not urgent.
for (let i = 0; i < boundaryObj.length; ++i) {
pts.push([boundaryObj[i].x - x0, boundaryObj[i].y - y0]);
const dx = boundaryObj[i].x - x0;
const dy = boundaryObj[i].y - y0;
pts.push([dx, dy]);
if (self.showCriticalCoordinateLabels) {
const barrierVertLabelNode = new cc.Node();
switch (i % 4) {
case 0:
barrierVertLabelNode.color = cc.Color.RED;
break;
case 1:
barrierVertLabelNode.color = cc.Color.GRAY;
break;
case 2:
barrierVertLabelNode.color = cc.Color.BLACK;
break;
default:
barrierVertLabelNode.color = cc.Color.MAGENTA;
break;
}
barrierVertLabelNode.setPosition(cc.v2(x0+0.95*dx, y0+0.5*dy));
const barrierVertLabel = barrierVertLabelNode.addComponent(cc.Label);
barrierVertLabel.fontSize = 20;
barrierVertLabel.lineHeight = 22;
barrierVertLabel.string = `(${boundaryObj[i].x.toFixed(1)}, ${boundaryObj[i].y.toFixed(1)})`;
safelyAddChild(self.node, barrierVertLabelNode);
setLocalZOrder(barrierVertLabelNode, 5);
barrierVertLabelNode.active = true;
}
}
const newBarrier = self.collisionSys.createPolygon(x0, y0, pts);
// console.log("Created barrier: ", newBarrier);

View File

@@ -1,4 +1,4 @@
const BasePlayer = require("./BasePlayer");
const BasePlayer = require("./BasePlayer");
cc.Class({
extends: BasePlayer,
@@ -7,6 +7,10 @@ cc.Class({
arrowTipNode: {
type: cc.Node,
default: null
},
coordLabel: {
type: cc.Label,
default: null
}
},
start() {
@@ -34,7 +38,7 @@ cc.Class({
return;
}
self.arrowTipNode.active = true;
window.setTimeout(function(){
window.setTimeout(function() {
if (null == self.arrowTipNode) {
return;
}
@@ -44,6 +48,9 @@ cc.Class({
update(dt) {
BasePlayer.prototype.update.call(this, dt);
if (this.mapIns.showCriticalCoordinateLabels) {
this.coordLabel.string = `(${this.node.x.toFixed(2)}, ${this.node.y.toFixed(2)})`;
}
},
});

View File

@@ -371,8 +371,8 @@ TileCollisionManager.prototype.extractBoundaryObjects = function (withTiledMapNo
const tilesElListUnderTilesets = {};
for (let tsxFilenameIdx = 0; tsxFilenameIdx < tsxFileNames.length; ++tsxFilenameIdx) {
const tsxOrientation = tileSets[tsxFilenameIdx].orientation;
if (cc.TiledMap.Orientation.ORTHO != tsxOrientation) {
cc.error("Error at tileset %s: We proceed with ONLY tilesets in ORTHO orientation for all map orientations by now.", tsxFileNames[tsxFilenameIdx]);
if (cc.TiledMap.Orientation.ORTHO == tsxOrientation) {
cc.error("Error at tileset %s: We don't proceed with tilesets in ORTHO orientation by now.", tsxFileNames[tsxFilenameIdx]);
continue;
};