新增doc

This commit is contained in:
yhh
2020-11-20 14:07:34 +08:00
parent 562bacbe22
commit 7eab688d9c
589 changed files with 179126 additions and 326 deletions

View File

@@ -3188,85 +3188,6 @@ var es;
es.SceneComponent = SceneComponent;
})(es || (es = {}));
var es;
(function (es) {
var CollisionState = (function () {
function CollisionState() {
}
Object.defineProperty(CollisionState.prototype, "hasCollision", {
get: function () {
return this.below || this.right || this.left || this.above;
},
enumerable: true,
configurable: true
});
CollisionState.prototype.reset = function () {
this.becameGroundedThisFrame = this.isGroundedOnOnewayPlatform = this.right = this.left = this.above = this.below = false;
this.slopAngle = 0;
};
CollisionState.prototype.toString = function () {
return "[CollisionState] r: " + this.right + ", l: " + this.left + ", a: " + this.above + ", b: " + this.below + ", angle: " + this.slopAngle + ", wasGroundedLastFrame: " + this.wasGroundedLastFrame + ", becameGroundedThisFrame: " + this.becameGroundedThisFrame;
};
return CollisionState;
}());
es.CollisionState = CollisionState;
var TiledMapMover = (function (_super) {
__extends(TiledMapMover, _super);
function TiledMapMover() {
var _this = _super.call(this) || this;
_this.colliderHorizontalInset = 2;
_this.colliderVerticalInset = 6;
return _this;
}
TiledMapMover.prototype.testCollisions = function (motion, boxColliderBounds, collisionState) {
this._boxColliderBounds = boxColliderBounds;
collisionState.wasGroundedLastFrame = collisionState.below;
collisionState.reset();
var motionX = motion.x;
var motionY = motion.y;
if (motionX != 0) {
var direction = motionX > 0 ? es.Edge.right : es.Edge.left;
var sweptBounds = this.collisionRectForSide(direction, motionX);
var collisionResponse = 0;
if (this.testMapCollision(sweptBounds, direction, collisionState, collisionResponse)) {
motion.x = collisionResponse - es.RectangleExt.getSide(boxColliderBounds, direction);
collisionState.left = direction == es.Edge.left;
collisionState.right = direction == es.Edge.right;
collisionState._movementRemainderX.reset();
}
else {
collisionState.left = false;
collisionState.right = false;
}
}
};
TiledMapMover.prototype.testMapCollision = function (collisionRect, direction, collisionState, collisionResponse) {
var side = es.EdgeExt.oppositeEdge(direction);
var perpindicularPosition = es.EdgeExt.isVertical(side) ? collisionRect.center.x : collisionRect.center.y;
var leadingPosition = es.RectangleExt.getSide(collisionRect, direction);
var shouldTestSlopes = es.EdgeExt.isVertical(side);
};
TiledMapMover.prototype.collisionRectForSide = function (side, motion) {
var bounds;
if (es.EdgeExt.isHorizontal(side)) {
bounds = es.RectangleExt.getRectEdgePortion(this._boxColliderBounds, side);
}
else {
bounds = es.RectangleExt.getHalfRect(this._boxColliderBounds, side);
}
if (es.EdgeExt.isVertical(side)) {
es.RectangleExt.contract(bounds, this.colliderHorizontalInset, 0);
}
else {
es.RectangleExt.contract(bounds, 0, this.colliderVerticalInset);
}
es.RectangleExt.expandSide(bounds, side, motion);
return bounds;
};
return TiledMapMover;
}(es.Component));
es.TiledMapMover = TiledMapMover;
})(es || (es = {}));
var es;
(function (es) {
var Mover = (function (_super) {
__extends(Mover, _super);