新增raycast射线
This commit is contained in:
353
demo/libs/framework/framework.d.ts
vendored
353
demo/libs/framework/framework.d.ts
vendored
@@ -27,9 +27,9 @@ declare module es {
|
||||
declare module es {
|
||||
class AStarPathfinder {
|
||||
static search<T>(graph: IAstarGraph<T>, start: T, goal: T): T[];
|
||||
static recontructPath<T>(cameFrom: Map<T, T>, start: T, goal: T): T[];
|
||||
private static hasKey;
|
||||
private static getKey;
|
||||
static recontructPath<T>(cameFrom: Map<T, T>, start: T, goal: T): T[];
|
||||
}
|
||||
class AStarNode<T> extends PriorityQueueNode {
|
||||
data: T;
|
||||
@@ -68,9 +68,9 @@ declare module es {
|
||||
private _nodes;
|
||||
private _numNodesEverEnqueued;
|
||||
constructor(maxNodes: number);
|
||||
clear(): void;
|
||||
readonly count: number;
|
||||
readonly maxSize: number;
|
||||
clear(): void;
|
||||
contains(node: T): boolean;
|
||||
enqueue(node: T, priority: number): void;
|
||||
dequeue(): T;
|
||||
@@ -103,28 +103,21 @@ declare module es {
|
||||
}
|
||||
declare module es {
|
||||
class Vector2 {
|
||||
x: number;
|
||||
y: number;
|
||||
private static readonly unitYVector;
|
||||
private static readonly unitXVector;
|
||||
private static readonly unitVector2;
|
||||
private static readonly zeroVector2;
|
||||
x: number;
|
||||
y: number;
|
||||
constructor(x?: number, y?: number);
|
||||
static readonly zero: Vector2;
|
||||
static readonly one: Vector2;
|
||||
static readonly unitX: Vector2;
|
||||
static readonly unitY: Vector2;
|
||||
constructor(x?: number, y?: number);
|
||||
add(value: Vector2): Vector2;
|
||||
divide(value: Vector2): Vector2;
|
||||
multiply(value: Vector2): Vector2;
|
||||
subtract(value: Vector2): this;
|
||||
static add(value1: Vector2, value2: Vector2): Vector2;
|
||||
static divide(value1: Vector2, value2: Vector2): Vector2;
|
||||
static multiply(value1: Vector2, value2: Vector2): Vector2;
|
||||
static subtract(value1: Vector2, value2: Vector2): Vector2;
|
||||
normalize(): void;
|
||||
length(): number;
|
||||
round(): Vector2;
|
||||
static normalize(value: Vector2): Vector2;
|
||||
static dot(value1: Vector2, value2: Vector2): number;
|
||||
static distanceSquared(value1: Vector2, value2: Vector2): number;
|
||||
@@ -133,6 +126,13 @@ declare module es {
|
||||
static transform(position: Vector2, matrix: Matrix2D): Vector2;
|
||||
static distance(value1: Vector2, value2: Vector2): number;
|
||||
static negate(value: Vector2): Vector2;
|
||||
add(value: Vector2): Vector2;
|
||||
divide(value: Vector2): Vector2;
|
||||
multiply(value: Vector2): Vector2;
|
||||
subtract(value: Vector2): this;
|
||||
normalize(): this;
|
||||
length(): number;
|
||||
round(): Vector2;
|
||||
equals(other: Vector2): boolean;
|
||||
}
|
||||
}
|
||||
@@ -185,9 +185,9 @@ declare module es {
|
||||
}
|
||||
class WeightedPathfinder {
|
||||
static search<T>(graph: IWeightedGraph<T>, start: T, goal: T): T[];
|
||||
static recontructPath<T>(cameFrom: Map<T, T>, start: T, goal: T): T[];
|
||||
private static hasKey;
|
||||
private static getKey;
|
||||
static recontructPath<T>(cameFrom: Map<T, T>, start: T, goal: T): T[];
|
||||
}
|
||||
}
|
||||
declare module es {
|
||||
@@ -228,12 +228,12 @@ declare module es {
|
||||
declare module es {
|
||||
abstract class Component {
|
||||
entity: Entity;
|
||||
readonly transform: Transform;
|
||||
enabled: boolean;
|
||||
updateOrder: number;
|
||||
updateInterval: number;
|
||||
readonly transform: Transform;
|
||||
private _enabled;
|
||||
enabled: boolean;
|
||||
private _updateOrder;
|
||||
updateOrder: number;
|
||||
initialize(): void;
|
||||
onAddedToEntity(): void;
|
||||
onRemovedFromEntity(): void;
|
||||
@@ -252,27 +252,27 @@ declare module es {
|
||||
static emitter: Emitter<CoreEvents>;
|
||||
static graphicsDevice: GraphicsDevice;
|
||||
static content: ContentManager;
|
||||
static readonly Instance: Core;
|
||||
static _instance: Core;
|
||||
_scene: Scene;
|
||||
_nextScene: Scene;
|
||||
_sceneTransition: SceneTransition;
|
||||
_globalManagers: GlobalManager[];
|
||||
static scene: Scene;
|
||||
constructor();
|
||||
private onAddToStage;
|
||||
onOrientationChanged(): void;
|
||||
protected onGraphicsDeviceReset(): void;
|
||||
protected initialize(): void;
|
||||
protected update(): Promise<void>;
|
||||
draw(): Promise<void>;
|
||||
startDebugUpdate(): void;
|
||||
endDebugUpdate(): void;
|
||||
onSceneChanged(): void;
|
||||
static readonly Instance: Core;
|
||||
_scene: Scene;
|
||||
static scene: Scene;
|
||||
static startSceneTransition<T extends SceneTransition>(sceneTransition: T): T;
|
||||
static registerGlobalManager(manager: es.GlobalManager): void;
|
||||
static unregisterGlobalManager(manager: es.GlobalManager): void;
|
||||
static getGlobalManager<T extends es.GlobalManager>(type: any): T;
|
||||
onOrientationChanged(): void;
|
||||
draw(): Promise<void>;
|
||||
startDebugUpdate(): void;
|
||||
endDebugUpdate(): void;
|
||||
onSceneChanged(): void;
|
||||
protected onGraphicsDeviceReset(): void;
|
||||
protected initialize(): void;
|
||||
protected update(): Promise<void>;
|
||||
private onAddToStage;
|
||||
}
|
||||
}
|
||||
declare module es {
|
||||
@@ -290,16 +290,17 @@ declare module es {
|
||||
readonly id: number;
|
||||
readonly transform: Transform;
|
||||
readonly components: ComponentList;
|
||||
tag: number;
|
||||
updateInterval: number;
|
||||
enabled: boolean;
|
||||
updateOrder: number;
|
||||
componentBits: BitSet;
|
||||
constructor(name: string);
|
||||
_isDestroyed: boolean;
|
||||
readonly isDestroyed: boolean;
|
||||
componentBits: BitSet;
|
||||
private _tag;
|
||||
tag: number;
|
||||
private _enabled;
|
||||
enabled: boolean;
|
||||
private _updateOrder;
|
||||
updateOrder: number;
|
||||
parent: Transform;
|
||||
readonly childCount: number;
|
||||
position: Vector2;
|
||||
@@ -313,7 +314,6 @@ declare module es {
|
||||
readonly worldInverseTransform: Matrix2D;
|
||||
readonly localToWorldTransform: Matrix2D;
|
||||
readonly worldToLocalTransform: Matrix2D;
|
||||
constructor(name: string);
|
||||
onTransformChanged(comp: transform.Component): void;
|
||||
setTag(tag: number): Entity;
|
||||
setEnabled(isEnabled: boolean): this;
|
||||
@@ -322,7 +322,6 @@ declare module es {
|
||||
detachFromScene(): void;
|
||||
attachToScene(newScene: Scene): void;
|
||||
clone(position?: Vector2): Entity;
|
||||
protected copyFrom(entity: Entity): void;
|
||||
onAddedToScene(): void;
|
||||
onRemovedFromScene(): void;
|
||||
update(): void;
|
||||
@@ -336,6 +335,7 @@ declare module es {
|
||||
removeAllComponents(): void;
|
||||
compareTo(other: Entity): number;
|
||||
toString(): string;
|
||||
protected copyFrom(entity: Entity): void;
|
||||
}
|
||||
}
|
||||
declare module es {
|
||||
@@ -349,8 +349,8 @@ declare module es {
|
||||
_renderers: Renderer[];
|
||||
readonly _postProcessors: PostProcessor[];
|
||||
_didSceneBegin: any;
|
||||
static createWithDefaultRenderer(): Scene;
|
||||
constructor();
|
||||
static createWithDefaultRenderer(): Scene;
|
||||
initialize(): void;
|
||||
onStart(): Promise<void>;
|
||||
unload(): void;
|
||||
@@ -397,20 +397,6 @@ declare module es {
|
||||
}
|
||||
class Transform extends HashObject {
|
||||
readonly entity: Entity;
|
||||
parent: Transform;
|
||||
readonly childCount: number;
|
||||
position: Vector2;
|
||||
localPosition: Vector2;
|
||||
rotation: number;
|
||||
rotationDegrees: number;
|
||||
localRotation: number;
|
||||
localRotationDegrees: number;
|
||||
scale: Vector2;
|
||||
localScale: Vector2;
|
||||
readonly worldInverseTransform: Matrix2D;
|
||||
readonly localToWorldTransform: Matrix2D;
|
||||
readonly worldToLocalTransform: Matrix2D;
|
||||
_parent: Transform;
|
||||
hierarchyDirty: DirtyType;
|
||||
_localDirty: boolean;
|
||||
_localPositionDirty: boolean;
|
||||
@@ -421,19 +407,33 @@ declare module es {
|
||||
_worldInverseDirty: boolean;
|
||||
_localTransform: Matrix2D;
|
||||
_worldTransform: Matrix2D;
|
||||
_worldToLocalTransform: Matrix2D;
|
||||
_worldInverseTransform: Matrix2D;
|
||||
_rotationMatrix: Matrix2D;
|
||||
_translationMatrix: Matrix2D;
|
||||
_scaleMatrix: Matrix2D;
|
||||
_position: Vector2;
|
||||
_scale: Vector2;
|
||||
_rotation: number;
|
||||
_localPosition: Vector2;
|
||||
_localScale: Vector2;
|
||||
_localRotation: number;
|
||||
_children: Transform[];
|
||||
constructor(entity: Entity);
|
||||
readonly childCount: number;
|
||||
rotationDegrees: number;
|
||||
localRotationDegrees: number;
|
||||
readonly localToWorldTransform: Matrix2D;
|
||||
_parent: Transform;
|
||||
parent: Transform;
|
||||
_worldToLocalTransform: Matrix2D;
|
||||
readonly worldToLocalTransform: Matrix2D;
|
||||
_worldInverseTransform: Matrix2D;
|
||||
readonly worldInverseTransform: Matrix2D;
|
||||
_position: Vector2;
|
||||
position: Vector2;
|
||||
_scale: Vector2;
|
||||
scale: Vector2;
|
||||
_rotation: number;
|
||||
rotation: number;
|
||||
_localPosition: Vector2;
|
||||
localPosition: Vector2;
|
||||
_localScale: Vector2;
|
||||
localScale: Vector2;
|
||||
_localRotation: number;
|
||||
localRotation: number;
|
||||
getChild(index: number): Transform;
|
||||
setParent(parent: Transform): Transform;
|
||||
setPosition(x: number, y: number): Transform;
|
||||
@@ -465,23 +465,7 @@ declare module es {
|
||||
bottom: number;
|
||||
}
|
||||
class Camera extends Component {
|
||||
position: Vector2;
|
||||
rotation: number;
|
||||
zoom: number;
|
||||
minimumZoom: number;
|
||||
maximumZoom: number;
|
||||
readonly bounds: Rectangle;
|
||||
readonly transformMatrix: Matrix2D;
|
||||
readonly inverseTransformMatrix: Matrix2D;
|
||||
origin: Vector2;
|
||||
_zoom: any;
|
||||
_minimumZoom: number;
|
||||
_maximumZoom: number;
|
||||
_bounds: Rectangle;
|
||||
_inset: CameraInset;
|
||||
_transformMatrix: Matrix2D;
|
||||
_inverseTransformMatrix: Matrix2D;
|
||||
_origin: Vector2;
|
||||
_areMatrixedDirty: boolean;
|
||||
_areBoundsDirty: boolean;
|
||||
_isProjectionMatrixDirty: boolean;
|
||||
@@ -496,8 +480,23 @@ declare module es {
|
||||
_cameraStyle: CameraStyle;
|
||||
_worldSpaceDeadZone: Rectangle;
|
||||
constructor(targetEntity?: Entity, cameraStyle?: CameraStyle);
|
||||
position: Vector2;
|
||||
rotation: number;
|
||||
_zoom: any;
|
||||
zoom: number;
|
||||
_minimumZoom: number;
|
||||
minimumZoom: number;
|
||||
_maximumZoom: number;
|
||||
maximumZoom: number;
|
||||
_bounds: Rectangle;
|
||||
readonly bounds: Rectangle;
|
||||
_transformMatrix: Matrix2D;
|
||||
readonly transformMatrix: Matrix2D;
|
||||
_inverseTransformMatrix: Matrix2D;
|
||||
readonly inverseTransformMatrix: Matrix2D;
|
||||
_origin: Vector2;
|
||||
origin: Vector2;
|
||||
onSceneSizeChanged(newWidth: number, newHeight: number): void;
|
||||
protected updateMatrixes(): void;
|
||||
setInset(left: number, right: number, top: number, bottom: number): Camera;
|
||||
setPosition(position: Vector2): this;
|
||||
setRotation(rotation: number): Camera;
|
||||
@@ -516,6 +515,7 @@ declare module es {
|
||||
updateFollow(): void;
|
||||
follow(targetEntity: Entity, cameraStyle?: CameraStyle): void;
|
||||
setCenteredDeadzone(width: number, height: number): void;
|
||||
protected updateMatrixes(): void;
|
||||
}
|
||||
}
|
||||
declare module es {
|
||||
@@ -540,28 +540,28 @@ declare module es {
|
||||
declare module es {
|
||||
abstract class RenderableComponent extends Component implements IRenderable {
|
||||
displayObject: egret.DisplayObject;
|
||||
color: number;
|
||||
protected _areBoundsDirty: boolean;
|
||||
readonly width: number;
|
||||
readonly height: number;
|
||||
readonly bounds: Rectangle;
|
||||
renderLayer: number;
|
||||
color: number;
|
||||
localOffset: Vector2;
|
||||
isVisible: boolean;
|
||||
protected _localOffset: Vector2;
|
||||
localOffset: Vector2;
|
||||
protected _renderLayer: number;
|
||||
renderLayer: number;
|
||||
protected _bounds: Rectangle;
|
||||
readonly bounds: Rectangle;
|
||||
private _isVisible;
|
||||
protected _areBoundsDirty: boolean;
|
||||
isVisible: boolean;
|
||||
onEntityTransformChanged(comp: transform.Component): void;
|
||||
abstract render(camera: Camera): any;
|
||||
protected onBecameVisible(): void;
|
||||
protected onBecameInvisible(): void;
|
||||
isVisibleFromCamera(camera: Camera): boolean;
|
||||
setRenderLayer(renderLayer: number): RenderableComponent;
|
||||
setColor(color: number): RenderableComponent;
|
||||
setLocalOffset(offset: Vector2): RenderableComponent;
|
||||
sync(camera: Camera): void;
|
||||
toString(): string;
|
||||
protected onBecameVisible(): void;
|
||||
protected onBecameInvisible(): void;
|
||||
}
|
||||
}
|
||||
declare module es {
|
||||
@@ -575,13 +575,13 @@ declare module es {
|
||||
}
|
||||
declare module es {
|
||||
class SpriteRenderer extends RenderableComponent {
|
||||
readonly bounds: Rectangle;
|
||||
origin: Vector2;
|
||||
originNormalized: Vector2;
|
||||
sprite: Sprite;
|
||||
protected _origin: Vector2;
|
||||
protected _sprite: Sprite;
|
||||
constructor(sprite?: Sprite | egret.Texture);
|
||||
readonly bounds: Rectangle;
|
||||
originNormalized: Vector2;
|
||||
protected _origin: Vector2;
|
||||
origin: Vector2;
|
||||
protected _sprite: Sprite;
|
||||
sprite: Sprite;
|
||||
setSprite(sprite: Sprite): SpriteRenderer;
|
||||
setOrigin(origin: Vector2): SpriteRenderer;
|
||||
setOriginNormalized(value: Vector2): SpriteRenderer;
|
||||
@@ -593,9 +593,9 @@ declare module es {
|
||||
protected sourceRect: Rectangle;
|
||||
protected leftTexture: egret.Bitmap;
|
||||
protected rightTexture: egret.Bitmap;
|
||||
constructor(sprite: Sprite);
|
||||
scrollX: number;
|
||||
scrollY: number;
|
||||
constructor(sprite: Sprite);
|
||||
render(camera: es.Camera): void;
|
||||
}
|
||||
}
|
||||
@@ -647,12 +647,12 @@ declare module es {
|
||||
currentAnimation: SpriteAnimation;
|
||||
currentAnimationName: string;
|
||||
currentFrame: number;
|
||||
readonly isRunning: boolean;
|
||||
readonly animations: Map<string, SpriteAnimation>;
|
||||
private _animations;
|
||||
_elapsedTime: number;
|
||||
_loopMode: LoopMode;
|
||||
constructor(sprite?: Sprite);
|
||||
readonly isRunning: boolean;
|
||||
private _animations;
|
||||
readonly animations: Map<string, SpriteAnimation>;
|
||||
update(): void;
|
||||
addAnimation(name: string, animation: SpriteAnimation): SpriteAnimator;
|
||||
play(name: string, loopMode?: LoopMode): void;
|
||||
@@ -689,22 +689,22 @@ declare module es {
|
||||
declare module es {
|
||||
abstract class Collider extends Component {
|
||||
shape: Shape;
|
||||
localOffset: Vector2;
|
||||
readonly absolutePosition: Vector2;
|
||||
readonly rotation: number;
|
||||
isTrigger: boolean;
|
||||
physicsLayer: number;
|
||||
collidesWithLayers: number;
|
||||
shouldColliderScaleAndRotateWithTransform: boolean;
|
||||
readonly bounds: Rectangle;
|
||||
registeredPhysicsBounds: Rectangle;
|
||||
protected _colliderRequiresAutoSizing: any;
|
||||
protected _localOffset: Vector2;
|
||||
_localOffsetLength: number;
|
||||
protected _isParentEntityAddedToScene: any;
|
||||
protected _isColliderRegistered: any;
|
||||
_isPositionDirty: boolean;
|
||||
_isRotationDirty: boolean;
|
||||
protected _colliderRequiresAutoSizing: any;
|
||||
protected _isParentEntityAddedToScene: any;
|
||||
protected _isColliderRegistered: any;
|
||||
readonly absolutePosition: Vector2;
|
||||
readonly rotation: number;
|
||||
readonly bounds: Rectangle;
|
||||
protected _localOffset: Vector2;
|
||||
localOffset: Vector2;
|
||||
setLocalOffset(offset: Vector2): Collider;
|
||||
setShouldColliderScaleAndRotateWithTransform(shouldColliderScaleAndRotationWithTransform: boolean): Collider;
|
||||
onAddedToEntity(): void;
|
||||
@@ -721,9 +721,9 @@ declare module es {
|
||||
}
|
||||
declare module es {
|
||||
class BoxCollider extends Collider {
|
||||
constructor();
|
||||
width: number;
|
||||
height: number;
|
||||
constructor();
|
||||
setSize(width: number, height: number): this;
|
||||
setWidth(width: number): BoxCollider;
|
||||
setHeight(height: number): void;
|
||||
@@ -732,8 +732,8 @@ declare module es {
|
||||
}
|
||||
declare module es {
|
||||
class CircleCollider extends Collider {
|
||||
radius: number;
|
||||
constructor(radius?: number);
|
||||
radius: number;
|
||||
setRadius(radius: number): CircleCollider;
|
||||
toString(): string;
|
||||
}
|
||||
@@ -745,12 +745,12 @@ declare module es {
|
||||
}
|
||||
declare module es {
|
||||
class EntitySystem {
|
||||
private _scene;
|
||||
private _entities;
|
||||
constructor(matcher?: Matcher);
|
||||
private _scene;
|
||||
scene: Scene;
|
||||
private _matcher;
|
||||
readonly matcher: Matcher;
|
||||
scene: Scene;
|
||||
constructor(matcher?: Matcher);
|
||||
initialize(): void;
|
||||
onChanged(entity: Entity): void;
|
||||
add(entity: Entity): void;
|
||||
@@ -783,8 +783,8 @@ declare module es {
|
||||
declare module es {
|
||||
abstract class ProcessingSystem extends EntitySystem {
|
||||
onChanged(entity: Entity): void;
|
||||
protected process(entities: Entity[]): void;
|
||||
abstract processSystem(): any;
|
||||
protected process(entities: Entity[]): void;
|
||||
}
|
||||
}
|
||||
declare module es {
|
||||
@@ -796,12 +796,12 @@ declare module es {
|
||||
andNot(bs: BitSet): void;
|
||||
cardinality(): number;
|
||||
clear(pos?: number): void;
|
||||
private ensure;
|
||||
get(pos: number): boolean;
|
||||
intersects(set: BitSet): boolean;
|
||||
isEmpty(): boolean;
|
||||
nextSetBit(from: number): number;
|
||||
set(pos: number, value?: boolean): void;
|
||||
private ensure;
|
||||
}
|
||||
}
|
||||
declare module es {
|
||||
@@ -879,13 +879,13 @@ declare module es {
|
||||
onComponentRemoved(entity: Entity): void;
|
||||
onEntityAdded(entity: Entity): void;
|
||||
onEntityRemoved(entity: Entity): void;
|
||||
protected notifyEntityChanged(entity: Entity): void;
|
||||
protected removeFromProcessors(entity: Entity): void;
|
||||
begin(): void;
|
||||
update(): void;
|
||||
lateUpdate(): void;
|
||||
end(): void;
|
||||
getProcessor<T extends EntitySystem>(): T;
|
||||
protected notifyEntityChanged(entity: Entity): void;
|
||||
protected removeFromProcessors(entity: Entity): void;
|
||||
}
|
||||
}
|
||||
declare module es {
|
||||
@@ -939,13 +939,13 @@ declare module es {
|
||||
}
|
||||
}
|
||||
declare class StringUtils {
|
||||
private static specialSigns;
|
||||
static matchChineseWord(str: string): string[];
|
||||
static lTrim(target: string): string;
|
||||
static rTrim(target: string): string;
|
||||
static trim(target: string): string;
|
||||
static isWhiteSpace(str: string): boolean;
|
||||
static replaceMatch(mainStr: string, targetStr: string, replaceStr: string, caseMark?: boolean): string;
|
||||
private static specialSigns;
|
||||
static htmlSpecialChars(str: string, reversion?: boolean): string;
|
||||
static zfill(str: string, width?: number): string;
|
||||
static reverse(str: string): string;
|
||||
@@ -969,8 +969,8 @@ declare module es {
|
||||
static deltaTime: number;
|
||||
static timeScale: number;
|
||||
static frameCount: number;
|
||||
private static _lastTime;
|
||||
static _timeSinceSceneLoad: any;
|
||||
private static _lastTime;
|
||||
static update(currentTime: number): void;
|
||||
static sceneChanged(): void;
|
||||
static checkEvery(interval: number): boolean;
|
||||
@@ -998,10 +998,10 @@ declare module es {
|
||||
}
|
||||
declare module es {
|
||||
class GraphicsDevice {
|
||||
private _viewport;
|
||||
readonly viewport: Viewport;
|
||||
graphicsCapabilities: GraphicsCapabilities;
|
||||
constructor();
|
||||
private _viewport;
|
||||
readonly viewport: Viewport;
|
||||
private setup;
|
||||
}
|
||||
}
|
||||
@@ -1009,15 +1009,15 @@ declare module es {
|
||||
class Viewport {
|
||||
private _x;
|
||||
private _y;
|
||||
private _width;
|
||||
private _height;
|
||||
private _minDepth;
|
||||
private _maxDepth;
|
||||
height: number;
|
||||
constructor(x: number, y: number, width: number, height: number);
|
||||
private _width;
|
||||
width: number;
|
||||
private _height;
|
||||
height: number;
|
||||
readonly aspectRatio: number;
|
||||
bounds: Rectangle;
|
||||
constructor(x: number, y: number, width: number, height: number);
|
||||
}
|
||||
}
|
||||
declare module es {
|
||||
@@ -1035,17 +1035,17 @@ declare module es {
|
||||
}
|
||||
declare module es {
|
||||
class PostProcessor {
|
||||
static default_vert: string;
|
||||
enabled: boolean;
|
||||
effect: egret.Filter;
|
||||
scene: Scene;
|
||||
shape: egret.Shape;
|
||||
static default_vert: string;
|
||||
constructor(effect?: egret.Filter);
|
||||
onAddedToScene(scene: Scene): void;
|
||||
process(): void;
|
||||
onSceneBackBufferSizeChanged(newWidth: number, newHeight: number): void;
|
||||
protected drawFullscreenQuad(): void;
|
||||
unload(): void;
|
||||
protected drawFullscreenQuad(): void;
|
||||
}
|
||||
}
|
||||
declare module es {
|
||||
@@ -1060,11 +1060,11 @@ declare module es {
|
||||
protected constructor(renderOrder: number, camera?: Camera);
|
||||
onAddedToScene(scene: Scene): void;
|
||||
unload(): void;
|
||||
protected beginRender(cam: Camera): void;
|
||||
abstract render(scene: Scene): any;
|
||||
protected renderAfterStateCheck(renderable: IRenderable, cam: Camera): void;
|
||||
onSceneBackBufferSizeChanged(newWidth: number, newHeight: number): void;
|
||||
compareTo(other: Renderer): number;
|
||||
protected beginRender(cam: Camera): void;
|
||||
protected renderAfterStateCheck(renderable: IRenderable, cam: Camera): void;
|
||||
}
|
||||
}
|
||||
declare module es {
|
||||
@@ -1081,33 +1081,33 @@ declare module es {
|
||||
declare module es {
|
||||
class PolyLight extends RenderableComponent {
|
||||
power: number;
|
||||
protected _radius: number;
|
||||
private _lightEffect;
|
||||
private _indices;
|
||||
radius: number;
|
||||
constructor(radius: number, color: number, power: number);
|
||||
private computeTriangleIndices;
|
||||
protected _radius: number;
|
||||
radius: number;
|
||||
setRadius(radius: number): void;
|
||||
render(camera: Camera): void;
|
||||
reset(): void;
|
||||
private computeTriangleIndices;
|
||||
}
|
||||
}
|
||||
declare module es {
|
||||
abstract class SceneTransition {
|
||||
private _hasPreviousSceneRender;
|
||||
loadsNewScene: boolean;
|
||||
isNewSceneLoaded: boolean;
|
||||
protected sceneLoadAction: Function;
|
||||
onScreenObscured: Function;
|
||||
onTransitionCompleted: Function;
|
||||
readonly hasPreviousSceneRender: boolean;
|
||||
protected sceneLoadAction: Function;
|
||||
constructor(sceneLoadAction: Function);
|
||||
private _hasPreviousSceneRender;
|
||||
readonly hasPreviousSceneRender: boolean;
|
||||
preRender(): void;
|
||||
render(): void;
|
||||
onBeginTransition(): Promise<void>;
|
||||
tickEffectProgressProperty(filter: egret.CustomFilter, duration: number, easeType: Function, reverseDirection?: boolean): Promise<boolean>;
|
||||
protected transitionComplete(): void;
|
||||
protected loadNextScene(): Promise<void>;
|
||||
tickEffectProgressProperty(filter: egret.CustomFilter, duration: number, easeType: Function, reverseDirection?: boolean): Promise<boolean>;
|
||||
}
|
||||
}
|
||||
declare module es {
|
||||
@@ -1125,13 +1125,13 @@ declare module es {
|
||||
}
|
||||
declare module es {
|
||||
class WindTransition extends SceneTransition {
|
||||
duration: number;
|
||||
easeType: (t: number) => number;
|
||||
private _mask;
|
||||
private _windEffect;
|
||||
duration: number;
|
||||
constructor(sceneLoadAction: Function);
|
||||
windSegments: number;
|
||||
size: number;
|
||||
easeType: (t: number) => number;
|
||||
constructor(sceneLoadAction: Function);
|
||||
onBeginTransition(): Promise<void>;
|
||||
}
|
||||
}
|
||||
@@ -1202,14 +1202,15 @@ declare module es {
|
||||
readonly center: Vector2;
|
||||
location: Vector2;
|
||||
size: Vector2;
|
||||
static fromMinMax(minX: number, minY: number, maxX: number, maxY: number): Rectangle;
|
||||
static rectEncompassingPoints(points: Vector2[]): Rectangle;
|
||||
intersects(value: egret.Rectangle): boolean;
|
||||
containsRect(value: Rectangle): boolean;
|
||||
contains(x: number, y: number): boolean;
|
||||
getHalfSize(): Vector2;
|
||||
static fromMinMax(minX: number, minY: number, maxX: number, maxY: number): Rectangle;
|
||||
getClosestPointOnRectangleBorderToPoint(point: Vector2, edgeNormal: Vector2): Vector2;
|
||||
getClosestPointOnBoundsToOrigin(): Vector2;
|
||||
calculateBounds(parentPosition: Vector2, position: Vector2, origin: Vector2, scale: Vector2, rotation: number, width: number, height: number): void;
|
||||
static rectEncompassingPoints(points: Vector2[]): Rectangle;
|
||||
}
|
||||
}
|
||||
declare module es {
|
||||
@@ -1259,9 +1260,9 @@ declare module es {
|
||||
}
|
||||
declare module es {
|
||||
class Physics {
|
||||
private static _spatialHash;
|
||||
static spatialHashCellSize: number;
|
||||
static readonly allLayers: number;
|
||||
private static _spatialHash;
|
||||
static reset(): void;
|
||||
static clear(): void;
|
||||
static overlapCircleAll(center: Vector2, randius: number, results: any[], layerMask?: number): number;
|
||||
@@ -1273,6 +1274,20 @@ declare module es {
|
||||
static debugDraw(secondsToDisplay: any): void;
|
||||
}
|
||||
}
|
||||
declare module es {
|
||||
class RaycastHit {
|
||||
collider: Collider;
|
||||
fraction: number;
|
||||
distance: number;
|
||||
point: Vector2;
|
||||
normal: Vector2;
|
||||
centroid: Vector2;
|
||||
constructor(collider: Collider, fraction: number, distance: number, point: Vector2, normal: Vector2);
|
||||
setValues(collider: Collider, fraction: number, distance: number, point: Vector2): void;
|
||||
reset(): void;
|
||||
toString(): string;
|
||||
}
|
||||
}
|
||||
declare module es {
|
||||
abstract class Shape {
|
||||
position: Vector2;
|
||||
@@ -1288,21 +1303,23 @@ declare module es {
|
||||
declare module es {
|
||||
class Polygon extends Shape {
|
||||
points: Vector2[];
|
||||
readonly edgeNormals: Vector2[];
|
||||
_areEdgeNormalsDirty: boolean;
|
||||
_edgeNormals: Vector2[];
|
||||
_originalPoints: Vector2[];
|
||||
_polygonCenter: Vector2;
|
||||
isBox: boolean;
|
||||
isUnrotated: boolean;
|
||||
constructor(points: Vector2[], isBox?: boolean);
|
||||
_edgeNormals: Vector2[];
|
||||
readonly edgeNormals: Vector2[];
|
||||
setPoints(points: Vector2[]): void;
|
||||
recalculateCenterAndEdgeNormals(): void;
|
||||
buildEdgeNormals(): void;
|
||||
static buildSymmetricalPolygon(vertCount: number, radius: number): any[];
|
||||
static recenterPolygonVerts(points: Vector2[]): void;
|
||||
static findPolygonCenter(points: Vector2[]): Vector2;
|
||||
static getFarthestPointInDirection(points: Vector2[], direction: Vector2): Vector2;
|
||||
static getClosestPointOnPolygonToPoint(points: Vector2[], point: Vector2, distanceSquared: number, edgeNormal: Vector2): Vector2;
|
||||
static rotatePolygonVerts(radians: number, originalPoints: Vector2[], rotatedPoints: any): void;
|
||||
recalculateBounds(collider: Collider): void;
|
||||
overlaps(other: Shape): any;
|
||||
collidesWithShape(other: Shape, result: CollisionResult): boolean;
|
||||
@@ -1320,6 +1337,7 @@ declare module es {
|
||||
overlaps(other: Shape): any;
|
||||
collidesWithShape(other: Shape, result: CollisionResult): boolean;
|
||||
containsPoint(point: Vector2): boolean;
|
||||
pointCollidesWithShape(point: es.Vector2, result: es.CollisionResult): boolean;
|
||||
}
|
||||
}
|
||||
declare module es {
|
||||
@@ -1336,10 +1354,12 @@ declare module es {
|
||||
declare module es {
|
||||
class CollisionResult {
|
||||
collider: Collider;
|
||||
minimumTranslationVector: Vector2;
|
||||
normal: Vector2;
|
||||
minimumTranslationVector: Vector2;
|
||||
point: Vector2;
|
||||
invertResult(): void;
|
||||
removeHorizontal(deltaMovement: Vector2): void;
|
||||
invertResult(): this;
|
||||
toString(): string;
|
||||
}
|
||||
}
|
||||
declare module es {
|
||||
@@ -1353,6 +1373,7 @@ declare module es {
|
||||
static circleToPolygon(circle: Circle, polygon: Polygon, result: CollisionResult): boolean;
|
||||
static circleToBox(circle: Circle, box: Box, result: CollisionResult): boolean;
|
||||
static pointToCircle(point: Vector2, circle: Circle, result: CollisionResult): boolean;
|
||||
static pointToBox(point: Vector2, box: Box, result: CollisionResult): boolean;
|
||||
static closestPointOnLine(lineA: Vector2, lineB: Vector2, closestTo: Vector2): Vector2;
|
||||
static pointToPoly(point: Vector2, poly: Polygon, result: CollisionResult): boolean;
|
||||
static circleToCircle(first: Circle, second: Circle, result: CollisionResult): boolean;
|
||||
@@ -1370,24 +1391,24 @@ declare module es {
|
||||
_cellDict: NumberDictionary;
|
||||
_tempHashSet: Collider[];
|
||||
constructor(cellSize?: number);
|
||||
private cellCoords;
|
||||
private cellAtPosition;
|
||||
register(collider: Collider): void;
|
||||
remove(collider: Collider): void;
|
||||
removeWithBruteForce(obj: Collider): void;
|
||||
clear(): void;
|
||||
debugDraw(secondsToDisplay: number, textScale?: number): void;
|
||||
private debugDrawCellDetails;
|
||||
aabbBroadphase(bounds: Rectangle, excludeCollider: Collider, layerMask: number): Collider[];
|
||||
overlapCircle(circleCenter: Vector2, radius: number, results: Collider[], layerMask: any): number;
|
||||
private cellCoords;
|
||||
private cellAtPosition;
|
||||
private debugDrawCellDetails;
|
||||
}
|
||||
class NumberDictionary {
|
||||
_store: Map<string, Collider[]>;
|
||||
private getKey;
|
||||
add(x: number, y: number, list: Collider[]): void;
|
||||
remove(obj: Collider): void;
|
||||
tryGetValue(x: number, y: number): Collider[];
|
||||
clear(): void;
|
||||
private getKey;
|
||||
}
|
||||
class RaycastResultParser {
|
||||
}
|
||||
@@ -1412,8 +1433,8 @@ declare class Base64Utils {
|
||||
private static _keyStr;
|
||||
private static _keyAll;
|
||||
static encode: (input: any) => string;
|
||||
private static _utf8_encode;
|
||||
static decode(input: any, isNotStr?: boolean): string;
|
||||
private static _utf8_encode;
|
||||
private static _utf8_decode;
|
||||
private static getConfKey;
|
||||
}
|
||||
@@ -1450,9 +1471,9 @@ declare module es {
|
||||
}
|
||||
declare module es {
|
||||
class GlobalManager {
|
||||
_enabled: boolean;
|
||||
enabled: boolean;
|
||||
setEnabled(isEnabled: boolean): void;
|
||||
_enabled: boolean;
|
||||
onEnabled(): void;
|
||||
onDisabled(): void;
|
||||
update(): void;
|
||||
@@ -1470,31 +1491,29 @@ declare module es {
|
||||
class Input {
|
||||
private static _init;
|
||||
private static _previousTouchState;
|
||||
private static _gameTouchs;
|
||||
private static _resolutionOffset;
|
||||
private static _resolutionScale;
|
||||
private static _touchIndex;
|
||||
private static _gameTouchs;
|
||||
static readonly gameTouchs: TouchState[];
|
||||
private static _resolutionScale;
|
||||
static readonly resolutionScale: Vector2;
|
||||
private static _totalTouchCount;
|
||||
static readonly totalTouchCount: number;
|
||||
static readonly touchPosition: Vector2;
|
||||
static maxSupportedTouch: number;
|
||||
static readonly resolutionScale: Vector2;
|
||||
static readonly totalTouchCount: number;
|
||||
static readonly gameTouchs: TouchState[];
|
||||
static readonly touchPositionDelta: Vector2;
|
||||
static initialize(): void;
|
||||
static scaledPosition(position: Vector2): Vector2;
|
||||
private static initTouchCache;
|
||||
private static touchBegin;
|
||||
private static touchMove;
|
||||
private static touchEnd;
|
||||
private static setpreviousTouchState;
|
||||
static scaledPosition(position: Vector2): Vector2;
|
||||
}
|
||||
}
|
||||
declare class KeyboardUtils {
|
||||
static TYPE_KEY_DOWN: number;
|
||||
static TYPE_KEY_UP: number;
|
||||
private static keyDownDict;
|
||||
private static keyUpDict;
|
||||
static A: string;
|
||||
static B: string;
|
||||
static C: string;
|
||||
@@ -1566,13 +1585,15 @@ declare class KeyboardUtils {
|
||||
static NUM_LOCK: string;
|
||||
static SCROLL_LOCK: string;
|
||||
static WINDOWS: string;
|
||||
private static keyDownDict;
|
||||
private static keyUpDict;
|
||||
static init(): void;
|
||||
private static onKeyDonwHander;
|
||||
private static onKeyUpHander;
|
||||
static registerKey(key: string, fun: Function, thisObj: any, type?: number, ...args: any[]): void;
|
||||
static unregisterKey(key: string, type?: number): void;
|
||||
private static keyCodeToString;
|
||||
static destroy(): void;
|
||||
private static onKeyDonwHander;
|
||||
private static onKeyUpHander;
|
||||
private static keyCodeToString;
|
||||
}
|
||||
declare module es {
|
||||
class ListPool {
|
||||
@@ -1609,11 +1630,11 @@ declare class RandomUtils {
|
||||
static randint(a: number, b: number): number;
|
||||
static randnum(a: number, b: number): number;
|
||||
static shuffle(array: any[]): any[];
|
||||
private static _randomCompare;
|
||||
static choice(sequence: any): any;
|
||||
static sample(sequence: any[], num: number): any[];
|
||||
static random(): number;
|
||||
static boolean(chance?: number): boolean;
|
||||
private static _randomCompare;
|
||||
}
|
||||
declare module es {
|
||||
class RectangleExt {
|
||||
@@ -1625,9 +1646,9 @@ declare module es {
|
||||
triangleIndices: number[];
|
||||
private _triPrev;
|
||||
private _triNext;
|
||||
static testPointTriangle(point: Vector2, a: Vector2, b: Vector2, c: Vector2): boolean;
|
||||
triangulate(points: Vector2[], arePointsCCW?: boolean): void;
|
||||
private initialize;
|
||||
static testPointTriangle(point: Vector2, a: Vector2, b: Vector2, c: Vector2): boolean;
|
||||
}
|
||||
}
|
||||
declare module es {
|
||||
@@ -1689,12 +1710,12 @@ declare namespace stopwatch {
|
||||
getCompletedAndPendingSlices(): Slice[];
|
||||
getPendingSlice(): Slice;
|
||||
getTime(): number;
|
||||
private calculatePendingSlice;
|
||||
private caculateStopwatchTime;
|
||||
private getSystemTimeOfCurrentStopwatchTime;
|
||||
reset(): void;
|
||||
start(forceReset?: boolean): void;
|
||||
stop(recordPendingSlice?: boolean): number;
|
||||
private calculatePendingSlice;
|
||||
private caculateStopwatchTime;
|
||||
private getSystemTimeOfCurrentStopwatchTime;
|
||||
private recordPendingSlice;
|
||||
}
|
||||
type GetTimeFunc = () => number;
|
||||
@@ -1721,14 +1742,14 @@ declare module es {
|
||||
static readonly barPadding: number;
|
||||
static readonly autoAdjustDelay: number;
|
||||
private static _instance;
|
||||
static readonly Instance: TimeRuler;
|
||||
targetSampleFrames: number;
|
||||
width: number;
|
||||
enabled: true;
|
||||
showLog: boolean;
|
||||
private _frameKey;
|
||||
private _logKey;
|
||||
private _logs;
|
||||
private sampleFrames;
|
||||
targetSampleFrames: number;
|
||||
width: number;
|
||||
enabled: true;
|
||||
private _position;
|
||||
private _prevLog;
|
||||
private _curLog;
|
||||
@@ -1737,16 +1758,16 @@ declare module es {
|
||||
private stopwacth;
|
||||
private _markerNameToIdMap;
|
||||
private _updateCount;
|
||||
showLog: boolean;
|
||||
private _frameAdjust;
|
||||
constructor();
|
||||
private onGraphicsDeviceReset;
|
||||
static readonly Instance: TimeRuler;
|
||||
startFrame(): void;
|
||||
beginMark(markerName: string, color: number, barIndex?: number): void;
|
||||
endMark(markerName: string, barIndex?: number): void;
|
||||
getAverageTime(barIndex: number, markerName: string): number;
|
||||
resetLog(): void;
|
||||
render(position?: Vector2, width?: number): void;
|
||||
private onGraphicsDeviceReset;
|
||||
}
|
||||
class FrameLog {
|
||||
bars: MarkerCollection[];
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
2
demo/libs/framework/framework.min.js
vendored
2
demo/libs/framework/framework.min.js
vendored
File diff suppressed because one or more lines are too long
35
source/bin/framework.d.ts
vendored
35
source/bin/framework.d.ts
vendored
@@ -130,7 +130,7 @@ declare module es {
|
||||
divide(value: Vector2): Vector2;
|
||||
multiply(value: Vector2): Vector2;
|
||||
subtract(value: Vector2): this;
|
||||
normalize(): void;
|
||||
normalize(): this;
|
||||
length(): number;
|
||||
round(): Vector2;
|
||||
equals(other: Vector2): boolean;
|
||||
@@ -1206,6 +1206,7 @@ declare module es {
|
||||
static rectEncompassingPoints(points: Vector2[]): Rectangle;
|
||||
intersects(value: egret.Rectangle): boolean;
|
||||
containsRect(value: Rectangle): boolean;
|
||||
contains(x: number, y: number): boolean;
|
||||
getHalfSize(): Vector2;
|
||||
getClosestPointOnRectangleBorderToPoint(point: Vector2, edgeNormal: Vector2): Vector2;
|
||||
getClosestPointOnBoundsToOrigin(): Vector2;
|
||||
@@ -1273,6 +1274,20 @@ declare module es {
|
||||
static debugDraw(secondsToDisplay: any): void;
|
||||
}
|
||||
}
|
||||
declare module es {
|
||||
class RaycastHit {
|
||||
collider: Collider;
|
||||
fraction: number;
|
||||
distance: number;
|
||||
point: Vector2;
|
||||
normal: Vector2;
|
||||
centroid: Vector2;
|
||||
constructor(collider: Collider, fraction: number, distance: number, point: Vector2, normal: Vector2);
|
||||
setValues(collider: Collider, fraction: number, distance: number, point: Vector2): void;
|
||||
reset(): void;
|
||||
toString(): string;
|
||||
}
|
||||
}
|
||||
declare module es {
|
||||
abstract class Shape {
|
||||
position: Vector2;
|
||||
@@ -1296,13 +1311,15 @@ declare module es {
|
||||
constructor(points: Vector2[], isBox?: boolean);
|
||||
_edgeNormals: Vector2[];
|
||||
readonly edgeNormals: Vector2[];
|
||||
static buildSymmetricalPolygon(vertCount: number, radius: number): any[];
|
||||
static recenterPolygonVerts(points: Vector2[]): void;
|
||||
static findPolygonCenter(points: Vector2[]): Vector2;
|
||||
static getClosestPointOnPolygonToPoint(points: Vector2[], point: Vector2, distanceSquared: number, edgeNormal: Vector2): Vector2;
|
||||
setPoints(points: Vector2[]): void;
|
||||
recalculateCenterAndEdgeNormals(): void;
|
||||
buildEdgeNormals(): void;
|
||||
static buildSymmetricalPolygon(vertCount: number, radius: number): any[];
|
||||
static recenterPolygonVerts(points: Vector2[]): void;
|
||||
static findPolygonCenter(points: Vector2[]): Vector2;
|
||||
static getFarthestPointInDirection(points: Vector2[], direction: Vector2): Vector2;
|
||||
static getClosestPointOnPolygonToPoint(points: Vector2[], point: Vector2, distanceSquared: number, edgeNormal: Vector2): Vector2;
|
||||
static rotatePolygonVerts(radians: number, originalPoints: Vector2[], rotatedPoints: any): void;
|
||||
recalculateBounds(collider: Collider): void;
|
||||
overlaps(other: Shape): any;
|
||||
collidesWithShape(other: Shape, result: CollisionResult): boolean;
|
||||
@@ -1320,6 +1337,7 @@ declare module es {
|
||||
overlaps(other: Shape): any;
|
||||
collidesWithShape(other: Shape, result: CollisionResult): boolean;
|
||||
containsPoint(point: Vector2): boolean;
|
||||
pointCollidesWithShape(point: es.Vector2, result: es.CollisionResult): boolean;
|
||||
}
|
||||
}
|
||||
declare module es {
|
||||
@@ -1336,10 +1354,12 @@ declare module es {
|
||||
declare module es {
|
||||
class CollisionResult {
|
||||
collider: Collider;
|
||||
minimumTranslationVector: Vector2;
|
||||
normal: Vector2;
|
||||
minimumTranslationVector: Vector2;
|
||||
point: Vector2;
|
||||
invertResult(): void;
|
||||
removeHorizontal(deltaMovement: Vector2): void;
|
||||
invertResult(): this;
|
||||
toString(): string;
|
||||
}
|
||||
}
|
||||
declare module es {
|
||||
@@ -1353,6 +1373,7 @@ declare module es {
|
||||
static circleToPolygon(circle: Circle, polygon: Polygon, result: CollisionResult): boolean;
|
||||
static circleToBox(circle: Circle, box: Box, result: CollisionResult): boolean;
|
||||
static pointToCircle(point: Vector2, circle: Circle, result: CollisionResult): boolean;
|
||||
static pointToBox(point: Vector2, box: Box, result: CollisionResult): boolean;
|
||||
static closestPointOnLine(lineA: Vector2, lineB: Vector2, closestTo: Vector2): Vector2;
|
||||
static pointToPoly(point: Vector2, poly: Polygon, result: CollisionResult): boolean;
|
||||
static circleToCircle(first: Circle, second: Circle, result: CollisionResult): boolean;
|
||||
|
||||
@@ -744,6 +744,7 @@ var es;
|
||||
var val = 1 / Math.sqrt((this.x * this.x) + (this.y * this.y));
|
||||
this.x *= val;
|
||||
this.y *= val;
|
||||
return this;
|
||||
};
|
||||
Vector2.prototype.length = function () {
|
||||
return Math.sqrt((this.x * this.x) + (this.y * this.y));
|
||||
@@ -5639,6 +5640,9 @@ var es;
|
||||
(this.y <= value.y)) &&
|
||||
(value.y < (this.y + this.height)));
|
||||
};
|
||||
Rectangle.prototype.contains = function (x, y) {
|
||||
return ((((this.x <= x) && (x < (this.x + this.width))) && (this.y <= y)) && (y < (this.y + this.height)));
|
||||
};
|
||||
Rectangle.prototype.getHalfSize = function () {
|
||||
return new es.Vector2(this.width * 0.5, this.height * 0.5);
|
||||
};
|
||||
@@ -6024,6 +6028,37 @@ var es;
|
||||
es.Physics = Physics;
|
||||
})(es || (es = {}));
|
||||
var es;
|
||||
(function (es) {
|
||||
var RaycastHit = (function () {
|
||||
function RaycastHit(collider, fraction, distance, point, normal) {
|
||||
this.fraction = 0;
|
||||
this.distance = 0;
|
||||
this.point = es.Vector2.zero;
|
||||
this.normal = es.Vector2.zero;
|
||||
this.collider = collider;
|
||||
this.fraction = fraction;
|
||||
this.distance = distance;
|
||||
this.point = point;
|
||||
this.centroid = es.Vector2.zero;
|
||||
}
|
||||
RaycastHit.prototype.setValues = function (collider, fraction, distance, point) {
|
||||
this.collider = collider;
|
||||
this.fraction = fraction;
|
||||
this.distance = distance;
|
||||
this.point = point;
|
||||
};
|
||||
RaycastHit.prototype.reset = function () {
|
||||
this.collider = null;
|
||||
this.fraction = this.distance = 0;
|
||||
};
|
||||
RaycastHit.prototype.toString = function () {
|
||||
return "[RaycastHit] fraction: " + this.fraction + ", distance: " + this.distance + ", normal: " + this.normal + ", centroid: " + this.centroid + ", point: " + this.point;
|
||||
};
|
||||
return RaycastHit;
|
||||
}());
|
||||
es.RaycastHit = RaycastHit;
|
||||
})(es || (es = {}));
|
||||
var es;
|
||||
(function (es) {
|
||||
var Shape = (function () {
|
||||
function Shape() {
|
||||
@@ -6056,48 +6091,6 @@ var es;
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Polygon.buildSymmetricalPolygon = function (vertCount, radius) {
|
||||
var verts = new Array(vertCount);
|
||||
for (var i = 0; i < vertCount; i++) {
|
||||
var a = 2 * Math.PI * (i / vertCount);
|
||||
verts[i] = new es.Vector2(Math.cos(a), Math.sin(a) * radius);
|
||||
}
|
||||
return verts;
|
||||
};
|
||||
Polygon.recenterPolygonVerts = function (points) {
|
||||
var center = this.findPolygonCenter(points);
|
||||
for (var i = 0; i < points.length; i++)
|
||||
points[i] = es.Vector2.subtract(points[i], center);
|
||||
};
|
||||
Polygon.findPolygonCenter = function (points) {
|
||||
var x = 0, y = 0;
|
||||
for (var i = 0; i < points.length; i++) {
|
||||
x += points[i].x;
|
||||
y += points[i].y;
|
||||
}
|
||||
return new es.Vector2(x / points.length, y / points.length);
|
||||
};
|
||||
Polygon.getClosestPointOnPolygonToPoint = function (points, point, distanceSquared, edgeNormal) {
|
||||
distanceSquared = Number.MAX_VALUE;
|
||||
edgeNormal = new es.Vector2(0, 0);
|
||||
var closestPoint = new es.Vector2(0, 0);
|
||||
var tempDistanceSquared;
|
||||
for (var i = 0; i < points.length; i++) {
|
||||
var j = i + 1;
|
||||
if (j == points.length)
|
||||
j = 0;
|
||||
var closest = es.ShapeCollisions.closestPointOnLine(points[i], points[j], point);
|
||||
tempDistanceSquared = es.Vector2.distanceSquared(point, closest);
|
||||
if (tempDistanceSquared < distanceSquared) {
|
||||
distanceSquared = tempDistanceSquared;
|
||||
closestPoint = closest;
|
||||
var line = es.Vector2.subtract(points[j], points[i]);
|
||||
edgeNormal = new es.Vector2(-line.y, line.x);
|
||||
}
|
||||
}
|
||||
edgeNormal = es.Vector2Ext.normalize(edgeNormal);
|
||||
return closestPoint;
|
||||
};
|
||||
Polygon.prototype.setPoints = function (points) {
|
||||
this.points = points;
|
||||
this.recalculateCenterAndEdgeNormals();
|
||||
@@ -6126,6 +6119,68 @@ var es;
|
||||
this._edgeNormals[i] = perp;
|
||||
}
|
||||
};
|
||||
Polygon.buildSymmetricalPolygon = function (vertCount, radius) {
|
||||
var verts = new Array(vertCount);
|
||||
for (var i = 0; i < vertCount; i++) {
|
||||
var a = 2 * Math.PI * (i / vertCount);
|
||||
verts[i] = es.Vector2.multiply(new es.Vector2(Math.cos(a), Math.sin(a)), new es.Vector2(radius));
|
||||
}
|
||||
return verts;
|
||||
};
|
||||
Polygon.recenterPolygonVerts = function (points) {
|
||||
var center = this.findPolygonCenter(points);
|
||||
for (var i = 0; i < points.length; i++)
|
||||
points[i] = es.Vector2.subtract(points[i], center);
|
||||
};
|
||||
Polygon.findPolygonCenter = function (points) {
|
||||
var x = 0, y = 0;
|
||||
for (var i = 0; i < points.length; i++) {
|
||||
x += points[i].x;
|
||||
y += points[i].y;
|
||||
}
|
||||
return new es.Vector2(x / points.length, y / points.length);
|
||||
};
|
||||
Polygon.getFarthestPointInDirection = function (points, direction) {
|
||||
var index = 0;
|
||||
var maxDot = es.Vector2.dot(points[index], direction);
|
||||
for (var i = 1; i < points.length; i++) {
|
||||
var dot = es.Vector2.dot(points[i], direction);
|
||||
if (dot > maxDot) {
|
||||
maxDot = dot;
|
||||
index = i;
|
||||
}
|
||||
}
|
||||
return points[index];
|
||||
};
|
||||
Polygon.getClosestPointOnPolygonToPoint = function (points, point, distanceSquared, edgeNormal) {
|
||||
distanceSquared = Number.MAX_VALUE;
|
||||
edgeNormal = new es.Vector2(0, 0);
|
||||
var closestPoint = new es.Vector2(0, 0);
|
||||
var tempDistanceSquared;
|
||||
for (var i = 0; i < points.length; i++) {
|
||||
var j = i + 1;
|
||||
if (j == points.length)
|
||||
j = 0;
|
||||
var closest = es.ShapeCollisions.closestPointOnLine(points[i], points[j], point);
|
||||
tempDistanceSquared = es.Vector2.distanceSquared(point, closest);
|
||||
if (tempDistanceSquared < distanceSquared) {
|
||||
distanceSquared = tempDistanceSquared;
|
||||
closestPoint = closest;
|
||||
var line = es.Vector2.subtract(points[j], points[i]);
|
||||
edgeNormal = new es.Vector2(-line.y, line.x);
|
||||
}
|
||||
}
|
||||
es.Vector2Ext.normalize(edgeNormal);
|
||||
return closestPoint;
|
||||
};
|
||||
Polygon.rotatePolygonVerts = function (radians, originalPoints, rotatedPoints) {
|
||||
var cos = Math.cos(radians);
|
||||
var sin = Math.sign(radians);
|
||||
for (var i = 0; i < originalPoints.length; i++) {
|
||||
var position = originalPoints[i];
|
||||
rotatedPoints[i] = new es.Vector2(position.x * cos + position.y * -sin, position.x * sin + position.y * cos);
|
||||
}
|
||||
};
|
||||
Polygon.prototype.recalculateBounds = function (collider) {
|
||||
this.center = collider.localOffset;
|
||||
if (collider.shouldColliderScaleAndRotateWithTransform) {
|
||||
@@ -6236,7 +6291,7 @@ var es;
|
||||
};
|
||||
Box.prototype.overlaps = function (other) {
|
||||
if (this.isUnrotated) {
|
||||
if (other instanceof Box)
|
||||
if (other instanceof Box && other.isUnrotated)
|
||||
return this.bounds.intersects(other.bounds);
|
||||
if (other instanceof es.Circle)
|
||||
return es.Collisions.isRectToCircle(this.bounds, other.position, other.radius);
|
||||
@@ -6254,6 +6309,11 @@ var es;
|
||||
return this.bounds.contains(point.x, point.y);
|
||||
return _super.prototype.containsPoint.call(this, point);
|
||||
};
|
||||
Box.prototype.pointCollidesWithShape = function (point, result) {
|
||||
if (this.isUnrotated)
|
||||
return es.ShapeCollisions.pointToBox(point, this, result);
|
||||
return _super.prototype.pointCollidesWithShape.call(this, point, result);
|
||||
};
|
||||
return Box;
|
||||
}(es.Polygon));
|
||||
es.Box = Box;
|
||||
@@ -6317,13 +6377,26 @@ var es;
|
||||
(function (es) {
|
||||
var CollisionResult = (function () {
|
||||
function CollisionResult() {
|
||||
this.minimumTranslationVector = es.Vector2.zero;
|
||||
this.normal = es.Vector2.zero;
|
||||
this.minimumTranslationVector = es.Vector2.zero;
|
||||
this.point = es.Vector2.zero;
|
||||
}
|
||||
CollisionResult.prototype.removeHorizontal = function (deltaMovement) {
|
||||
if (Math.sign(this.normal.x) != Math.sign(deltaMovement.x) || (deltaMovement.x == 0 && this.normal.x != 0)) {
|
||||
var responseDistance = this.minimumTranslationVector.length();
|
||||
var fix = responseDistance / this.normal.y;
|
||||
if (Math.abs(this.normal.x) != 1 && Math.abs(fix) < Math.abs(deltaMovement.y * 3)) {
|
||||
this.minimumTranslationVector = new es.Vector2(0, -fix);
|
||||
}
|
||||
}
|
||||
};
|
||||
CollisionResult.prototype.invertResult = function () {
|
||||
this.minimumTranslationVector = es.Vector2.negate(this.minimumTranslationVector);
|
||||
this.normal = es.Vector2.negate(this.normal);
|
||||
return this;
|
||||
};
|
||||
CollisionResult.prototype.toString = function () {
|
||||
return "[CollisionResult] normal: " + this.normal + ", minimumTranslationVector: " + this.minimumTranslationVector;
|
||||
};
|
||||
return CollisionResult;
|
||||
}());
|
||||
@@ -6458,6 +6531,14 @@ var es;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
ShapeCollisions.pointToBox = function (point, box, result) {
|
||||
if (box.containsPoint(point)) {
|
||||
result.point = box.bounds.getClosestPointOnRectangleBorderToPoint(point, result.normal);
|
||||
result.minimumTranslationVector = es.Vector2.subtract(point, result.point);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
ShapeCollisions.closestPointOnLine = function (lineA, lineB, closestTo) {
|
||||
var v = es.Vector2.subtract(lineB, lineA);
|
||||
var w = es.Vector2.subtract(closestTo, lineA);
|
||||
@@ -6495,7 +6576,7 @@ var es;
|
||||
if (result.minimumTranslationVector.equals(es.Vector2.zero))
|
||||
return false;
|
||||
result.normal = new es.Vector2(-result.minimumTranslationVector.x, -result.minimumTranslationVector.y);
|
||||
result.normal.normalize();
|
||||
result.normal = result.normal.normalize();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
2
source/bin/framework.min.js
vendored
2
source/bin/framework.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -71,7 +71,7 @@ module es {
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否与另一个矩形相交
|
||||
* 如果其他相交矩形返回true
|
||||
* @param value
|
||||
*/
|
||||
public intersects(value: egret.Rectangle) {
|
||||
@@ -91,6 +91,10 @@ module es {
|
||||
(value.y < (this.y + this.height)));
|
||||
}
|
||||
|
||||
public contains(x: number, y: number): boolean{
|
||||
return ((((this.x <= x) && (x < (this.x + this.width))) && (this.y <= y)) && (y < (this.y + this.height)));
|
||||
}
|
||||
|
||||
public getHalfSize() {
|
||||
return new Vector2(this.width * 0.5, this.height * 0.5);
|
||||
}
|
||||
|
||||
@@ -211,6 +211,7 @@ module es {
|
||||
let val = 1 / Math.sqrt((this.x * this.x) + (this.y * this.y));
|
||||
this.x *= val;
|
||||
this.y *= val;
|
||||
return this;
|
||||
}
|
||||
|
||||
/** 返回它的长度 */
|
||||
|
||||
57
source/src/Physics/RaycastHit.ts
Normal file
57
source/src/Physics/RaycastHit.ts
Normal file
@@ -0,0 +1,57 @@
|
||||
module es {
|
||||
export class RaycastHit {
|
||||
/**
|
||||
* 对撞机被射线击中
|
||||
*/
|
||||
public collider: Collider;
|
||||
|
||||
/**
|
||||
* 撞击发生时沿射线的距离。
|
||||
*/
|
||||
public fraction: number = 0;
|
||||
|
||||
/**
|
||||
* 从射线原点到碰撞点的距离
|
||||
*/
|
||||
public distance: number = 0;
|
||||
|
||||
/**
|
||||
* 世界空间中光线击中对撞机表面的点
|
||||
*/
|
||||
public point: Vector2 = Vector2.zero;
|
||||
|
||||
/**
|
||||
* 被射线击中的表面的法向量
|
||||
*/
|
||||
public normal: Vector2 = Vector2.zero;
|
||||
|
||||
/**
|
||||
* 用于执行转换的质心。使其接触的形状的位置。
|
||||
*/
|
||||
public centroid: Vector2;
|
||||
|
||||
constructor(collider: Collider, fraction: number, distance: number, point: Vector2, normal: Vector2){
|
||||
this.collider = collider;
|
||||
this.fraction = fraction;
|
||||
this.distance = distance;
|
||||
this.point = point;
|
||||
this.centroid = Vector2.zero;
|
||||
}
|
||||
|
||||
public setValues(collider: Collider, fraction: number, distance: number, point: Vector2){
|
||||
this.collider = collider;
|
||||
this.fraction = fraction;
|
||||
this.distance = distance;
|
||||
this.point = point;
|
||||
}
|
||||
|
||||
public reset(){
|
||||
this.collider = null;
|
||||
this.fraction = this.distance = 0;
|
||||
}
|
||||
|
||||
public toString(){
|
||||
return `[RaycastHit] fraction: ${this.fraction}, distance: ${this.distance}, normal: ${this.normal}, centroid: ${this.centroid}, point: ${this.point}`;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -56,7 +56,7 @@ module es {
|
||||
public overlaps(other: Shape) {
|
||||
// 特殊情况,这一个高性能方式实现,其他情况则使用polygon方法检测
|
||||
if (this.isUnrotated) {
|
||||
if (other instanceof Box)
|
||||
if (other instanceof Box && other.isUnrotated)
|
||||
return this.bounds.intersects(other.bounds);
|
||||
|
||||
if (other instanceof Circle)
|
||||
@@ -83,5 +83,12 @@ module es {
|
||||
|
||||
return super.containsPoint(point);
|
||||
}
|
||||
|
||||
public pointCollidesWithShape(point: es.Vector2, result: es.CollisionResult): boolean {
|
||||
if (this.isUnrotated)
|
||||
return ShapeCollisions.pointToBox(point, this, result);
|
||||
|
||||
return super.pointCollidesWithShape(point, result);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,47 @@
|
||||
module es {
|
||||
export class CollisionResult {
|
||||
/**
|
||||
* 与之相撞的对撞机
|
||||
*/
|
||||
public collider: Collider;
|
||||
public minimumTranslationVector: Vector2 = Vector2.zero;
|
||||
/**
|
||||
* 被形状击中的表面的法向量
|
||||
*/
|
||||
public normal: Vector2 = Vector2.zero;
|
||||
/**
|
||||
* 应用于第一个形状以推入形状的转换
|
||||
*/
|
||||
public minimumTranslationVector: Vector2 = Vector2.zero;
|
||||
/**
|
||||
* 不是所有冲突类型都使用!在依赖这个字段之前,请检查ShapeCollisions切割类!
|
||||
*/
|
||||
public point: Vector2 = Vector2.zero;
|
||||
|
||||
/**
|
||||
* 改变最小平移向量,如果没有相同方向上的运动,它将移除平移的x分量。
|
||||
* @param deltaMovement
|
||||
*/
|
||||
public removeHorizontal(deltaMovement: Vector2){
|
||||
// 检查是否需要横向移动,如果需要,移除并固定响应
|
||||
if (Math.sign(this.normal.x) != Math.sign(deltaMovement.x) || (deltaMovement.x == 0 && this.normal.x != 0)){
|
||||
let responseDistance = this.minimumTranslationVector.length();
|
||||
let fix = responseDistance / this.normal.y;
|
||||
|
||||
// 检查一些边界情况。因为我们除以法线 使得x == 1和一个非常小的y这将导致一个巨大的固定值
|
||||
if (Math.abs(this.normal.x) != 1 && Math.abs(fix) < Math.abs(deltaMovement.y * 3)){
|
||||
this.minimumTranslationVector = new Vector2(0, -fix);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public invertResult() {
|
||||
this.minimumTranslationVector = Vector2.negate(this.minimumTranslationVector);
|
||||
this.normal = Vector2.negate(this.normal);
|
||||
return this;
|
||||
}
|
||||
|
||||
public toString(){
|
||||
return `[CollisionResult] normal: ${this.normal}, minimumTranslationVector: ${this.minimumTranslationVector}`;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,85 +46,6 @@ module es {
|
||||
return this._edgeNormals;
|
||||
}
|
||||
|
||||
/**
|
||||
* 建立一个对称的多边形(六边形,八角形,n角形)并返回点
|
||||
* @param vertCount
|
||||
* @param radius
|
||||
*/
|
||||
public static buildSymmetricalPolygon(vertCount: number, radius: number) {
|
||||
let verts = new Array(vertCount);
|
||||
|
||||
for (let i = 0; i < vertCount; i++) {
|
||||
let a = 2 * Math.PI * (i / vertCount);
|
||||
verts[i] = new Vector2(Math.cos(a), Math.sin(a) * radius);
|
||||
}
|
||||
|
||||
return verts;
|
||||
}
|
||||
|
||||
/**
|
||||
* 重定位多边形的点
|
||||
* @param points
|
||||
*/
|
||||
public static recenterPolygonVerts(points: Vector2[]) {
|
||||
let center = this.findPolygonCenter(points);
|
||||
for (let i = 0; i < points.length; i++)
|
||||
points[i] = Vector2.subtract(points[i], center);
|
||||
}
|
||||
|
||||
/**
|
||||
* 找到多边形的中心。注意,这对于正则多边形是准确的。不规则多边形没有中心。
|
||||
* @param points
|
||||
*/
|
||||
public static findPolygonCenter(points: Vector2[]) {
|
||||
let x = 0, y = 0;
|
||||
|
||||
for (let i = 0; i < points.length; i++) {
|
||||
x += points[i].x;
|
||||
y += points[i].y;
|
||||
}
|
||||
|
||||
return new Vector2(x / points.length, y / points.length);
|
||||
}
|
||||
|
||||
/**
|
||||
* 迭代多边形的所有边,并得到任意边上离点最近的点。
|
||||
* 通过最近点的平方距离和它所在的边的法线返回。
|
||||
* 点应该在多边形的空间中(点-多边形.位置)
|
||||
* @param points
|
||||
* @param point
|
||||
* @param distanceSquared
|
||||
* @param edgeNormal
|
||||
*/
|
||||
public static getClosestPointOnPolygonToPoint(points: Vector2[], point: Vector2, distanceSquared: number, edgeNormal: Vector2): Vector2 {
|
||||
distanceSquared = Number.MAX_VALUE;
|
||||
edgeNormal = new Vector2(0, 0);
|
||||
let closestPoint = new Vector2(0, 0);
|
||||
|
||||
let tempDistanceSquared;
|
||||
for (let i = 0; i < points.length; i++) {
|
||||
let j = i + 1;
|
||||
if (j == points.length)
|
||||
j = 0;
|
||||
|
||||
let closest = ShapeCollisions.closestPointOnLine(points[i], points[j], point);
|
||||
tempDistanceSquared = Vector2.distanceSquared(point, closest);
|
||||
|
||||
if (tempDistanceSquared < distanceSquared) {
|
||||
distanceSquared = tempDistanceSquared;
|
||||
closestPoint = closest;
|
||||
|
||||
// 求直线的法线
|
||||
let line = Vector2.subtract(points[j], points[i]);
|
||||
edgeNormal = new Vector2(-line.y, line.x);
|
||||
}
|
||||
}
|
||||
|
||||
edgeNormal = Vector2Ext.normalize(edgeNormal);
|
||||
|
||||
return closestPoint;
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置点并重新计算中心和边缘法线
|
||||
* @param points
|
||||
@@ -172,6 +93,121 @@ module es {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 建立一个对称的多边形(六边形,八角形,n角形)并返回点
|
||||
* @param vertCount
|
||||
* @param radius
|
||||
*/
|
||||
public static buildSymmetricalPolygon(vertCount: number, radius: number) {
|
||||
let verts = new Array(vertCount);
|
||||
|
||||
for (let i = 0; i < vertCount; i++) {
|
||||
let a = 2 * Math.PI * (i / vertCount);
|
||||
verts[i] = Vector2.multiply(new Vector2(Math.cos(a), Math.sin(a)), new Vector2(radius));
|
||||
}
|
||||
|
||||
return verts;
|
||||
}
|
||||
|
||||
/**
|
||||
* 重定位多边形的点
|
||||
* @param points
|
||||
*/
|
||||
public static recenterPolygonVerts(points: Vector2[]) {
|
||||
let center = this.findPolygonCenter(points);
|
||||
for (let i = 0; i < points.length; i++)
|
||||
points[i] = Vector2.subtract(points[i], center);
|
||||
}
|
||||
|
||||
/**
|
||||
* 找到多边形的中心。注意,这对于正则多边形是准确的。不规则多边形没有中心。
|
||||
* @param points
|
||||
*/
|
||||
public static findPolygonCenter(points: Vector2[]) {
|
||||
let x = 0, y = 0;
|
||||
|
||||
for (let i = 0; i < points.length; i++) {
|
||||
x += points[i].x;
|
||||
y += points[i].y;
|
||||
}
|
||||
|
||||
return new Vector2(x / points.length, y / points.length);
|
||||
}
|
||||
|
||||
/**
|
||||
* 不知道辅助顶点,所以取每个顶点,如果你知道辅助顶点,执行climbing算法
|
||||
* @param points
|
||||
* @param direction
|
||||
*/
|
||||
public static getFarthestPointInDirection(points: Vector2[], direction: Vector2): Vector2{
|
||||
let index = 0;
|
||||
let maxDot = Vector2.dot(points[index], direction);
|
||||
|
||||
for (let i = 1; i < points.length; i ++){
|
||||
let dot = Vector2.dot(points[i], direction);
|
||||
if (dot > maxDot){
|
||||
maxDot = dot;
|
||||
index = i;
|
||||
}
|
||||
}
|
||||
|
||||
return points[index];
|
||||
}
|
||||
|
||||
/**
|
||||
* 迭代多边形的所有边,并得到任意边上离点最近的点。
|
||||
* 通过最近点的平方距离和它所在的边的法线返回。
|
||||
* 点应该在多边形的空间中(点-多边形.位置)
|
||||
* @param points
|
||||
* @param point
|
||||
* @param distanceSquared
|
||||
* @param edgeNormal
|
||||
*/
|
||||
public static getClosestPointOnPolygonToPoint(points: Vector2[], point: Vector2, distanceSquared: number, edgeNormal: Vector2): Vector2 {
|
||||
distanceSquared = Number.MAX_VALUE;
|
||||
edgeNormal = new Vector2(0, 0);
|
||||
let closestPoint = new Vector2(0, 0);
|
||||
|
||||
let tempDistanceSquared;
|
||||
for (let i = 0; i < points.length; i++) {
|
||||
let j = i + 1;
|
||||
if (j == points.length)
|
||||
j = 0;
|
||||
|
||||
let closest = ShapeCollisions.closestPointOnLine(points[i], points[j], point);
|
||||
tempDistanceSquared = Vector2.distanceSquared(point, closest);
|
||||
|
||||
if (tempDistanceSquared < distanceSquared) {
|
||||
distanceSquared = tempDistanceSquared;
|
||||
closestPoint = closest;
|
||||
|
||||
// 求直线的法线
|
||||
let line = Vector2.subtract(points[j], points[i]);
|
||||
edgeNormal = new Vector2(-line.y, line.x);
|
||||
}
|
||||
}
|
||||
|
||||
Vector2Ext.normalize(edgeNormal);
|
||||
|
||||
return closestPoint;
|
||||
}
|
||||
|
||||
/**
|
||||
* 旋转原始点并复制旋转的值到旋转的点
|
||||
* @param radians
|
||||
* @param originalPoints
|
||||
* @param rotatedPoints
|
||||
*/
|
||||
public static rotatePolygonVerts(radians: number, originalPoints: Vector2[], rotatedPoints){
|
||||
let cos = Math.cos(radians);
|
||||
let sin = Math.sign(radians);
|
||||
|
||||
for (let i = 0; i < originalPoints.length; i ++){
|
||||
let position = originalPoints[i];
|
||||
rotatedPoints[i] = new Vector2(position.x * cos + position.y * -sin, position.x * sin + position.y * cos);
|
||||
}
|
||||
}
|
||||
|
||||
public recalculateBounds(collider: Collider) {
|
||||
// 如果我们没有旋转或不关心TRS我们使用localOffset作为中心,我们会从那开始
|
||||
this.center = collider.localOffset;
|
||||
|
||||
@@ -205,6 +205,18 @@ module es {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static pointToBox(point: Vector2, box: Box, result: CollisionResult){
|
||||
if (box.containsPoint(point)){
|
||||
// 在方框的空间里找到点
|
||||
result.point = box.bounds.getClosestPointOnRectangleBorderToPoint(point, result.normal);
|
||||
result.minimumTranslationVector = Vector2.subtract(point, result.point);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param lineA
|
||||
@@ -277,7 +289,7 @@ module es {
|
||||
return false;
|
||||
|
||||
result.normal = new Vector2(-result.minimumTranslationVector.x, -result.minimumTranslationVector.y);
|
||||
result.normal.normalize();
|
||||
result.normal = result.normal.normalize();
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -285,7 +297,7 @@ module es {
|
||||
return false;
|
||||
}
|
||||
|
||||
private static minkowskiDifference(first: Box, second: Box) {
|
||||
private static minkowskiDifference(first: Box, second: Box): Rectangle {
|
||||
// 我们需要第一个框的左上角
|
||||
// 碰撞器只会修改运动的位置所以我们需要用位置来计算出运动是什么。
|
||||
let positionOffset = Vector2.subtract(first.position, Vector2.add(first.bounds.location, Vector2.divide(first.bounds.size, new Vector2(2))));
|
||||
|
||||
Reference in New Issue
Block a user