新增doc
This commit is contained in:
Vendored
+1
-27
@@ -702,32 +702,6 @@ declare module es {
|
||||
compareTo(other: SceneComponent): number;
|
||||
}
|
||||
}
|
||||
declare module es {
|
||||
class CollisionState {
|
||||
right: boolean;
|
||||
left: boolean;
|
||||
above: boolean;
|
||||
below: boolean;
|
||||
becameGroundedThisFrame: boolean;
|
||||
wasGroundedLastFrame: boolean;
|
||||
isGroundedOnOnewayPlatform: boolean;
|
||||
slopAngle: number;
|
||||
readonly hasCollision: boolean;
|
||||
_movementRemainderX: SubpixelNumber;
|
||||
_movementRemainderY: SubpixelNumber;
|
||||
reset(): void;
|
||||
toString(): string;
|
||||
}
|
||||
class TiledMapMover extends Component {
|
||||
colliderHorizontalInset: number;
|
||||
colliderVerticalInset: number;
|
||||
_boxColliderBounds: Rectangle;
|
||||
constructor();
|
||||
testCollisions(motion: Vector2, boxColliderBounds: Rectangle, collisionState: CollisionState): void;
|
||||
testMapCollision(collisionRect: Rectangle, direction: Edge, collisionState: CollisionState, collisionResponse: number): void;
|
||||
collisionRectForSide(side: Edge, motion: number): Rectangle;
|
||||
}
|
||||
}
|
||||
declare module es {
|
||||
interface ITriggerListener {
|
||||
onTriggerEnter(other: Collider, local: Collider): any;
|
||||
@@ -2447,7 +2421,7 @@ declare module es {
|
||||
}
|
||||
}
|
||||
declare module es {
|
||||
class Ref<T> {
|
||||
class Ref<T extends number | string | boolean> {
|
||||
value: T;
|
||||
constructor(value: T);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user