mirror of
https://github.com/genxium/DelayNoMore
synced 2025-10-09 00:26:39 +00:00
Added more helper functions for backend collision debugging.
This commit is contained in:
@@ -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;
|
||||
},
|
||||
|
||||
|
@@ -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);
|
||||
|
@@ -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)})`;
|
||||
}
|
||||
},
|
||||
|
||||
});
|
||||
|
@@ -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;
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user