diff --git a/source/bin/framework.d.ts b/source/bin/framework.d.ts index 5b23c9a5..ceb06f26 100644 --- a/source/bin/framework.d.ts +++ b/source/bin/framework.d.ts @@ -285,61 +285,6 @@ declare module es { describe(planner: ActionPlanner): string; } } -declare module es { - class Core extends egret.DisplayObjectContainer { - static emitter: Emitter; - static debugRenderEndabled: boolean; - static graphicsDevice: GraphicsDevice; - static content: ContentManager; - static _instance: Core; - _nextScene: Scene; - _sceneTransition: SceneTransition; - _globalManagers: GlobalManager[]; - _coroutineManager: CoroutineManager; - _timerManager: TimerManager; - constructor(); - static readonly Instance: Core; - _frameCounterElapsedTime: number; - _frameCounter: number; - _scene: Scene; - static scene: Scene; - static startSceneTransition(sceneTransition: T): T; - static registerGlobalManager(manager: es.GlobalManager): void; - static unregisterGlobalManager(manager: es.GlobalManager): void; - static getGlobalManager(type: any): T; - static startCoroutine(enumerator: Iterator): CoroutineImpl; - static schedule(timeInSeconds: number, repeats: boolean, context: any, onTime: (timer: ITimer) => void): Timer; - onOrientationChanged(): void; - draw(): Promise; - startDebugUpdate(): void; - endDebugUpdate(): void; - startDebugDraw(elapsedGameTime: number): void; - endDebugDraw(): void; - onSceneChanged(): void; - protected onGraphicsDeviceReset(): void; - protected initialize(): void; - protected update(): Promise; - private onAddToStage; - } -} -declare module es { - class Colors { - static renderableBounds: number; - static renderableCenter: number; - static colliderBounds: number; - static colliderEdge: number; - static colliderPosition: number; - static colliderCenter: number; - } - class Size { - static readonly lineSizeMultiplier: number; - } - class Debug { - private static _debugDrawItems; - static drawHollowRect(rectanle: Rectangle, color: number, duration?: number): void; - static render(): void; - } -} declare module es { class DebugDefaults { static verletParticle: number; @@ -347,32 +292,9 @@ declare module es { } } declare module es { - enum DebugDrawType { - line = 0, - hollowRectangle = 1, - pixel = 2, - text = 3 - } - class DebugDrawItem { - rectangle: Rectangle; - color: number; - duration: number; - drawType: DebugDrawType; - text: string; - start: Vector2; - end: Vector2; - x: number; - y: number; - size: number; - constructor(rectangle: Rectangle, color: number, duration: number); - draw(shape: egret.Shape): boolean; - } -} -declare module es { - abstract class Component extends egret.HashObject { + abstract class Component { entity: Entity; updateInterval: number; - debugDisplayObject: egret.DisplayObjectContainer; readonly transform: Transform; private _enabled; enabled: boolean; @@ -385,11 +307,40 @@ declare module es { debugRender(camera: Camera): void; onEnabled(): void; onDisabled(): void; - update(): void; setEnabled(isEnabled: boolean): this; setUpdateOrder(updateOrder: number): this; } } +declare module es { + class Core { + static emitter: Emitter; + static debugRenderEndabled: boolean; + static _instance: Core; + _nextScene: Scene; + _sceneTransition: SceneTransition; + _globalManagers: GlobalManager[]; + _timerManager: TimerManager; + width: number; + height: number; + constructor(width: number, height: number); + static readonly Instance: Core; + _frameCounterElapsedTime: number; + _frameCounter: number; + _scene: Scene; + static scene: Scene; + static startSceneTransition(sceneTransition: T): T; + static registerGlobalManager(manager: es.GlobalManager): void; + static unregisterGlobalManager(manager: es.GlobalManager): void; + static getGlobalManager(type: any): T; + static schedule(timeInSeconds: number, repeats: boolean, context: any, onTime: (timer: ITimer) => void): Timer; + onOrientationChanged(): void; + draw(): Promise; + onSceneChanged(): void; + protected onGraphicsDeviceReset(): void; + protected initialize(): void; + protected update(): Promise; + } +} declare module es { enum CoreEvents { GraphicsDeviceReset = 0, @@ -444,7 +395,7 @@ declare module es { getComponent(type: any): T; hasComponent(type: any): boolean; getOrCreateComponent(type: T): T; - getComponents(typeName: string | any, componentList?: any): any; + getComponents(typeName: any, componentList?: any): any; removeComponent(component: Component): void; removeComponentForType(type: any): boolean; removeAllComponents(): void; @@ -453,19 +404,14 @@ declare module es { } } declare module es { - class Scene extends egret.DisplayObjectContainer { + class Scene { camera: Camera; - readonly content: ContentManager; - enablePostProcessing: boolean; readonly entities: EntityList; readonly renderableComponents: RenderableComponentList; readonly entityProcessors: EntityProcessorList; - _screenshotRequestCallback: Function; readonly _sceneComponents: SceneComponent[]; _renderers: Renderer[]; - readonly _postProcessors: PostProcessor[]; _didSceneBegin: any; - dynamicBatch: boolean; constructor(); static createWithDefaultRenderer(): Scene; initialize(): void; @@ -478,9 +424,7 @@ declare module es { updateResolutionScaler(): void; update(): void; render(): void; - dynamicInBatch(): void; postRender(): void; - requestScreenshot(callback: Function): void; addSceneComponent(component: T): T; getSceneComponent(type: any): T; getOrCreateSceneComponent(type: any): T; @@ -488,9 +432,6 @@ declare module es { addRenderer(renderer: T): T; getRenderer(type: any): T; removeRenderer(renderer: Renderer): void; - addPostProcessor(postProcessor: T): T; - getPostProcessor(type: any): T; - removePostProcessor(postProcessor: PostProcessor): void; createEntity(name: string): Entity; addEntity(entity: Entity): Entity; destroyAllEntities(): void; @@ -512,14 +453,13 @@ declare module transform { } } declare module es { - import HashObject = egret.HashObject; enum DirtyType { clean = 0, positionDirty = 1, scaleDirty = 2, rotationDirty = 3 } - class Transform extends HashObject { + class Transform { readonly entity: Entity; hierarchyDirty: DirtyType; _localDirty: boolean; @@ -574,64 +514,6 @@ declare module es { setDirty(dirtyFlagType: DirtyType): void; copyFrom(transform: Transform): void; toString(): string; - equals(other: Transform): boolean; - } -} -declare module es { - interface CameraInset { - left: number; - right: number; - top: number; - bottom: number; - } - class Camera extends Component { - _inset: CameraInset; - _areMatrixedDirty: boolean; - _areBoundsDirty: boolean; - _isProjectionMatrixDirty: boolean; - constructor(); - position: Vector2; - rotation: number; - rawZoom: number; - _zoom: number; - 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; - setInset(left: number, right: number, top: number, bottom: number): Camera; - setPosition(position: Vector2): this; - setRotation(rotation: number): Camera; - setZoom(zoom: number): Camera; - setMinimumZoom(minZoom: number): Camera; - setMaximumZoom(maxZoom: number): Camera; - forceMatrixUpdate(): void; - onEntityTransformChanged(comp: transform.Component): void; - zoomIn(deltaZoom: number): void; - zoomOut(deltaZoom: number): void; - worldToScreenPoint(worldPosition: Vector2): Vector2; - screenToWorldPoint(screenPosition: Vector2): Vector2; - onSceneRenderTargetSizeChanged(newWidth: number, newHeight: number): void; - mouseToWorldPoint(): Vector2; - protected updateMatrixes(): void; - } -} -declare module es { - class CameraShake extends Component { - _shakeDirection: Vector2; - _shakeOffset: Vector2; - _shakeIntensity: number; - _shakeDegredation: number; - shake(shakeIntensify?: number, shakeDegredation?: number, shakeDirection?: Vector2): void; - update(): void; } } declare module es { @@ -643,35 +525,6 @@ declare module es { free(component: T): void; } } -declare module es { - enum CameraStyle { - lockOn = 0, - cameraWindow = 1 - } - class FollowCamera extends Component { - camera: Camera; - followLerp: number; - deadzone: Rectangle; - focusOffset: Vector2; - mapLockEnabled: boolean; - mapSize: Rectangle; - _targetEntity: Entity; - _targetCollider: Collider; - _desiredPositionDelta: Vector2; - _cameraStyle: CameraStyle; - _worldSpaceDeadZone: Rectangle; - private rectShape; - constructor(targetEntity?: Entity, camera?: Camera, cameraStyle?: CameraStyle); - onAddedToEntity(): void; - onGraphicsDeviceReset(): void; - update(): void; - debugRender(camera: Camera): void; - clampToMapSize(position: Vector2): Vector2; - follow(targetEntity: Entity, cameraStyle?: CameraStyle): void; - updateFollow(): void; - setCenteredDeadzone(width: number, height: number): void; - } -} declare module es { interface IUpdatable { enabled: boolean; @@ -679,8 +532,9 @@ declare module es { update(): any; } class IUpdatableComparer implements IComparer { - compare(a: Component, b: Component): number; + compare(a: IUpdatable, b: IUpdatable): number; } + var isIUpdatable: (props: any) => props is IUpdatable; } declare module es { abstract class PooledComponent extends Component { @@ -737,7 +591,6 @@ declare module es { _localOffsetLength: number; _isPositionDirty: boolean; _isRotationDirty: boolean; - protected _colliderRequiresAutoSizing: any; protected _isParentEntityAddedToScene: any; protected _isColliderRegistered: any; readonly absolutePosition: Vector2; @@ -760,11 +613,7 @@ declare module es { } declare module es { class BoxCollider extends Collider { - hollowShape: egret.Shape; - polygonShape: egret.Shape; - pixelShape1: egret.Shape; - pixelShape2: egret.Shape; - constructor(x?: number, y?: number, width?: number, height?: number); + constructor(x: number, y: number, width: number, height: number); width: number; height: number; setSize(width: number, height: number): this; @@ -776,11 +625,7 @@ declare module es { } declare module es { class CircleCollider extends Collider { - private rectShape; - private circleShape; - private pixelShape1; - private pixelShape2; - constructor(radius?: number); + constructor(radius: number); radius: number; setRadius(radius: number): CircleCollider; debugRender(camera: Camera): void; @@ -792,179 +637,6 @@ declare module es { constructor(points: Vector2[]); } } -declare module es { - abstract class RenderableComponent extends Component implements IRenderable { - displayObject: egret.DisplayObject; - hollowShape: egret.Shape; - pixelShape: egret.Shape; - color: number; - protected _areBoundsDirty: boolean; - readonly width: number; - readonly height: number; - debugRenderEnabled: boolean; - protected _localOffset: Vector2; - localOffset: Vector2; - protected _renderLayer: number; - renderLayer: number; - protected _bounds: Rectangle; - readonly bounds: Rectangle; - private _isVisible; - isVisible: boolean; - onEntityTransformChanged(comp: transform.Component): void; - abstract render(camera: Camera): any; - debugRender(camera: Camera): void; - isVisibleFromCamera(camera: Camera): boolean; - setRenderLayer(renderLayer: number): RenderableComponent; - setColor(color: number): RenderableComponent; - setLocalOffset(offset: Vector2): RenderableComponent; - sync(camera: Camera): void; - compareTo(other: RenderableComponent): number; - toString(): string; - protected onBecameVisible(): void; - protected onBecameInvisible(): void; - } -} -declare module es { - class Mesh extends RenderableComponent { - displayObject: egret.Mesh; - readonly bounds: Rectangle; - _primitiveCount: number; - _topLeftVertPosition: Vector2; - _width: number; - _height: number; - _triangles: number[]; - _verts: VertexPositionColorTexture[]; - recalculateBounds(recalculateUVs: boolean): this; - setTexture(texture: egret.Texture): Mesh; - setVertPositions(positions: Vector2[]): this; - setTriangles(triangles: number[]): this; - render(camera: es.Camera): void; - } - class VertexPositionColorTexture { - position: Vector2; - textureCoordinate: Vector2; - } -} -declare module es { - class SpriteRenderer extends RenderableComponent { - 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; - render(camera: Camera): void; - } -} -declare module es { - class TiledSpriteRenderer extends SpriteRenderer { - readonly bounds: Rectangle; - scrollX: number; - scrollY: number; - textureScale: Vector2; - width: number; - height: number; - gapXY: Vector2; - protected _sourceRect: Rectangle; - protected _textureScale: Vector2; - protected _inverseTexScale: Vector2; - private _gapX; - private _gapY; - constructor(sprite: Sprite); - setGapXY(value: Vector2): TiledSpriteRenderer; - render(camera: es.Camera): void; - } -} -declare module es { - class ScrollingSpriteRenderer extends TiledSpriteRenderer { - scrollSpeedX: number; - scroolSpeedY: number; - textureScale: Vector2; - scrollWidth: number; - scrollHeight: number; - private _scrollX; - private _scrollY; - private _scrollWidth; - private _scrollHeight; - constructor(sprite: Sprite); - update(): void; - } -} -declare module es { - class Sprite { - texture2D: egret.Texture; - readonly sourceRect: Rectangle; - readonly center: Vector2; - origin: Vector2; - readonly uvs: Rectangle; - constructor(texture: egret.Texture, sourceRect?: Rectangle, origin?: Vector2); - static spritesFromAtlas(texture: egret.Texture, cellWidth: number, cellHeight: number, cellOffset?: number, maxCellsToInclude?: number): Sprite[]; - } -} -declare module es { - class SpriteAnimation { - readonly sprites: Sprite[]; - readonly frameRate: number; - constructor(sprites: Sprite[], frameRate?: number); - } -} -declare module es { - enum LoopMode { - loop = 0, - once = 1, - clampForever = 2, - pingPong = 3, - pingPongOnce = 4 - } - enum State { - none = 0, - running = 1, - paused = 2, - completed = 3 - } - class SpriteAnimator extends SpriteRenderer { - onAnimationCompletedEvent: (string: any) => {}; - speed: number; - animationState: State; - currentAnimation: SpriteAnimation; - currentAnimationName: string; - currentFrame: number; - _elapsedTime: number; - _loopMode: LoopMode; - constructor(sprite?: Sprite); - readonly isRunning: boolean; - private _animations; - readonly animations: Map; - update(): void; - addAnimation(name: string, animation: SpriteAnimation): SpriteAnimator; - play(name: string, loopMode?: LoopMode): void; - isAnimationActive(name: string): boolean; - pause(): void; - unPause(): void; - stop(): void; - } -} -declare module es { - import Bitmap = egret.Bitmap; - class StaticSpriteContainerRenderer extends RenderableComponent { - displayObject: egret.DisplayObjectContainer; - private displayObjectCache; - constructor(sprite?: Sprite[] | egret.Texture[]); - readonly bounds: Rectangle; - originNormalized: Vector2; - protected _origin: Vector2; - origin: Vector2; - pushSprite(sprite: Sprite): StaticSpriteContainerRenderer; - getSprite(sprite: Sprite): Bitmap; - setOrigin(origin: Vector2): StaticSpriteContainerRenderer; - setOriginNormalized(value: Vector2): StaticSpriteContainerRenderer; - render(camera: Camera): void; - } -} declare module es { class EntitySystem { private _entities; @@ -1031,6 +703,7 @@ declare module es { static compareUpdatableOrder: IUpdatableComparer; _entity: Entity; _components: FastList; + _updatableComponents: FastList; _componentsToAdd: Component[]; _componentsToRemove: Component[]; _tempBufferList: Component[]; @@ -1047,7 +720,7 @@ declare module es { updateLists(): void; handleRemove(component: Component): void; getComponent(type: any, onlyReturnInitializedComponents: boolean): T; - getComponents(typeName: string | any, components?: any): any; + getComponents(typeName: any, components?: any): any; update(): void; onEntityTransformChanged(comp: transform.Component): void; onEntityEnabled(): void; @@ -1197,10 +870,6 @@ declare module es { one(...types: any[]): this; } } -declare class ObjectUtils { - static clone(p: any, c?: T): T; - static elements(p: {}): any[]; -} declare module es { interface IRenderable { bounds: Rectangle; @@ -1249,17 +918,6 @@ declare class StringUtils { static cutOff(str: string, start: number, len: number, order?: boolean): string; static strReplace(str: string, rStr: string[]): string; } -declare module es { - class TextureUtils { - static sharedCanvas: HTMLCanvasElement; - static sharedContext: CanvasRenderingContext2D; - static convertImageToCanvas(texture: egret.Texture, rect?: egret.Rectangle): HTMLCanvasElement; - static toDataURL(type: string, texture: egret.Texture, rect?: egret.Rectangle, encoderOptions?: any): string; - static eliFoTevas(type: string, texture: egret.Texture, filePath: string, rect?: egret.Rectangle, encoderOptions?: any): void; - static getPixel32(texture: egret.Texture, x: number, y: number): number[]; - static getPixels(texture: egret.Texture, x: number, y: number, width?: number, height?: number): number[]; - } -} declare module es { class Time { static unscaledDeltaTime: any; @@ -1287,28 +945,6 @@ declare class TimeUtils { static secondToTime(time?: number, partition?: string, showHour?: boolean): string; static timeToMillisecond(time: string, partition?: string): string; } -declare module es { - class Graphics { - static Instance: Graphics; - pixelTexture: Sprite; - constructor(); - } -} -declare module es { - class GraphicsCapabilities extends egret.Capabilities { - initialize(device: GraphicsDevice): void; - private platformInitialize; - } -} -declare module es { - class GraphicsDevice { - graphicsCapabilities: GraphicsCapabilities; - constructor(); - private _viewport; - readonly viewport: Viewport; - private setup; - } -} declare module es { class Viewport { private _x; @@ -1324,46 +960,11 @@ declare module es { bounds: Rectangle; } } -declare module es { - class GaussianBlurEffect extends egret.CustomFilter { - private static blur_frag; - constructor(); - } -} -declare module es { - class PolygonLightEffect extends egret.CustomFilter { - private static vertSrc; - private static fragmentSrc; - constructor(); - } -} -declare module es { - class PostProcessor { - static default_vert: string; - enabled: boolean; - effect: egret.Filter; - scene: Scene; - shape: egret.Shape; - constructor(effect?: egret.Filter); - onAddedToScene(scene: Scene): void; - process(): void; - onSceneBackBufferSizeChanged(newWidth: number, newHeight: number): void; - unload(): void; - protected drawFullscreenQuad(): void; - } -} -declare module es { - class GaussianBlurPostProcessor extends PostProcessor { - onAddedToScene(scene: Scene): void; - } -} declare module es { abstract class Renderer { camera: Camera; readonly renderOrder: number; - renderTexture: egret.RenderTexture; shouldDebugRender: boolean; - readonly wantsToRenderToSceneRenderTarget: boolean; protected constructor(renderOrder: number, camera?: Camera); onAddedToScene(scene: Scene): void; unload(): void; @@ -1381,76 +982,6 @@ declare module es { render(scene: Scene): void; } } -declare module es { - class RenderLayerExcludeRenderer extends Renderer { - excludedRenderLayers: number[]; - constructor(renderOrder: number, ...excludedRenderLayers: number[]); - render(scene: es.Scene): void; - protected debugRender(scene: es.Scene, cam: es.Camera): void; - } -} -declare module es { - class ScreenSpaceRenderer extends Renderer { - renderLayers: number[]; - constructor(renderOrder: number, ...renderLayers: number[]); - render(scene: Scene): void; - protected debugRender(scene: es.Scene, cam: es.Camera): void; - onSceneBackBufferSizeChanged(newWidth: number, newHeight: number): void; - } -} -declare module es { - class PolyLight extends RenderableComponent { - power: number; - private _lightEffect; - private _indices; - constructor(radius: number, color: number, power: number); - protected _radius: number; - radius: number; - setRadius(radius: number): void; - render(camera: Camera): void; - reset(): void; - private computeTriangleIndices; - } -} -declare module es { - class GaussianBlur { - static createBlurredTexture(image: egret.Texture, deviation?: number): void; - static createBlurredTextureData(srcData: Color[], width: number, height: number, deviation?: number): Color[]; - static gaussianConvolution(matrix: FasterDictionary<{ - x: number; - y: number; - }, number>, deviation: number): FasterDictionary<{ - x: number; - y: number; - }, number>; - static processPoint(matrix: FasterDictionary<{ - x: number; - y: number; - }, number>, x: number, y: number, kernel: FasterDictionary<{ - x: number; - y: number; - }, number>, direction: number): number; - static calculate1DSampleKernel(deviation: number): FasterDictionary<{ - x: number; - y: number; - }, number>; - static calculate1DSampleKernelOfSize(deviation: number, size: number): FasterDictionary<{ - x: number; - y: number; - }, number>; - static calculateNormalized1DSampleKernel(deviation: number): FasterDictionary<{ - x: number; - y: number; - }, number>; - static normalizeMatrix(matrix: FasterDictionary<{ - x: number; - y: number; - }, number>): FasterDictionary<{ - x: number; - y: number; - }, number>; - } -} declare module es { abstract class SceneTransition { loadsNewScene: boolean; @@ -1464,38 +995,10 @@ declare module es { preRender(): void; render(): void; onBeginTransition(): Promise; - tickEffectProgressProperty(filter: egret.CustomFilter, duration: number, easeType: Function, reverseDirection?: boolean): Promise; protected transitionComplete(): void; protected loadNextScene(): Promise; } } -declare module es { - class FadeTransition extends SceneTransition { - fadeToColor: number; - fadeOutDuration: number; - fadeEaseType: Function; - delayBeforeFadeInDuration: number; - private _mask; - private _alpha; - constructor(sceneLoadAction: Function); - onBeginTransition(): Promise; - protected transitionComplete(): void; - render(): void; - } -} -declare module es { - class WindTransition extends SceneTransition { - duration: number; - easeType: (t: number) => number; - private _mask; - private _windEffect; - constructor(sceneLoadAction: Function); - windSegments: number; - size: number; - onBeginTransition(): Promise; - protected transitionComplete(): void; - } -} declare module es { class Bezier { static getPoint(p0: Vector2, p1: Vector2, p2: Vector2, t: number): Vector2; @@ -1536,46 +1039,87 @@ declare module es { } } declare module es { - var matrixPool: any[]; - class Matrix2D extends egret.Matrix { + class Matrix2D implements IEquatable { m11: number; m12: number; m21: number; m22: number; m31: number; m32: number; - static create(): Matrix2D; - identity(): Matrix2D; - translate(dx: number, dy: number): Matrix2D; - scale(sx: number, sy: number): Matrix2D; - rotate(angle: number): Matrix2D; - invert(): Matrix2D; + static readonly identity: Matrix2D; + translation: Vector2; + rotation: number; + rotationDegrees: number; + scale: Vector2; + static _identity: Matrix2D; + constructor(m11: number, m12: number, m21: number, m22: number, m31: number, m32: number); + static createRotation(radians: number): Matrix2D; + static createScale(xScale: number, yScale: number): Matrix2D; + static createTranslation(xPosition: number, yPosition: number): Matrix2D; + static invert(matrix: Matrix2D): Matrix2D; add(matrix: Matrix2D): Matrix2D; substract(matrix: Matrix2D): Matrix2D; divide(matrix: Matrix2D): Matrix2D; multiply(matrix: Matrix2D): Matrix2D; determinant(): number; - release(matrix: Matrix2D): void; + static lerp(matrix1: Matrix2D, matrix2: Matrix2D, amount: number): Matrix2D; + static transpose(matrix: Matrix2D): Matrix2D; + mutiplyTranslation(x: number, y: number): Matrix2D; + equals(other: Matrix2D): boolean; + toString(): string; } } declare module es { - class Rectangle extends egret.Rectangle { - _tempMat: Matrix2D; - _transformMat: Matrix2D; + class MatrixHelper { + static add(matrix1: Matrix2D, matrix2: Matrix2D): Matrix2D; + static divide(matrix1: Matrix2D, matrix2: Matrix2D): Matrix2D; + static mutiply(matrix1: Matrix2D, matrix2: Matrix2D | number): Matrix2D; + static subtract(matrix1: Matrix2D, matrix2: Matrix2D): Matrix2D; + } +} +declare module es { + class Rectangle implements IEquatable { + static emptyRectangle: Rectangle; + x: number; + y: number; + width: number; + height: number; + static readonly empty: Rectangle; + static readonly maxRect: Rectangle; + readonly left: number; + readonly right: number; + readonly top: number; + readonly bottom: number; readonly max: Vector2; - readonly center: Vector2; + isEmpty(): boolean; location: Vector2; size: Vector2; + readonly center: Vector2; + _tempMat: Matrix2D; + _transformMat: Matrix2D; + constructor(x?: number, y?: number, width?: number, height?: number); static fromMinMax(minX: number, minY: number, maxX: number, maxY: number): Rectangle; static rectEncompassingPoints(points: Vector2[]): Rectangle; - intersects(value: egret.Rectangle): boolean; + getSide(edge: Edge): number; + contains(x: number, y: number): boolean; + inflate(horizontalAmount: number, verticalAmount: number): void; + intersects(value: Rectangle): boolean; rayIntersects(ray: Ray2D, distance: Ref): boolean; containsRect(value: Rectangle): boolean; - contains(x: number, y: number): boolean; getHalfSize(): Vector2; - getClosestPointOnRectangleBorderToPoint(point: Vector2, edgeNormal: Vector2): Vector2; getClosestPointOnBoundsToOrigin(): Vector2; + getClosestPointOnRectangleToPoint(point: Vector2): Vector2; + getClosestPointOnRectangleBorderToPoint(point: Vector2, edgeNormal: Vector2): Vector2; + static intersect(value1: Rectangle, value2: Rectangle): Rectangle; + offset(offsetX: number, offsetY: number): void; + static union(value1: Rectangle, value2: Rectangle): Rectangle; + static overlap(value1: Rectangle, value2: Rectangle): Rectangle; calculateBounds(parentPosition: Vector2, position: Vector2, origin: Vector2, scale: Vector2, rotation: number, width: number, height: number): void; + getSweptBroadphaseBounds(deltaX: number, deltaY: number): Rectangle; + collisionCheck(other: Rectangle, moveX: Ref, moveY: Ref): boolean; + static getIntersectionDepth(rectA: Rectangle, rectB: Rectangle): Vector2; + equals(other: Rectangle): boolean; + getHashCode(): number; } } declare module es { @@ -1632,7 +1176,7 @@ declare module es { static circleToCircle(circleCenter1: Vector2, circleRadius1: number, circleCenter2: Vector2, circleRadius2: number): boolean; static circleToLine(circleCenter: Vector2, radius: number, lineFrom: Vector2, lineTo: Vector2): boolean; static circleToPoint(circleCenter: Vector2, radius: number, point: Vector2): boolean; - static rectToCircle(rect: egret.Rectangle, cPosition: Vector2, cRadius: number): boolean; + static rectToCircle(rect: Rectangle, cPosition: Vector2, cRadius: number): boolean; static rectToLine(rect: Rectangle, lineFrom: Vector2, lineTo: Vector2): boolean; static rectToPoint(rX: number, rY: number, rW: number, rH: number, point: Vector2): boolean; static getSector(rX: number, rY: number, rW: number, rH: number, point: Vector2): PointSectors; @@ -1927,18 +1471,6 @@ declare module es { equals(other: Color): boolean; } } -declare module es { - class ContentManager { - protected loadedAssets: Map; - loadRes(name: string, local?: boolean): Promise; - dispose(): void; - } -} -declare module es { - class DrawUtils { - static getColorMatrix(color: number): egret.ColorMatrixFilter; - } -} declare module es { class EdgeExt { static oppositeEdge(self: Edge): Edge; @@ -2041,6 +1573,7 @@ declare module es { interface IPoolable { reset(): any; } + var isIPoolable: (props: any) => props is IPoolable; } declare class RandomUtils { static randrange(start: number, stop: number, step?: number): number; @@ -2102,32 +1635,6 @@ declare module es { declare class WebGLUtils { static getContext(): CanvasRenderingContext2D; } -declare module es { - class Layout { - clientArea: Rectangle; - safeArea: Rectangle; - constructor(); - place(size: Vector2, horizontalMargin: number, verticalMargine: number, alignment: Alignment): Rectangle; - } - enum Alignment { - none = 0, - left = 1, - right = 2, - horizontalCenter = 4, - top = 8, - bottom = 16, - verticalCenter = 32, - topLeft = 9, - topRight = 10, - topCenter = 12, - bottomLeft = 17, - bottomRight = 18, - bottomCenter = 20, - centerLeft = 33, - centerRight = 34, - center = 36 - } -} declare namespace stopwatch { class Stopwatch { private readonly getSystemTime; @@ -2167,444 +1674,6 @@ declare namespace stopwatch { readonly duration: number; } } -declare module es { - class TimeRuler { - static readonly maxBars: number; - static readonly maxSamples: number; - static readonly maxNestCall: number; - static readonly barHeight: number; - static readonly maxSampleFrames: number; - static readonly logSnapDuration: number; - static readonly barPadding: number; - static readonly autoAdjustDelay: number; - private static _instance; - targetSampleFrames: number; - width: number; - enabled: true; - showLog: boolean; - logs: FrameLog[]; - private sampleFrames; - private _position; - private prevLog; - private curLog; - private frameCount; - private markers; - private stopwacth; - private _markerNameToIdMap; - private _updateCount; - private _frameAdjust; - private _rectShape1; - private _rectShape2; - private _rectShape3; - private _rectShape4; - private _rectShape5; - private _rectShape6; - constructor(); - 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[]; - constructor(); - } - class MarkerCollection { - markers: Marker[]; - markCount: number; - markerNests: number[]; - nestCount: number; - constructor(); - } - class Marker { - markerId: number; - beginTime: number; - endTime: number; - color: number; - } - class MarkerInfo { - name: string; - logs: MarkerLog[]; - constructor(name: any); - } - class MarkerLog { - snapMin: number; - snapMax: number; - snapAvg: number; - min: number; - max: number; - avg: number; - samples: number; - color: number; - initialized: boolean; - } -} -declare module es { - interface ICoroutine { - stop(): any; - setUseUnscaledDeltaTime(useUnscaledDeltaTime: any): ICoroutine; - } - class Coroutine { - static waitForSeconds(seconds: number): WaitForSeconds; - } - class WaitForSeconds { - static waiter: WaitForSeconds; - waitTime: number; - wait(seconds: number): WaitForSeconds; - } -} -declare module es { - class CoroutineImpl implements ICoroutine, IPoolable { - enumerator: Iterator; - waitTimer: number; - isDone: boolean; - waitForCoroutine: CoroutineImpl; - useUnscaledDeltaTime: boolean; - stop(): void; - setUseUnscaledDeltaTime(useUnscaledDeltaTime: any): es.ICoroutine; - prepareForuse(): void; - reset(): void; - } - class CoroutineManager extends GlobalManager { - _isInUpdate: boolean; - _unblockedCoroutines: CoroutineImpl[]; - _shouldRunNextFrame: CoroutineImpl[]; - startCoroutine(enumerator: Iterator): CoroutineImpl; - update(): void; - tickCoroutine(coroutine: CoroutineImpl): boolean; - } -} -declare module es { - class TouchState { - x: number; - y: number; - touchPoint: number; - touchDown: boolean; - readonly position: Vector2; - reset(): void; - } - class Input { - private static _init; - private static _previousTouchState; - private static _resolutionOffset; - 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 _virtualInputs: VirtualInput[]; - static maxSupportedTouch: number; - static readonly touchPositionDelta: Vector2; - static initialize(): void; - static update(): void; - static scaledPosition(position: Vector2): Vector2; - static isKeyPressed(key: Keys): boolean; - static isKeyPressedBoth(keyA: Keys, keyB: Keys): boolean; - static isKeyDown(key: Keys): boolean; - static isKeyDownBoth(keyA: Keys, keyB: Keys): boolean; - static isKeyReleased(key: Keys): boolean; - static isKeyReleasedBoth(keyA: Keys, keyB: Keys): boolean; - private static initTouchCache; - private static touchBegin; - private static touchMove; - private static touchEnd; - private static setpreviousTouchState; - } -} -import Keys = es.Keys; -declare class KeyboardUtils { - static currentKeys: Keys[]; - static previousKeys: Keys[]; - private static keyStatusKeys; - static init(): void; - static update(): void; - static destroy(): void; - private static onKeyDownHandler; - private static onKeyUpHandler; -} -declare module es { - enum Keys { - none = 0, - back = 8, - tab = 9, - enter = 13, - capsLock = 20, - escape = 27, - space = 32, - pageUp = 33, - pageDown = 34, - end = 35, - home = 36, - left = 37, - up = 38, - right = 39, - down = 40, - select = 41, - print = 42, - execute = 43, - printScreen = 44, - insert = 45, - delete = 46, - help = 47, - d0 = 48, - d1 = 49, - d2 = 50, - d3 = 51, - d4 = 52, - d5 = 53, - d6 = 54, - d7 = 55, - d8 = 56, - d9 = 57, - a = 65, - b = 66, - c = 67, - d = 68, - e = 69, - f = 70, - g = 71, - h = 72, - i = 73, - j = 74, - k = 75, - l = 76, - m = 77, - n = 78, - o = 79, - p = 80, - q = 81, - r = 82, - s = 83, - t = 84, - u = 85, - v = 86, - w = 87, - x = 88, - y = 89, - z = 90, - leftWindows = 91, - rightWindows = 92, - apps = 93, - sleep = 95, - numPad0 = 96, - numPad1 = 97, - numPad2 = 98, - numPad3 = 99, - numPad4 = 100, - numPad5 = 101, - numPad6 = 102, - numPad7 = 103, - numPad8 = 104, - numPad9 = 105, - multiply = 106, - add = 107, - seperator = 108, - subtract = 109, - decimal = 110, - divide = 111, - f1 = 112, - f2 = 113, - f3 = 114, - f4 = 115, - f5 = 116, - f6 = 117, - f7 = 118, - f8 = 119, - f9 = 120, - f10 = 121, - f11 = 122, - f12 = 123, - f13 = 124, - f14 = 125, - f15 = 126, - f16 = 127, - f17 = 128, - f18 = 129, - f19 = 130, - f20 = 131, - f21 = 132, - f22 = 133, - f23 = 134, - f24 = 135, - numLock = 144, - scroll = 145, - leftShift = 160, - rightShift = 161, - leftControl = 162, - rightControl = 163, - leftAlt = 164, - rightAlt = 165, - browserBack = 166, - browserForward = 167 - } -} -declare module es { - enum OverlapBehavior { - cancelOut = 0, - takeOlder = 1, - takeNewer = 2 - } - abstract class VirtualInput { - protected constructor(); - deregister(): void; - abstract update(): any; - } - abstract class VirtualInputNode { - update(): void; - } -} -declare module es { - class VirtualIntegerAxis extends VirtualInput { - nodes: VirtualAxisNode[]; - readonly value: number; - constructor(...nodes: VirtualAxisNode[]); - update(): void; - addKeyboardKeys(overlapBehavior: OverlapBehavior, negative: Keys, positive: Keys): this; - } - abstract class VirtualAxisNode extends VirtualInputNode { - abstract value: number; - } -} -declare module es { - class VirtualAxis extends VirtualInput { - nodes: VirtualAxisNode[]; - readonly value: number; - constructor(...nodes: VirtualAxisNode[]); - update(): void; - } - class KeyboardKeys extends VirtualAxisNode { - overlapBehavior: OverlapBehavior; - positive: Keys; - negative: Keys; - _value: number; - _turned: boolean; - constructor(overlapBehavior: OverlapBehavior, negative: Keys, positive: Keys); - update(): void; - readonly value: number; - } -} -declare module es { - class VirtualButton extends VirtualInput { - nodes: Node[]; - bufferTime: number; - firstRepeatTime: number; - mutiRepeatTime: number; - isRepeating: boolean; - _bufferCounter: number; - _repeatCounter: number; - _willRepeat: boolean; - constructor(bufferTime?: number, ...nodes: Node[]); - setRepeat(firstRepeatTime: number, mutiRepeatTime?: number): void; - update(): void; - readonly isDown: boolean; - readonly isPressed: boolean; - readonly isReleased: boolean; - consumeBuffer(): void; - addKeyboardKey(key: Keys): VirtualButton; - } - abstract class Node extends VirtualInputNode { - abstract isDown: boolean; - abstract isPressed: boolean; - abstract isReleased: boolean; - } - class KeyboardKey extends Node { - key: Keys; - constructor(key: Keys); - readonly isDown: boolean; - readonly isPressed: boolean; - readonly isReleased: boolean; - } -} -declare module es { - class AssetPacker { - protected itemsToRaster: TextureToPack[]; - onProcessCompleted: Function; - useCache: boolean; - cacheName: string; - protected _sprites: Map; - protected allow4096Textures: boolean; - addTextureToPack(texture: egret.Texture, customID: string): void; - process(allow4096Textures?: boolean): Promise; - protected loadPack(): Promise; - protected createPack(): void; - dispose(): void; - getTexture(id: string): egret.Texture; - } -} -declare module es { - class IntegerRectangle extends Rectangle { - id: number; - } -} -declare module es { - class RectanglePacker { - private _width; - private _height; - private _padding; - private _packedWidth; - private _packedHeight; - private _insertList; - private _insertedRectangles; - private _freeAreas; - private _newFreeAreas; - private _outsideRectangle; - private _sortableSizeStack; - private _rectangleStack; - readonly rectangleCount: number; - readonly packedWidth: number; - readonly packedHeight: number; - readonly padding: number; - constructor(width: number, height: number, padding?: number); - reset(width: number, height: number, padding?: number): void; - insertRectangle(width: number, height: number, id: number): void; - packRectangles(sort?: boolean): number; - getRectangle(index: number, rectangle: IntegerRectangle): IntegerRectangle; - getRectangleId(index: number): number; - private generateNewFreeAreas; - private filterSelfSubAreas; - private generateDividedAreas; - private getFreeAreaIndex; - private allocateSize; - private freeSize; - private allocateRectangle; - private freeRectangle; - } -} -declare module es { - class SortableSize { - width: number; - height: number; - id: number; - constructor(width: number, height: number, id: number); - } -} -declare module es { - class TextureAssets { - assets: TextureAsset[]; - constructor(assets: TextureAsset[]); - } - class TextureAsset { - x: number; - y: number; - width: number; - height: number; - name: string; - } -} -declare module es { - class TextureToPack { - texture: egret.Texture; - id: string; - constructor(texture: egret.Texture, id: string); - } -} declare module es { interface ITimer { context: any; diff --git a/source/bin/framework.js b/source/bin/framework.js index ef66adfa..7a7fd69c 100644 --- a/source/bin/framework.js +++ b/source/bin/framework.js @@ -111,10 +111,6 @@ Array.prototype.findAll = function (predicate) { Array.prototype.contains = function (value) { function contains(array, value) { for (var i = 0, len = array.length; i < len; i++) { - if (array[i] instanceof egret.HashObject && value instanceof egret.HashObject) { - if (array[i].hashCode == value.hashCode) - return true; - } if (array[i] == value) { return true; } @@ -1361,259 +1357,6 @@ var es; es.WorldState = WorldState; })(es || (es = {})); var es; -(function (es) { - var Core = (function (_super) { - __extends(Core, _super); - function Core() { - var _this = _super.call(this) || this; - _this._globalManagers = []; - _this._coroutineManager = new es.CoroutineManager(); - _this._timerManager = new es.TimerManager(); - _this._frameCounterElapsedTime = 0; - _this._frameCounter = 0; - Core._instance = _this; - Core.emitter = new es.Emitter(); - Core.content = new es.ContentManager(); - _this.addEventListener(egret.Event.ADDED_TO_STAGE, _this.onAddToStage, _this); - Core.registerGlobalManager(_this._coroutineManager); - Core.registerGlobalManager(_this._timerManager); - return _this; - } - Object.defineProperty(Core, "Instance", { - get: function () { - return this._instance; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Core, "scene", { - get: function () { - if (!this._instance) - return null; - return this._instance._scene; - }, - set: function (value) { - if (!value) { - console.error("场景不能为空"); - return; - } - if (this._instance._scene == null) { - this._instance.addChild(value); - this._instance._scene = value; - this._instance._scene.begin(); - Core.Instance.onSceneChanged(); - } - else { - this._instance._nextScene = value; - } - }, - enumerable: true, - configurable: true - }); - Core.startSceneTransition = function (sceneTransition) { - if (this._instance._sceneTransition) { - console.warn("在前一个场景完成之前,不能开始一个新的场景转换。"); - return; - } - this._instance._sceneTransition = sceneTransition; - return sceneTransition; - }; - Core.registerGlobalManager = function (manager) { - this._instance._globalManagers.push(manager); - manager.enabled = true; - }; - Core.unregisterGlobalManager = function (manager) { - this._instance._globalManagers.remove(manager); - manager.enabled = false; - }; - Core.getGlobalManager = function (type) { - for (var i = 0; i < this._instance._globalManagers.length; i++) { - if (this._instance._globalManagers[i] instanceof type) - return this._instance._globalManagers[i]; - } - return null; - }; - Core.startCoroutine = function (enumerator) { - return this._instance._coroutineManager.startCoroutine(enumerator); - }; - Core.schedule = function (timeInSeconds, repeats, context, onTime) { - if (repeats === void 0) { repeats = false; } - if (context === void 0) { context = null; } - return this._instance._timerManager.schedule(timeInSeconds, repeats, context, onTime); - }; - Core.prototype.onOrientationChanged = function () { - Core.emitter.emit(es.CoreEvents.OrientationChanged); - }; - Core.prototype.draw = function () { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - if (!this._sceneTransition) return [3, 4]; - this._sceneTransition.preRender(); - if (!(this._scene && !this._sceneTransition.hasPreviousSceneRender)) return [3, 2]; - this._scene.render(); - this._scene.postRender(); - return [4, this._sceneTransition.onBeginTransition()]; - case 1: - _a.sent(); - return [3, 3]; - case 2: - if (this._sceneTransition) { - if (this._scene && this._sceneTransition.isNewSceneLoaded) { - this._scene.render(); - this._scene.postRender(); - } - this._sceneTransition.render(); - } - _a.label = 3; - case 3: return [3, 5]; - case 4: - if (this._scene) { - this._scene.render(); - es.Debug.render(); - this._scene.postRender(); - } - _a.label = 5; - case 5: return [2]; - } - }); - }); - }; - Core.prototype.startDebugUpdate = function () { - es.TimeRuler.Instance.startFrame(); - es.TimeRuler.Instance.beginMark("update", 0x00FF00); - }; - Core.prototype.endDebugUpdate = function () { - es.TimeRuler.Instance.endMark("update"); - }; - Core.prototype.startDebugDraw = function (elapsedGameTime) { - es.TimeRuler.Instance.beginMark("draw", 0xFFD700); - this._frameCounter++; - this._frameCounterElapsedTime += elapsedGameTime; - if (this._frameCounterElapsedTime >= 1) { - this._frameCounter = 0; - this._frameCounterElapsedTime -= 1; - } - }; - Core.prototype.endDebugDraw = function () { - es.TimeRuler.Instance.endMark("draw"); - es.TimeRuler.Instance.render(); - }; - Core.prototype.onSceneChanged = function () { - Core.emitter.emit(es.CoreEvents.SceneChanged); - es.Time.sceneChanged(); - }; - Core.prototype.onGraphicsDeviceReset = function () { - Core.emitter.emit(es.CoreEvents.GraphicsDeviceReset); - }; - Core.prototype.initialize = function () { - es.Graphics.Instance = new es.Graphics(); - }; - Core.prototype.update = function () { - return __awaiter(this, void 0, void 0, function () { - var i; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - es.Time.update(egret.getTimer()); - es.Input.update(); - if (!this._scene) return [3, 2]; - for (i = this._globalManagers.length - 1; i >= 0; i--) { - if (this._globalManagers[i].enabled) - this._globalManagers[i].update(); - } - if (!this._sceneTransition || - (this._sceneTransition && (!this._sceneTransition.loadsNewScene || this._sceneTransition.isNewSceneLoaded))) { - this._scene.update(); - } - if (!this._nextScene) return [3, 2]; - if (this._scene.parent) - this._scene.parent.removeChild(this._scene); - this._scene.end(); - this._scene = this._nextScene; - this._nextScene = null; - this.onSceneChanged(); - return [4, this._scene.begin()]; - case 1: - _a.sent(); - this.addChild(this._scene); - _a.label = 2; - case 2: return [4, this.draw()]; - case 3: - _a.sent(); - return [2]; - } - }); - }); - }; - Core.prototype.onAddToStage = function () { - Core.graphicsDevice = new es.GraphicsDevice(); - this.addEventListener(egret.Event.RESIZE, this.onGraphicsDeviceReset, this); - this.addEventListener(egret.StageOrientationEvent.ORIENTATION_CHANGE, this.onOrientationChanged, this); - this.addEventListener(egret.Event.ENTER_FRAME, this.update, this); - es.Input.initialize(); - KeyboardUtils.init(); - this.initialize(); - }; - Core.debugRenderEndabled = false; - return Core; - }(egret.DisplayObjectContainer)); - es.Core = Core; -})(es || (es = {})); -var es; -(function (es) { - var Colors = (function () { - function Colors() { - } - Colors.renderableBounds = 0xffff00; - Colors.renderableCenter = 0x9932CC; - Colors.colliderBounds = 0x555555; - Colors.colliderEdge = 0x8B0000; - Colors.colliderPosition = 0xFFFF00; - Colors.colliderCenter = 0xFF0000; - return Colors; - }()); - es.Colors = Colors; - var Size = (function () { - function Size() { - } - Object.defineProperty(Size, "lineSizeMultiplier", { - get: function () { - return Math.max(Math.ceil(es.Core.scene.x / es.Core.scene.width), 1); - }, - enumerable: true, - configurable: true - }); - return Size; - }()); - es.Size = Size; - var Debug = (function () { - function Debug() { - } - Debug.drawHollowRect = function (rectanle, color, duration) { - if (duration === void 0) { duration = 0; } - this._debugDrawItems.push(new es.DebugDrawItem(rectanle, color, duration)); - }; - Debug.render = function () { - if (this._debugDrawItems.length > 0) { - var debugShape = new egret.Shape(); - if (es.Core.scene) { - es.Core.scene.addChild(debugShape); - } - for (var i = this._debugDrawItems.length - 1; i >= 0; i--) { - var item = this._debugDrawItems[i]; - if (item.draw(debugShape)) - this._debugDrawItems.removeAt(i); - } - } - }; - Debug._debugDrawItems = []; - return Debug; - }()); - es.Debug = Debug; -})(es || (es = {})); -var es; (function (es) { var DebugDefaults = (function () { function DebugDefaults() { @@ -1626,49 +1369,11 @@ var es; })(es || (es = {})); var es; (function (es) { - var DebugDrawType; - (function (DebugDrawType) { - DebugDrawType[DebugDrawType["line"] = 0] = "line"; - DebugDrawType[DebugDrawType["hollowRectangle"] = 1] = "hollowRectangle"; - DebugDrawType[DebugDrawType["pixel"] = 2] = "pixel"; - DebugDrawType[DebugDrawType["text"] = 3] = "text"; - })(DebugDrawType = es.DebugDrawType || (es.DebugDrawType = {})); - var DebugDrawItem = (function () { - function DebugDrawItem(rectangle, color, duration) { - this.rectangle = rectangle; - this.color = color; - this.duration = duration; - this.drawType = DebugDrawType.hollowRectangle; - } - DebugDrawItem.prototype.draw = function (shape) { - switch (this.drawType) { - case DebugDrawType.line: - break; - case DebugDrawType.hollowRectangle: - break; - case DebugDrawType.pixel: - break; - case DebugDrawType.text: - break; - } - this.duration -= es.Time.deltaTime; - return this.duration < 0; - }; - return DebugDrawItem; - }()); - es.DebugDrawItem = DebugDrawItem; -})(es || (es = {})); -var es; -(function (es) { - var Component = (function (_super) { - __extends(Component, _super); + var Component = (function () { function Component() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.updateInterval = 1; - _this.debugDisplayObject = new egret.DisplayObjectContainer(); - _this._enabled = true; - _this._updateOrder = 0; - return _this; + this.updateInterval = 1; + this._enabled = true; + this._updateOrder = 0; } Object.defineProperty(Component.prototype, "transform", { get: function () { @@ -1711,8 +1416,6 @@ var es; }; Component.prototype.onDisabled = function () { }; - Component.prototype.update = function () { - }; Component.prototype.setEnabled = function (isEnabled) { if (this._enabled != isEnabled) { this._enabled = isEnabled; @@ -1732,10 +1435,167 @@ var es; return this; }; return Component; - }(egret.HashObject)); + }()); es.Component = Component; })(es || (es = {})); var es; +(function (es) { + var Core = (function () { + function Core(width, height) { + this._globalManagers = []; + this._timerManager = new es.TimerManager(); + this._frameCounterElapsedTime = 0; + this._frameCounter = 0; + this.width = width; + this.height = height; + Core._instance = this; + Core.emitter = new es.Emitter(); + Core.registerGlobalManager(this._timerManager); + this.initialize(); + } + Object.defineProperty(Core, "Instance", { + get: function () { + return this._instance; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Core, "scene", { + get: function () { + if (!this._instance) + return null; + return this._instance._scene; + }, + set: function (value) { + if (!value) { + console.error("场景不能为空"); + return; + } + if (this._instance._scene == null) { + this._instance._scene = value; + this._instance._scene.begin(); + Core.Instance.onSceneChanged(); + } + else { + this._instance._nextScene = value; + } + }, + enumerable: true, + configurable: true + }); + Core.startSceneTransition = function (sceneTransition) { + if (this._instance._sceneTransition) { + console.warn("在前一个场景完成之前,不能开始一个新的场景转换。"); + return; + } + this._instance._sceneTransition = sceneTransition; + return sceneTransition; + }; + Core.registerGlobalManager = function (manager) { + this._instance._globalManagers.push(manager); + manager.enabled = true; + }; + Core.unregisterGlobalManager = function (manager) { + this._instance._globalManagers.remove(manager); + manager.enabled = false; + }; + Core.getGlobalManager = function (type) { + for (var i = 0; i < this._instance._globalManagers.length; i++) { + if (this._instance._globalManagers[i] instanceof type) + return this._instance._globalManagers[i]; + } + return null; + }; + Core.schedule = function (timeInSeconds, repeats, context, onTime) { + if (repeats === void 0) { repeats = false; } + if (context === void 0) { context = null; } + return this._instance._timerManager.schedule(timeInSeconds, repeats, context, onTime); + }; + Core.prototype.onOrientationChanged = function () { + Core.emitter.emit(es.CoreEvents.OrientationChanged); + }; + Core.prototype.draw = function () { + return __awaiter(this, void 0, void 0, function () { + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + if (!this._sceneTransition) return [3, 4]; + this._sceneTransition.preRender(); + if (!(this._scene && !this._sceneTransition.hasPreviousSceneRender)) return [3, 2]; + this._scene.render(); + this._scene.postRender(); + return [4, this._sceneTransition.onBeginTransition()]; + case 1: + _a.sent(); + return [3, 3]; + case 2: + if (this._sceneTransition) { + if (this._scene && this._sceneTransition.isNewSceneLoaded) { + this._scene.render(); + this._scene.postRender(); + } + this._sceneTransition.render(); + } + _a.label = 3; + case 3: return [3, 5]; + case 4: + if (this._scene) { + this._scene.render(); + this._scene.postRender(); + } + _a.label = 5; + case 5: return [2]; + } + }); + }); + }; + Core.prototype.onSceneChanged = function () { + Core.emitter.emit(es.CoreEvents.SceneChanged); + es.Time.sceneChanged(); + }; + Core.prototype.onGraphicsDeviceReset = function () { + Core.emitter.emit(es.CoreEvents.GraphicsDeviceReset); + }; + Core.prototype.initialize = function () { + }; + Core.prototype.update = function () { + return __awaiter(this, void 0, void 0, function () { + var i; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + if (!this._scene) return [3, 2]; + for (i = this._globalManagers.length - 1; i >= 0; i--) { + if (this._globalManagers[i].enabled) + this._globalManagers[i].update(); + } + if (!this._sceneTransition || + (this._sceneTransition && (!this._sceneTransition.loadsNewScene || this._sceneTransition.isNewSceneLoaded))) { + this._scene.update(); + } + if (!this._nextScene) return [3, 2]; + this._scene.end(); + this._scene = this._nextScene; + this._nextScene = null; + this.onSceneChanged(); + return [4, this._scene.begin()]; + case 1: + _a.sent(); + _a.label = 2; + case 2: return [4, this.draw()]; + case 3: + _a.sent(); + return [2]; + } + }); + }); + }; + Core.debugRenderEndabled = false; + return Core; + }()); + es.Core = Core; +})(es || (es = {})); +var es; (function (es) { var CoreEvents; (function (CoreEvents) { @@ -2035,21 +1895,14 @@ var es; })(es || (es = {})); var es; (function (es) { - var Scene = (function (_super) { - __extends(Scene, _super); + var Scene = (function () { function Scene() { - var _this = _super.call(this) || this; - _this.enablePostProcessing = true; - _this._sceneComponents = []; - _this._renderers = []; - _this._postProcessors = []; - _this.dynamicBatch = false; - _this.entities = new es.EntityList(_this); - _this.renderableComponents = new es.RenderableComponentList(); - _this.content = new es.ContentManager(); - _this.entityProcessors = new es.EntityProcessorList(); - _this.initialize(); - return _this; + this._sceneComponents = []; + this._renderers = []; + this.entities = new es.EntityList(this); + this.renderableComponents = new es.RenderableComponentList(); + this.entityProcessors = new es.EntityProcessorList(); + this.initialize(); } Scene.createWithDefaultRenderer = function () { var scene = new Scene(); @@ -2076,18 +1929,12 @@ var es; this.addRenderer(new es.DefaultRenderer()); console.warn("场景开始时没有渲染器 自动添加DefaultRenderer以保证能够正常渲染"); } - var cameraEntity = this.findEntity("camera"); - if (!cameraEntity) - cameraEntity = this.createEntity("camera"); - this.camera = cameraEntity.getOrCreateComponent(new es.Camera()); es.Physics.reset(); this.updateResolutionScaler(); if (this.entityProcessors) this.entityProcessors.begin(); es.Core.emitter.addObserver(es.CoreEvents.GraphicsDeviceReset, this.updateResolutionScaler, this); es.Core.emitter.addObserver(es.CoreEvents.OrientationChanged, this.updateResolutionScaler, this); - this.addEventListener(egret.Event.ACTIVATE, this.onActive, this); - this.addEventListener(egret.Event.DEACTIVATE, this.onDeactive, this); this._didSceneBegin = true; this.onStart(); }; @@ -2095,30 +1942,20 @@ var es; this._didSceneBegin = false; es.Core.emitter.removeObserver(es.CoreEvents.GraphicsDeviceReset, this.updateResolutionScaler); es.Core.emitter.removeObserver(es.CoreEvents.OrientationChanged, this.updateResolutionScaler); - this.removeEventListener(egret.Event.DEACTIVATE, this.onDeactive, this); - this.removeEventListener(egret.Event.ACTIVATE, this.onActive, this); for (var i = 0; i < this._renderers.length; i++) { this._renderers[i].unload(); } - for (var i = 0; i < this._postProcessors.length; i++) { - this._postProcessors[i].unload(); - } this.entities.removeAllEntities(); - this.removeChildren(); for (var i = 0; i < this._sceneComponents.length; i++) { this._sceneComponents[i].onRemovedFromScene(); } this._sceneComponents.length = 0; this.camera = null; - this.content.dispose(); if (this.entityProcessors) this.entityProcessors.end(); - if (this.parent) - this.parent.removeChild(this); this.unload(); }; Scene.prototype.updateResolutionScaler = function () { - this.camera.onSceneRenderTargetSizeChanged(es.Core.Instance.stage.stageWidth, es.Core.Instance.stage.stageHeight); }; Scene.prototype.update = function () { this.entities.updateLists(); @@ -2139,53 +1976,10 @@ var es; return; } for (var i = 0; i < this._renderers.length; i++) { - this.camera.forceMatrixUpdate(); this._renderers[i].render(this); } }; - Scene.prototype.dynamicInBatch = function () { - this.removeChildren(); - var batching = false; - var displayContainer; - for (var _i = 0, _a = this.renderableComponents.buffer; _i < _a.length; _i++) { - var component = _a[_i]; - if (component instanceof es.SpriteAnimator) { - this.addChild(component.displayObject); - this.addChild(component.debugDisplayObject); - batching = false; - displayContainer = null; - } - else if (component instanceof es.RenderableComponent) { - if (!batching) { - batching = true; - displayContainer = new egret.DisplayObjectContainer(); - displayContainer.cacheAsBitmap = true; - displayContainer.touchEnabled = false; - displayContainer.touchChildren = false; - this.addChild(displayContainer); - } - displayContainer.addChild(component.displayObject); - displayContainer.addChild(component.debugDisplayObject); - } - } - }; Scene.prototype.postRender = function () { - if (this.enablePostProcessing) { - for (var i = 0; i < this._postProcessors.length; i++) { - if (this._postProcessors[i].enabled) { - this._postProcessors[i].process(); - } - } - } - if (this._screenshotRequestCallback) { - var tex = new egret.RenderTexture(); - tex.drawToTexture(this, new es.Rectangle(0, 0, this.stage.stageWidth, this.stage.stageHeight)); - this._screenshotRequestCallback(tex); - this._screenshotRequestCallback = null; - } - }; - Scene.prototype.requestScreenshot = function (callback) { - this._screenshotRequestCallback = callback; }; Scene.prototype.addSceneComponent = function (component) { component.scene = this; @@ -2235,28 +2029,6 @@ var es; this._renderers.remove(renderer); renderer.unload(); }; - Scene.prototype.addPostProcessor = function (postProcessor) { - this._postProcessors.push(postProcessor); - this._postProcessors.sort(); - postProcessor.onAddedToScene(this); - if (this._didSceneBegin) { - postProcessor.onSceneBackBufferSizeChanged(this.stage.stageWidth, this.stage.stageHeight); - } - return postProcessor; - }; - Scene.prototype.getPostProcessor = function (type) { - for (var i = 0; i < this._postProcessors.length; i++) { - if (this._postProcessors[i] instanceof type) - return this._postProcessors[i]; - } - return null; - }; - Scene.prototype.removePostProcessor = function (postProcessor) { - if (!this._postProcessors.contains(postProcessor)) - return; - this._postProcessors.remove(postProcessor); - postProcessor.unload(); - }; Scene.prototype.createEntity = function (name) { var entity = new es.Entity(name); return this.addEntity(entity); @@ -2302,7 +2074,7 @@ var es; return this.entityProcessors.getProcessor(); }; return Scene; - }(egret.DisplayObjectContainer)); + }()); es.Scene = Scene; })(es || (es = {})); var transform; @@ -2316,7 +2088,6 @@ var transform; })(transform || (transform = {})); var es; (function (es) { - var HashObject = egret.HashObject; var DirtyType; (function (DirtyType) { DirtyType[DirtyType["clean"] = 0] = "clean"; @@ -2324,27 +2095,24 @@ var es; DirtyType[DirtyType["scaleDirty"] = 2] = "scaleDirty"; DirtyType[DirtyType["rotationDirty"] = 3] = "rotationDirty"; })(DirtyType = es.DirtyType || (es.DirtyType = {})); - var Transform = (function (_super) { - __extends(Transform, _super); + var Transform = (function () { function Transform(entity) { - var _this = _super.call(this) || this; - _this._localTransform = es.Matrix2D.create(); - _this._worldTransform = es.Matrix2D.create().identity(); - _this._rotationMatrix = es.Matrix2D.create().identity(); - _this._translationMatrix = es.Matrix2D.create().identity(); - _this._scaleMatrix = es.Matrix2D.create().identity(); - _this._worldToLocalTransform = es.Matrix2D.create().identity(); - _this._worldInverseTransform = es.Matrix2D.create().identity(); - _this._position = es.Vector2.zero; - _this._scale = es.Vector2.one; - _this._rotation = 0; - _this._localPosition = es.Vector2.zero; - _this._localScale = es.Vector2.one; - _this._localRotation = 0; - _this.entity = entity; - _this.scale = _this._localScale = es.Vector2.one; - _this._children = []; - return _this; + this._localTransform = es.Matrix2D.identity; + this._worldTransform = es.Matrix2D.identity; + this._rotationMatrix = es.Matrix2D.identity; + this._translationMatrix = es.Matrix2D.identity; + this._scaleMatrix = es.Matrix2D.identity; + this._worldToLocalTransform = es.Matrix2D.identity; + this._worldInverseTransform = es.Matrix2D.identity; + this._position = es.Vector2.zero; + this._scale = es.Vector2.one; + this._rotation = 0; + this._localPosition = es.Vector2.zero; + this._localScale = es.Vector2.one; + this._localRotation = 0; + this.entity = entity; + this.scale = this._localScale = es.Vector2.one; + this._children = []; } Object.defineProperty(Transform.prototype, "childCount", { get: function () { @@ -2395,11 +2163,11 @@ var es; get: function () { if (this._worldToLocalDirty) { if (!this.parent) { - this._worldToLocalTransform = es.Matrix2D.create().identity(); + this._worldToLocalTransform = es.Matrix2D.identity; } else { this.parent.updateTransform(); - this._worldToLocalTransform = this.parent._worldTransform.invert(); + this._worldToLocalTransform = es.Matrix2D.invert(this.parent._worldTransform); } this._worldToLocalDirty = false; } @@ -2412,7 +2180,7 @@ var es; get: function () { this.updateTransform(); if (this._worldInverseDirty) { - this._worldInverseTransform = this._worldTransform.invert(); + this._worldInverseTransform = es.Matrix2D.invert(this._worldTransform); this._worldInverseDirty = false; } return this._worldInverseTransform; @@ -2500,7 +2268,7 @@ var es; return this._children[index]; }; Transform.prototype.setParent = function (parent) { - if (this._parent.equals(parent)) + if (this._parent == parent) return this; if (!this._parent) { this._parent._children.remove(this); @@ -2584,15 +2352,15 @@ var es; this.parent.updateTransform(); if (this._localDirty) { if (this._localPositionDirty) { - this._translationMatrix = es.Matrix2D.create().translate(this._localPosition.x, this._localPosition.y); + this._translationMatrix = es.Matrix2D.createTranslation(this._localPosition.x, this._localPosition.y); this._localPositionDirty = false; } if (this._localRotationDirty) { - this._rotationMatrix = es.Matrix2D.create().rotate(this._localRotation); + this._rotationMatrix = es.Matrix2D.createRotation(this._localRotation); this._localRotationDirty = false; } if (this._localScaleDirty) { - this._scaleMatrix = es.Matrix2D.create().scale(this._localScale.x, this._localScale.y); + this._scaleMatrix = es.Matrix2D.createScale(this._localScale.x, this._localScale.y); this._localScaleDirty = false; } this._localTransform = this._scaleMatrix.multiply(this._rotationMatrix); @@ -2650,312 +2418,11 @@ var es; Transform.prototype.toString = function () { return "[Transform: parent: " + this.parent + ", position: " + this.position + ", rotation: " + this.rotation + ",\n scale: " + this.scale + ", localPosition: " + this._localPosition + ", localRotation: " + this._localRotation + ",\n localScale: " + this._localScale + "]"; }; - Transform.prototype.equals = function (other) { - return other.hashCode == this.hashCode; - }; return Transform; - }(HashObject)); + }()); es.Transform = Transform; })(es || (es = {})); var es; -(function (es) { - var Camera = (function (_super) { - __extends(Camera, _super); - function Camera() { - var _this = _super.call(this) || this; - _this._inset = { left: 0, right: 0, top: 0, bottom: 0 }; - _this._areMatrixedDirty = true; - _this._areBoundsDirty = true; - _this._isProjectionMatrixDirty = true; - _this._zoom = 0; - _this._minimumZoom = 0.3; - _this._maximumZoom = 3; - _this._bounds = new es.Rectangle(); - _this._transformMatrix = new es.Matrix2D().identity(); - _this._inverseTransformMatrix = new es.Matrix2D().identity(); - _this._origin = es.Vector2.zero; - _this.setZoom(0); - return _this; - } - Object.defineProperty(Camera.prototype, "position", { - get: function () { - return this.entity.transform.position; - }, - set: function (value) { - this.entity.transform.position = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Camera.prototype, "rotation", { - get: function () { - return this.entity.transform.rotation; - }, - set: function (value) { - this.entity.transform.rotation = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Camera.prototype, "rawZoom", { - get: function () { - return this._zoom; - }, - set: function (value) { - if (value != this._zoom) { - this._zoom = value; - this._areMatrixedDirty = true; - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Camera.prototype, "zoom", { - get: function () { - if (this._zoom == 0) - return 1; - if (this._zoom < 1) - return es.MathHelper.map(this._zoom, this._minimumZoom, 1, -1, 0); - return es.MathHelper.map(this._zoom, 1, this._maximumZoom, 0, 1); - }, - set: function (value) { - this.setZoom(value); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Camera.prototype, "minimumZoom", { - get: function () { - return this._minimumZoom; - }, - set: function (value) { - this.setMinimumZoom(value); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Camera.prototype, "maximumZoom", { - get: function () { - return this._maximumZoom; - }, - set: function (value) { - this.setMaximumZoom(value); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Camera.prototype, "bounds", { - get: function () { - if (this._areMatrixedDirty) - this.updateMatrixes(); - if (this._areBoundsDirty) { - var topLeft = this.screenToWorldPoint(new es.Vector2(this._inset.left, this._inset.top)); - var bottomRight = this.screenToWorldPoint(new es.Vector2(es.Core.graphicsDevice.viewport.width - this._inset.right, es.Core.graphicsDevice.viewport.height - this._inset.bottom)); - if (this.entity.transform.rotation != 0) { - var topRight = this.screenToWorldPoint(new es.Vector2(es.Core.graphicsDevice.viewport.width - this._inset.right, this._inset.top)); - var bottomLeft = this.screenToWorldPoint(new es.Vector2(this._inset.left, es.Core.graphicsDevice.viewport.height - this._inset.bottom)); - var minX = Math.min(topLeft.x, bottomRight.x, topRight.x, bottomLeft.x); - var maxX = Math.max(topLeft.x, bottomRight.x, topRight.x, bottomLeft.x); - var minY = Math.min(topLeft.y, bottomRight.y, topRight.y, bottomLeft.y); - var maxY = Math.max(topLeft.y, bottomRight.y, topRight.y, bottomLeft.y); - this._bounds.location = new es.Vector2(minX, minY); - this._bounds.width = maxX - minX; - this._bounds.height = maxY - minY; - } - else { - this._bounds.location = topLeft; - this._bounds.width = bottomRight.x - topLeft.x; - this._bounds.height = bottomRight.y - topLeft.y; - } - this._areBoundsDirty = false; - } - return this._bounds; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Camera.prototype, "transformMatrix", { - get: function () { - if (this._areMatrixedDirty) - this.updateMatrixes(); - return this._transformMatrix; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Camera.prototype, "inverseTransformMatrix", { - get: function () { - if (this._areMatrixedDirty) - this.updateMatrixes(); - return this._inverseTransformMatrix; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Camera.prototype, "origin", { - get: function () { - return this._origin; - }, - set: function (value) { - if (this._origin != value) { - this._origin = value; - this._areMatrixedDirty = true; - } - }, - enumerable: true, - configurable: true - }); - Camera.prototype.setInset = function (left, right, top, bottom) { - this._inset = { left: left, right: right, top: top, bottom: bottom }; - this._areBoundsDirty = true; - return this; - }; - Camera.prototype.setPosition = function (position) { - this.entity.transform.setPosition(position.x, position.y); - return this; - }; - Camera.prototype.setRotation = function (rotation) { - this.entity.transform.setRotation(rotation); - return this; - }; - Camera.prototype.setZoom = function (zoom) { - var newZoom = es.MathHelper.clamp(zoom, -1, 1); - if (newZoom == 0) { - this._zoom = 1; - } - else if (newZoom < 0) { - this._zoom = es.MathHelper.map(newZoom, -1, 0, this._minimumZoom, 1); - } - else { - this._zoom = es.MathHelper.map(newZoom, 0, 1, 1, this._maximumZoom); - } - this._areMatrixedDirty = true; - return this; - }; - Camera.prototype.setMinimumZoom = function (minZoom) { - if (minZoom <= 0) { - console.error("minimumZoom must be greater than zero"); - return; - } - if (this._zoom < minZoom) - this._zoom = this.minimumZoom; - this._minimumZoom = minZoom; - return this; - }; - Camera.prototype.setMaximumZoom = function (maxZoom) { - if (maxZoom <= 0) { - console.error("maximumZoom must be greater than zero"); - return; - } - if (this._zoom > maxZoom) - this._zoom = maxZoom; - this._maximumZoom = maxZoom; - return this; - }; - Camera.prototype.forceMatrixUpdate = function () { - this._areMatrixedDirty = true; - }; - Camera.prototype.onEntityTransformChanged = function (comp) { - this._areMatrixedDirty = true; - }; - Camera.prototype.zoomIn = function (deltaZoom) { - this.zoom += deltaZoom; - }; - Camera.prototype.zoomOut = function (deltaZoom) { - this.zoom -= deltaZoom; - }; - Camera.prototype.worldToScreenPoint = function (worldPosition) { - this.updateMatrixes(); - es.Vector2Ext.transformR(worldPosition, this._transformMatrix, worldPosition); - return worldPosition; - }; - Camera.prototype.screenToWorldPoint = function (screenPosition) { - this.updateMatrixes(); - es.Vector2Ext.transformR(screenPosition, this._inverseTransformMatrix, screenPosition); - return screenPosition; - }; - Camera.prototype.onSceneRenderTargetSizeChanged = function (newWidth, newHeight) { - this._isProjectionMatrixDirty = true; - var oldOrigin = this._origin; - this.origin = new es.Vector2(newWidth / 2, newHeight / 2); - this.entity.transform.position.add(es.Vector2.subtract(this._origin, oldOrigin)); - }; - Camera.prototype.mouseToWorldPoint = function () { - return this.screenToWorldPoint(es.Input.touchPosition); - }; - Camera.prototype.updateMatrixes = function () { - if (!this._areMatrixedDirty) - return; - var tempMat; - this._transformMatrix = es.Matrix2D.create().translate(-this.entity.transform.position.x, -this.entity.transform.position.y); - if (this._zoom != 1) { - tempMat = es.Matrix2D.create().scale(this._zoom, this._zoom); - this._transformMatrix = this._transformMatrix.multiply(tempMat); - } - if (this.entity.transform.rotation != 0) { - tempMat = es.Matrix2D.create().rotate(this.entity.transform.rotation); - this._transformMatrix = this._transformMatrix.multiply(tempMat); - } - tempMat = es.Matrix2D.create().translate(Math.floor(this._origin.x), Math.floor(this._origin.y)); - this._transformMatrix = this._transformMatrix.multiply(tempMat); - this._inverseTransformMatrix = this._transformMatrix.invert(); - this._areBoundsDirty = true; - this._areMatrixedDirty = false; - }; - return Camera; - }(es.Component)); - es.Camera = Camera; -})(es || (es = {})); -var es; -(function (es) { - var CameraShake = (function (_super) { - __extends(CameraShake, _super); - function CameraShake() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this._shakeDirection = es.Vector2.zero; - _this._shakeOffset = es.Vector2.zero; - _this._shakeIntensity = 0; - _this._shakeDegredation = 0.95; - return _this; - } - CameraShake.prototype.shake = function (shakeIntensify, shakeDegredation, shakeDirection) { - if (shakeIntensify === void 0) { shakeIntensify = 15; } - if (shakeDegredation === void 0) { shakeDegredation = 0.9; } - if (shakeDirection === void 0) { shakeDirection = es.Vector2.zero; } - this.enabled = true; - if (this._shakeIntensity < shakeIntensify) { - this._shakeDirection = shakeDirection; - this._shakeIntensity = shakeIntensify; - if (shakeDegredation < 0 || shakeDegredation >= 1) { - shakeDegredation = 0.95; - } - this._shakeDegredation = shakeDegredation; - } - }; - CameraShake.prototype.update = function () { - if (Math.abs(this._shakeIntensity) > 0) { - this._shakeOffset = this._shakeDirection; - if (this._shakeOffset.x != 0 || this._shakeOffset.y != 0) { - this._shakeOffset.normalize(); - } - else { - this._shakeOffset.x = this._shakeOffset.x + Math.random() - 0.5; - this._shakeOffset.y = this._shakeOffset.y + Math.random() - 0.5; - } - this._shakeOffset.multiply(new es.Vector2(this._shakeIntensity)); - this._shakeIntensity *= -this._shakeDegredation; - if (Math.abs(this._shakeIntensity) <= 0.01) { - this._shakeIntensity = 0; - this.enabled = false; - } - } - this.entity.scene.camera.position.add(this._shakeOffset); - }; - return CameraShake; - }(es.Component)); - es.CameraShake = CameraShake; -})(es || (es = {})); -var es; (function (es) { var ComponentPool = (function () { function ComponentPool(typeClass) { @@ -2979,143 +2446,6 @@ var es; es.ComponentPool = ComponentPool; })(es || (es = {})); var es; -(function (es) { - var CameraStyle; - (function (CameraStyle) { - CameraStyle[CameraStyle["lockOn"] = 0] = "lockOn"; - CameraStyle[CameraStyle["cameraWindow"] = 1] = "cameraWindow"; - })(CameraStyle = es.CameraStyle || (es.CameraStyle = {})); - var FollowCamera = (function (_super) { - __extends(FollowCamera, _super); - function FollowCamera(targetEntity, camera, cameraStyle) { - if (targetEntity === void 0) { targetEntity = null; } - if (camera === void 0) { camera = null; } - if (cameraStyle === void 0) { cameraStyle = CameraStyle.lockOn; } - var _this = _super.call(this) || this; - _this.followLerp = 0.1; - _this.deadzone = new es.Rectangle(); - _this.focusOffset = es.Vector2.zero; - _this.mapLockEnabled = false; - _this.mapSize = new es.Rectangle(); - _this._desiredPositionDelta = new es.Vector2(); - _this._worldSpaceDeadZone = new es.Rectangle(); - _this.rectShape = new egret.Shape(); - _this._targetEntity = targetEntity; - _this._cameraStyle = cameraStyle; - _this.camera = camera; - return _this; - } - FollowCamera.prototype.onAddedToEntity = function () { - if (!this.camera) - this.camera = this.entity.scene.camera; - this.follow(this._targetEntity, this._cameraStyle); - es.Core.emitter.addObserver(es.CoreEvents.GraphicsDeviceReset, this.onGraphicsDeviceReset, this); - }; - FollowCamera.prototype.onGraphicsDeviceReset = function () { - es.Core.schedule(0, false, this, function (t) { - var self = t.context; - self.follow(self._targetEntity, self._cameraStyle); - }); - }; - FollowCamera.prototype.update = function () { - var halfScreen = es.Vector2.multiply(this.camera.bounds.size, new es.Vector2(0.5)); - this._worldSpaceDeadZone.x = this.camera.position.x - halfScreen.x * es.Core.scene.scaleX + this.deadzone.x + this.focusOffset.x; - this._worldSpaceDeadZone.y = this.camera.position.y - halfScreen.y * es.Core.scene.scaleY + this.deadzone.y + this.focusOffset.y; - this._worldSpaceDeadZone.width = this.deadzone.width; - this._worldSpaceDeadZone.height = this.deadzone.height; - if (this._targetEntity) - this.updateFollow(); - this.camera.position = es.Vector2.lerp(this.camera.position, es.Vector2.add(this.camera.position, this._desiredPositionDelta), this.followLerp); - this.entity.transform.roundPosition(); - if (this.mapLockEnabled) { - this.camera.position = this.clampToMapSize(this.camera.position); - this.entity.transform.roundPosition(); - } - }; - FollowCamera.prototype.debugRender = function (camera) { - if (!this.rectShape) - this.debugDisplayObject.addChild(this.rectShape); - this.rectShape.graphics.clear(); - if (this._cameraStyle == CameraStyle.lockOn) { - this.rectShape.graphics.beginFill(0x8B0000, 0); - this.rectShape.graphics.lineStyle(1, 0x8B0000); - this.rectShape.graphics.drawRect(this._worldSpaceDeadZone.x - 5 - camera.bounds.x, this._worldSpaceDeadZone.y - 5 - camera.bounds.y, this._worldSpaceDeadZone.width, this._worldSpaceDeadZone.height); - this.rectShape.graphics.endFill(); - } - else { - this.rectShape.graphics.beginFill(0x8B0000, 0); - this.rectShape.graphics.lineStyle(1, 0x8B0000); - this.rectShape.graphics.drawRect(this._worldSpaceDeadZone.x - camera.bounds.x, this._worldSpaceDeadZone.y - camera.bounds.y, this._worldSpaceDeadZone.width, this._worldSpaceDeadZone.height); - this.rectShape.graphics.endFill(); - } - }; - FollowCamera.prototype.clampToMapSize = function (position) { - var halfScreen = es.Vector2.multiply(this.camera.bounds.size, new es.Vector2(0.5)).add(new es.Vector2(this.mapSize.x, this.mapSize.y)); - var cameraMax = new es.Vector2(this.mapSize.width - halfScreen.x, this.mapSize.height - halfScreen.y); - return es.Vector2.clamp(position, halfScreen, cameraMax); - }; - FollowCamera.prototype.follow = function (targetEntity, cameraStyle) { - if (cameraStyle === void 0) { cameraStyle = CameraStyle.cameraWindow; } - this._targetEntity = targetEntity; - this._cameraStyle = cameraStyle; - var cameraBounds = this.camera.bounds; - switch (this._cameraStyle) { - case CameraStyle.cameraWindow: - var w = cameraBounds.width / 6; - var h = cameraBounds.height / 3; - this.deadzone = new es.Rectangle((cameraBounds.width - w) / 2, (cameraBounds.height - h) / 2, w, h); - break; - case CameraStyle.lockOn: - this.deadzone = new es.Rectangle(cameraBounds.width / 2, cameraBounds.height / 2, 10, 10); - break; - } - }; - FollowCamera.prototype.updateFollow = function () { - this._desiredPositionDelta.x = this._desiredPositionDelta.y = 0; - if (this._cameraStyle == CameraStyle.lockOn) { - var targetX = this._targetEntity.transform.position.x; - var targetY = this._targetEntity.transform.position.y; - if (this._worldSpaceDeadZone.x > targetX) - this._desiredPositionDelta.x = targetX - this._worldSpaceDeadZone.x; - else if (this._worldSpaceDeadZone.x < targetX) - this._desiredPositionDelta.x = targetX - this._worldSpaceDeadZone.x; - if (this._worldSpaceDeadZone.y < targetY) - this._desiredPositionDelta.y = targetY - this._worldSpaceDeadZone.y; - else if (this._worldSpaceDeadZone.y > targetY) - this._desiredPositionDelta.y = targetY - this._worldSpaceDeadZone.y; - } - else { - if (!this._targetCollider) { - this._targetCollider = this._targetEntity.getComponent(es.Collider); - if (!this._targetCollider) - return; - } - var targetBounds = this._targetEntity.getComponent(es.Collider).bounds; - if (!this._worldSpaceDeadZone.containsRect(targetBounds)) { - if (this._worldSpaceDeadZone.left > targetBounds.left) - this._desiredPositionDelta.x = targetBounds.left - this._worldSpaceDeadZone.left; - else if (this._worldSpaceDeadZone.right < targetBounds.right) - this._desiredPositionDelta.x = targetBounds.right - this._worldSpaceDeadZone.right; - if (this._worldSpaceDeadZone.bottom < targetBounds.bottom) - this._desiredPositionDelta.y = targetBounds.bottom - this._worldSpaceDeadZone.bottom; - else if (this._worldSpaceDeadZone.top > targetBounds.top) - this._desiredPositionDelta.y = targetBounds.top - this._worldSpaceDeadZone.top; - } - } - }; - FollowCamera.prototype.setCenteredDeadzone = function (width, height) { - if (!this.camera) { - console.error("相机是null。我们不能得到它的边界。请等到该组件添加到实体之后"); - return; - } - var cameraBounds = this.camera.bounds; - this.deadzone = new es.Rectangle((cameraBounds.width - width) / 2, (cameraBounds.height - height) / 2, width, height); - }; - return FollowCamera; - }(es.Component)); - es.FollowCamera = FollowCamera; -})(es || (es = {})); -var es; (function (es) { var IUpdatableComparer = (function () { function IUpdatableComparer() { @@ -3126,6 +2456,7 @@ var es; return IUpdatableComparer; }()); es.IUpdatableComparer = IUpdatableComparer; + es.isIUpdatable = function (props) { return typeof props['js'] !== 'undefined'; }; })(es || (es = {})); var es; (function (es) { @@ -3353,29 +2684,6 @@ var es; return this; }; Collider.prototype.onAddedToEntity = function () { - if (this._colliderRequiresAutoSizing) { - if (!(this instanceof es.BoxCollider || this instanceof es.CircleCollider)) { - console.error("Only box and circle colliders can be created automatically"); - return; - } - var renderable = this.entity.getComponent(es.RenderableComponent); - if (renderable) { - var renderableBounds = renderable.bounds; - var width = renderableBounds.width / this.entity.transform.scale.x; - var height = renderableBounds.height / this.entity.transform.scale.y; - if (this instanceof es.CircleCollider) { - this.radius = Math.max(width, height) * 0.5; - } - else { - this.width = width; - this.height = height; - } - this.localOffset = es.Vector2.subtract(renderableBounds.center, this.entity.transform.position); - } - else { - console.warn("碰撞器没有形状和RenderableComponent。不知道如何调整大小."); - } - } this._isParentEntityAddedToScene = true; this.registerColliderWithPhysicsSystem(); }; @@ -3439,26 +2747,8 @@ var es; __extends(BoxCollider, _super); function BoxCollider(x, y, width, height) { var _this = _super.call(this) || this; - _this.hollowShape = new egret.Shape(); - _this.polygonShape = new egret.Shape(); - _this.pixelShape1 = new egret.Shape(); - _this.pixelShape2 = new egret.Shape(); - if (x == undefined && y == undefined) { - if (width == undefined && height == undefined) { - _this.shape = new es.Box(1, 1); - _this._colliderRequiresAutoSizing = true; - } - else if (width != undefined && height != undefined) { - x = -width / 2; - y = -height / 2; - _this._localOffset = new es.Vector2(x + width / 2, y + height / 2); - _this.shape = new es.Box(width, height); - } - } - else if (x != undefined && y != undefined && width != undefined && height != undefined) { - _this._localOffset = new es.Vector2(x + width / 2, y + height / 2); - _this.shape = new es.Box(width, height); - } + _this._localOffset = new es.Vector2(x + width / 2, y + height / 2); + _this.shape = new es.Box(width, height); return _this; } Object.defineProperty(BoxCollider.prototype, "width", { @@ -3482,7 +2772,6 @@ var es; configurable: true }); BoxCollider.prototype.setSize = function (width, height) { - this._colliderRequiresAutoSizing = false; var box = this.shape; if (width != box.width || height != box.height) { box.updateBox(width, height); @@ -3492,7 +2781,6 @@ var es; return this; }; BoxCollider.prototype.setWidth = function (width) { - this._colliderRequiresAutoSizing = false; var box = this.shape; if (width != box.width) { box.updateBox(width, box.height); @@ -3502,7 +2790,6 @@ var es; return this; }; BoxCollider.prototype.setHeight = function (height) { - this._colliderRequiresAutoSizing = false; var box = this.shape; if (height != box.height) { box.updateBox(box.width, height); @@ -3511,47 +2798,6 @@ var es; } }; BoxCollider.prototype.debugRender = function (camera) { - var poly = this.shape; - if (!this.hollowShape.parent) - this.debugDisplayObject.addChild(this.hollowShape); - if (!this.polygonShape.parent) - this.debugDisplayObject.addChild(this.polygonShape); - if (!this.pixelShape1.parent) - this.debugDisplayObject.addChild(this.pixelShape1); - if (!this.pixelShape2.parent) - this.debugDisplayObject.addChild(this.pixelShape2); - this.hollowShape.graphics.clear(); - this.hollowShape.graphics.beginFill(es.Colors.colliderBounds, 0); - this.hollowShape.graphics.lineStyle(es.Size.lineSizeMultiplier, es.Colors.colliderBounds); - this.hollowShape.graphics.drawRect(this.bounds.x - camera.bounds.x, this.bounds.y - camera.bounds.y, this.bounds.width, this.bounds.height); - this.hollowShape.graphics.endFill(); - this.polygonShape.graphics.clear(); - if (poly.points.length >= 2) { - this.polygonShape.graphics.beginFill(es.Colors.colliderEdge, 0); - this.polygonShape.graphics.lineStyle(es.Size.lineSizeMultiplier, es.Colors.colliderEdge); - for (var i = 0; i < poly.points.length; i++) { - if (i == 0) { - this.polygonShape.graphics.moveTo(poly.position.x + poly.points[i].x - camera.bounds.x, poly.position.y + poly.points[i].y - camera.bounds.y); - } - else { - this.polygonShape.graphics.lineTo(poly.position.x + poly.points[i].x - camera.bounds.x, poly.position.y + poly.points[i].y - camera.bounds.y); - } - } - this.polygonShape.graphics.lineTo(poly.position.x + poly.points[poly.points.length - 1].x - camera.bounds.x, poly.position.y + poly.points[0].y - camera.bounds.y); - this.polygonShape.graphics.endFill(); - } - this.pixelShape1.graphics.clear(); - this.pixelShape1.graphics.beginFill(es.Colors.colliderPosition, 0); - this.pixelShape1.graphics.lineStyle(4 * es.Size.lineSizeMultiplier, es.Colors.colliderPosition); - this.pixelShape1.graphics.moveTo(this.entity.transform.position.x - camera.bounds.x, this.entity.transform.position.y - camera.bounds.y); - this.pixelShape1.graphics.lineTo(this.entity.transform.position.x - camera.bounds.x, this.entity.transform.position.y - camera.bounds.y); - this.pixelShape1.graphics.endFill(); - this.pixelShape2.graphics.clear(); - this.pixelShape2.graphics.beginFill(es.Colors.colliderCenter, 0); - this.pixelShape2.graphics.lineStyle(2 * es.Size.lineSizeMultiplier, es.Colors.colliderCenter); - this.pixelShape2.graphics.moveTo(this.entity.transform.position.x + this.shape.center.x - camera.bounds.x, this.entity.transform.position.y + this.shape.center.y - camera.bounds.y); - this.pixelShape2.graphics.lineTo(this.entity.transform.position.x + this.shape.center.x - camera.bounds.x, this.entity.transform.position.y + this.shape.center.y - camera.bounds.y); - this.pixelShape2.graphics.endFill(); }; BoxCollider.prototype.toString = function () { return "[BoxCollider: bounds: " + this.bounds + "]"; @@ -3566,17 +2812,7 @@ var es; __extends(CircleCollider, _super); function CircleCollider(radius) { var _this = _super.call(this) || this; - _this.rectShape = new egret.Shape(); - _this.circleShape = new egret.Shape(); - _this.pixelShape1 = new egret.Shape(); - _this.pixelShape2 = new egret.Shape(); - if (radius == undefined) { - _this.shape = new es.Circle(1); - _this._colliderRequiresAutoSizing = true; - } - else { - _this.shape = new es.Circle(radius); - } + _this.shape = new es.Circle(radius); return _this; } Object.defineProperty(CircleCollider.prototype, "radius", { @@ -3590,7 +2826,6 @@ var es; configurable: true }); CircleCollider.prototype.setRadius = function (radius) { - this._colliderRequiresAutoSizing = false; var circle = this.shape; if (radius != circle.radius) { circle.radius = radius; @@ -3601,36 +2836,6 @@ var es; return this; }; CircleCollider.prototype.debugRender = function (camera) { - if (!this.rectShape.parent) - this.debugDisplayObject.addChild(this.rectShape); - if (!this.circleShape.parent) - this.debugDisplayObject.addChild(this.circleShape); - if (!this.pixelShape1.parent) - this.debugDisplayObject.addChild(this.pixelShape1); - if (!this.pixelShape2.parent) - this.debugDisplayObject.addChild(this.pixelShape2); - this.rectShape.graphics.clear(); - this.rectShape.graphics.beginFill(es.Colors.colliderBounds, 0); - this.rectShape.graphics.lineStyle(es.Size.lineSizeMultiplier, es.Colors.colliderBounds); - this.rectShape.graphics.drawRect(this.bounds.x - camera.bounds.x, this.bounds.y - camera.bounds.y, this.bounds.width, this.bounds.height); - this.rectShape.graphics.endFill(); - this.circleShape.graphics.clear(); - this.circleShape.graphics.beginFill(es.Colors.colliderEdge, 0); - this.circleShape.graphics.lineStyle(es.Size.lineSizeMultiplier, es.Colors.colliderEdge); - this.circleShape.graphics.drawCircle(this.shape.position.x - camera.bounds.x, this.shape.position.y - camera.bounds.y, this.shape.radius); - this.circleShape.graphics.endFill(); - this.pixelShape1.graphics.clear(); - this.pixelShape1.graphics.beginFill(es.Colors.colliderPosition, 0); - this.pixelShape1.graphics.lineStyle(4 * es.Size.lineSizeMultiplier, es.Colors.colliderPosition); - this.pixelShape1.graphics.moveTo(this.entity.transform.position.x - camera.bounds.x, this.entity.transform.position.y - camera.bounds.y); - this.pixelShape1.graphics.lineTo(this.entity.transform.position.x - camera.bounds.y, this.entity.transform.position.y - camera.bounds.y); - this.pixelShape1.graphics.endFill(); - this.pixelShape2.graphics.clear(); - this.pixelShape2.graphics.beginFill(es.Colors.colliderCenter, 0); - this.pixelShape2.graphics.lineStyle(2 * es.Size.lineSizeMultiplier, es.Colors.colliderCenter); - this.pixelShape2.graphics.moveTo(this.shape.position.x - camera.bounds.x, this.shape.position.y - camera.bounds.y); - this.pixelShape2.graphics.lineTo(this.shape.position.x - camera.bounds.x, this.shape.position.y - camera.bounds.y); - this.pixelShape2.graphics.endFill(); }; CircleCollider.prototype.toString = function () { return "[CircleCollider: bounds: " + this.bounds + ", radius: " + this.shape.radius + "]"; @@ -3659,780 +2864,6 @@ var es; es.PolygonCollider = PolygonCollider; })(es || (es = {})); var es; -(function (es) { - var RenderableComponent = (function (_super) { - __extends(RenderableComponent, _super); - function RenderableComponent() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.displayObject = new egret.DisplayObject(); - _this.hollowShape = new egret.Shape(); - _this.pixelShape = new egret.Shape(); - _this.color = 0x000000; - _this._areBoundsDirty = true; - _this.debugRenderEnabled = true; - _this._localOffset = es.Vector2.zero; - _this._renderLayer = 0; - _this._bounds = new es.Rectangle(); - return _this; - } - Object.defineProperty(RenderableComponent.prototype, "width", { - get: function () { - return this.bounds.width; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(RenderableComponent.prototype, "height", { - get: function () { - return this.bounds.height; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(RenderableComponent.prototype, "localOffset", { - get: function () { - return this._localOffset; - }, - set: function (value) { - this.setLocalOffset(value); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(RenderableComponent.prototype, "renderLayer", { - get: function () { - return this._renderLayer; - }, - set: function (value) { - this.setRenderLayer(value); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(RenderableComponent.prototype, "bounds", { - get: function () { - if (this._areBoundsDirty) { - this._bounds.calculateBounds(this.entity.transform.position, this._localOffset, es.Vector2.zero, this.entity.transform.scale, this.entity.transform.rotation, this.width, this.height); - this._areBoundsDirty = false; - } - return this._bounds; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(RenderableComponent.prototype, "isVisible", { - get: function () { - return this._isVisible; - }, - set: function (value) { - if (this._isVisible != value) { - this._isVisible = value; - if (this._isVisible) - this.onBecameVisible(); - else - this.onBecameInvisible(); - } - }, - enumerable: true, - configurable: true - }); - RenderableComponent.prototype.onEntityTransformChanged = function (comp) { - this._areBoundsDirty = true; - }; - RenderableComponent.prototype.debugRender = function (camera) { - if (!this.debugRenderEnabled) - return; - if (!this.hollowShape.parent) - this.debugDisplayObject.addChild(this.hollowShape); - if (!this.pixelShape.parent) - this.debugDisplayObject.addChild(this.pixelShape); - if (!this.entity.getComponent(es.Collider)) { - this.hollowShape.graphics.clear(); - this.hollowShape.graphics.beginFill(es.Colors.renderableBounds, 0); - this.hollowShape.graphics.lineStyle(1, es.Colors.renderableBounds); - this.hollowShape.graphics.drawRect(this.bounds.x - camera.bounds.x, this.bounds.y - camera.bounds.y, this.bounds.width, this.bounds.height); - this.hollowShape.graphics.endFill(); - } - var pixelPos = es.Vector2.add(this.entity.transform.position, this._localOffset).subtract(camera.bounds.location); - this.pixelShape.graphics.clear(); - this.pixelShape.graphics.beginFill(es.Colors.renderableCenter, 0); - this.pixelShape.graphics.lineStyle(4, es.Colors.renderableCenter); - this.pixelShape.graphics.moveTo(pixelPos.x, pixelPos.y); - this.pixelShape.graphics.lineTo(pixelPos.x, pixelPos.y); - this.pixelShape.graphics.endFill(); - }; - RenderableComponent.prototype.isVisibleFromCamera = function (camera) { - if (!camera) - return false; - this.isVisible = camera.bounds.intersects(this.bounds); - return this.isVisible; - }; - RenderableComponent.prototype.setRenderLayer = function (renderLayer) { - if (renderLayer != this._renderLayer) { - this.displayObject.zIndex = renderLayer; - var oldRenderLayer = this._renderLayer; - this._renderLayer = renderLayer; - if (this.entity && this.entity.scene) - this.entity.scene.renderableComponents.updateRenderableRenderLayer(this, oldRenderLayer, this._renderLayer); - } - return this; - }; - RenderableComponent.prototype.setColor = function (color) { - this.color = color; - return this; - }; - RenderableComponent.prototype.setLocalOffset = function (offset) { - if (this._localOffset != offset) { - this._localOffset = offset; - } - return this; - }; - RenderableComponent.prototype.sync = function (camera) { - if (this.displayObject.x != this.bounds.x - camera.bounds.y) - this.displayObject.x = this.bounds.x - camera.bounds.y; - if (this.displayObject.y != this.bounds.y - camera.bounds.y) - this.displayObject.y = this.bounds.y - camera.bounds.y; - if (this.displayObject.scaleX != this.entity.scale.x) - this.displayObject.scaleX = this.entity.scale.x; - if (this.displayObject.scaleY != this.entity.scale.y) - this.displayObject.scaleY = this.entity.scale.y; - if (this.displayObject.rotation != this.entity.rotationDegrees) - this.displayObject.rotation = this.entity.rotationDegrees; - }; - RenderableComponent.prototype.compareTo = function (other) { - return other.renderLayer - this.renderLayer; - }; - RenderableComponent.prototype.toString = function () { - return "[RenderableComponent] renderLayer: " + this.renderLayer; - }; - RenderableComponent.prototype.onBecameVisible = function () { - this.displayObject.visible = this.isVisible; - this.debugDisplayObject.visible = this.isVisible; - }; - RenderableComponent.prototype.onBecameInvisible = function () { - this.displayObject.visible = this.isVisible; - this.debugDisplayObject.visible = this.isVisible; - }; - return RenderableComponent; - }(es.Component)); - es.RenderableComponent = RenderableComponent; -})(es || (es = {})); -var es; -(function (es) { - var Mesh = (function (_super) { - __extends(Mesh, _super); - function Mesh() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.displayObject = new egret.Mesh(); - _this._primitiveCount = 0; - _this._width = 0; - _this._height = 0; - _this._triangles = []; - _this._verts = []; - return _this; - } - Object.defineProperty(Mesh.prototype, "bounds", { - get: function () { - if (this._areBoundsDirty) { - this._bounds.calculateBounds(es.Vector2.add(this.entity.transform.position, this._topLeftVertPosition), es.Vector2.zero, es.Vector2.zero, this.entity.transform.scale, this.entity.transform.rotation, this._width, this._height); - this._areBoundsDirty = false; - } - return this._bounds; - }, - enumerable: true, - configurable: true - }); - Mesh.prototype.recalculateBounds = function (recalculateUVs) { - this._topLeftVertPosition = new es.Vector2(Number.MAX_VALUE, Number.MAX_VALUE); - var max = new es.Vector2(Number.MIN_VALUE, Number.MIN_VALUE); - for (var i = 0; i < this._verts.length; i++) { - this._topLeftVertPosition.x = Math.min(this._topLeftVertPosition.x, this._verts[i].position.x); - this._topLeftVertPosition.y = Math.min(this._topLeftVertPosition.y, this._verts[i].position.y); - max.x = Math.max(max.x, this._verts[i].position.x); - max.y = Math.max(max.y, this._verts[i].position.y); - } - this._width = max.x - this._topLeftVertPosition.x; - this._height = max.y - this._topLeftVertPosition.y; - if (recalculateUVs) { - for (var i = 0; i < this._verts.length; i++) { - this._verts[i].textureCoordinate.x = (this._verts[i].position.x - this._topLeftVertPosition.x) / this._width; - this._verts[i].textureCoordinate.y = (this._verts[i].position.y - this._topLeftVertPosition.y) / this._height; - } - } - return this; - }; - Mesh.prototype.setTexture = function (texture) { - this.displayObject.texture = texture; - return this; - }; - Mesh.prototype.setVertPositions = function (positions) { - if (this._verts == undefined || this._verts.length != positions.length) { - this._verts = new Array(positions.length); - this._verts.fill(new VertexPositionColorTexture(), 0, positions.length); - } - for (var i = 0; i < this._verts.length; i++) { - this._verts[i].position = positions[i]; - } - return this; - }; - Mesh.prototype.setTriangles = function (triangles) { - if (triangles.length % 3 != 0) { - console.error("三角形必须是3的倍数"); - return; - } - this._primitiveCount = triangles.length / 3; - this._triangles = triangles; - return this; - }; - Mesh.prototype.render = function (camera) { - var renderNode = this.displayObject.$renderNode; - renderNode.imageWidth = this._width; - renderNode.imageHeight = this._height; - renderNode.vertices = this._triangles; - }; - return Mesh; - }(es.RenderableComponent)); - es.Mesh = Mesh; - var VertexPositionColorTexture = (function () { - function VertexPositionColorTexture() { - } - return VertexPositionColorTexture; - }()); - es.VertexPositionColorTexture = VertexPositionColorTexture; -})(es || (es = {})); -var es; -(function (es) { - var Bitmap = egret.Bitmap; - var SpriteRenderer = (function (_super) { - __extends(SpriteRenderer, _super); - function SpriteRenderer(sprite) { - if (sprite === void 0) { sprite = null; } - var _this = _super.call(this) || this; - if (sprite instanceof es.Sprite) - _this.setSprite(sprite); - else if (sprite instanceof egret.Texture) - _this.setSprite(new es.Sprite(sprite)); - return _this; - } - Object.defineProperty(SpriteRenderer.prototype, "bounds", { - get: function () { - if (this._areBoundsDirty) { - if (this._sprite) { - this._bounds.calculateBounds(this.entity.transform.position, this._localOffset, this._origin, this.entity.transform.scale, this.entity.transform.rotation, this._sprite.sourceRect.width, this._sprite.sourceRect.height); - this._areBoundsDirty = false; - } - } - return this._bounds; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(SpriteRenderer.prototype, "originNormalized", { - get: function () { - return new es.Vector2(this._origin.x / this.width * this.entity.transform.scale.x, this._origin.y / this.height * this.entity.transform.scale.y); - }, - set: function (value) { - this.setOrigin(new es.Vector2(value.x * this.width / this.entity.transform.scale.x, value.y * this.height / this.entity.transform.scale.y)); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(SpriteRenderer.prototype, "origin", { - get: function () { - return this._origin; - }, - set: function (value) { - this.setOrigin(value); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(SpriteRenderer.prototype, "sprite", { - get: function () { - return this._sprite; - }, - set: function (value) { - this.setSprite(value); - }, - enumerable: true, - configurable: true - }); - SpriteRenderer.prototype.setSprite = function (sprite) { - this._sprite = sprite; - if (this._sprite) { - this._origin = this._sprite.origin; - this.displayObject.anchorOffsetX = this._origin.x; - this.displayObject.anchorOffsetY = this._origin.y; - } - this.displayObject = new Bitmap(sprite.texture2D); - this.displayObject.touchEnabled = false; - return this; - }; - SpriteRenderer.prototype.setOrigin = function (origin) { - if (!this._origin.equals(origin)) { - this._origin = origin; - this.displayObject.anchorOffsetX = this._origin.x; - this.displayObject.anchorOffsetY = this._origin.y; - this._areBoundsDirty = true; - } - return this; - }; - SpriteRenderer.prototype.setOriginNormalized = function (value) { - this.setOrigin(new es.Vector2(value.x * this.width / this.entity.transform.scale.x, value.y * this.height / this.entity.transform.scale.y)); - return this; - }; - SpriteRenderer.prototype.render = function (camera) { - this.sync(camera); - if (this.displayObject.x != this.bounds.x - camera.bounds.x + this._origin.x) - this.displayObject.x = this.bounds.x - camera.bounds.x + this._origin.x * this.entity.scale.x; - if (this.displayObject.y != this.bounds.y - camera.bounds.y + this._origin.y) - this.displayObject.y = this.bounds.y - camera.bounds.y + this._origin.y * this.entity.scale.y; - if (this.displayObject.anchorOffsetX != this._origin.x) - this.displayObject.anchorOffsetX = this._origin.x; - if (this.displayObject.anchorOffsetY != this._origin.y) - this.displayObject.anchorOffsetY = this._origin.y; - }; - return SpriteRenderer; - }(es.RenderableComponent)); - es.SpriteRenderer = SpriteRenderer; -})(es || (es = {})); -var es; -(function (es) { - var Bitmap = egret.Bitmap; - var RenderTexture = egret.RenderTexture; - var TiledSpriteRenderer = (function (_super) { - __extends(TiledSpriteRenderer, _super); - function TiledSpriteRenderer(sprite) { - var _this = _super.call(this, sprite) || this; - _this._textureScale = es.Vector2.one; - _this._inverseTexScale = es.Vector2.one; - _this._gapX = 0; - _this._gapY = 0; - _this._sourceRect = sprite.sourceRect; - var bitmap = _this.displayObject; - bitmap.$fillMode = egret.BitmapFillMode.REPEAT; - return _this; - } - Object.defineProperty(TiledSpriteRenderer.prototype, "bounds", { - get: function () { - if (this._areBoundsDirty) { - if (this._sprite) { - this._bounds.calculateBounds(this.entity.transform.position, this._localOffset, this._origin, this.entity.transform.scale, this.entity.transform.rotation, this.width, this.height); - this._areBoundsDirty = false; - } - } - return this._bounds; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(TiledSpriteRenderer.prototype, "scrollX", { - get: function () { - return this._sourceRect.x; - }, - set: function (value) { - this._sourceRect.x = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(TiledSpriteRenderer.prototype, "scrollY", { - get: function () { - return this._sourceRect.y; - }, - set: function (value) { - this._sourceRect.y = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(TiledSpriteRenderer.prototype, "textureScale", { - get: function () { - return this._textureScale; - }, - set: function (value) { - this._textureScale = value; - this._inverseTexScale = new es.Vector2(1 / this._textureScale.x, 1 / this._textureScale.y); - this._sourceRect.width = Math.floor(this._sprite.sourceRect.width * this._inverseTexScale.x); - this._sourceRect.height = Math.floor(this._sprite.sourceRect.height * this._inverseTexScale.y); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(TiledSpriteRenderer.prototype, "width", { - get: function () { - return this._sourceRect.width; - }, - set: function (value) { - this._areBoundsDirty = true; - this._sourceRect.width = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(TiledSpriteRenderer.prototype, "height", { - get: function () { - return this._sourceRect.height; - }, - set: function (value) { - this._areBoundsDirty = true; - this._sourceRect.height = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(TiledSpriteRenderer.prototype, "gapXY", { - get: function () { - return new es.Vector2(this._gapX, this._gapY); - }, - set: function (value) { - this._gapX = value.x; - this._gapY = value.y; - var renderTexture = new RenderTexture(); - var newRectangle = this.sprite.sourceRect; - newRectangle.x = 0; - newRectangle.y = 0; - newRectangle.width += this._gapX; - newRectangle.height += this._gapY; - renderTexture.drawToTexture(this.displayObject, newRectangle); - if (!this.displayObject) { - this.displayObject = new Bitmap(renderTexture); - } - else { - this.displayObject.texture = renderTexture; - } - }, - enumerable: true, - configurable: true - }); - TiledSpriteRenderer.prototype.setGapXY = function (value) { - this.gapXY = value; - return this; - }; - TiledSpriteRenderer.prototype.render = function (camera) { - _super.prototype.render.call(this, camera); - var bitmap = this.displayObject; - bitmap.width = this.width; - bitmap.height = this.height; - bitmap.scrollRect = this._sourceRect; - }; - return TiledSpriteRenderer; - }(es.SpriteRenderer)); - es.TiledSpriteRenderer = TiledSpriteRenderer; -})(es || (es = {})); -var es; -(function (es) { - var ScrollingSpriteRenderer = (function (_super) { - __extends(ScrollingSpriteRenderer, _super); - function ScrollingSpriteRenderer(sprite) { - var _this = _super.call(this, sprite) || this; - _this.scrollSpeedX = 15; - _this.scroolSpeedY = 0; - _this._scrollX = 0; - _this._scrollY = 0; - _this._scrollWidth = 0; - _this._scrollHeight = 0; - _this._scrollWidth = _this.width; - _this._scrollHeight = _this.height; - return _this; - } - Object.defineProperty(ScrollingSpriteRenderer.prototype, "textureScale", { - get: function () { - return this._textureScale; - }, - set: function (value) { - this._textureScale = value; - this._inverseTexScale = new es.Vector2(1 / this._textureScale.x, 1 / this._textureScale.y); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ScrollingSpriteRenderer.prototype, "scrollWidth", { - get: function () { - return this._scrollWidth; - }, - set: function (value) { - this._scrollWidth = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ScrollingSpriteRenderer.prototype, "scrollHeight", { - get: function () { - return this._scrollHeight; - }, - set: function (value) { - this._scrollHeight = value; - }, - enumerable: true, - configurable: true - }); - ScrollingSpriteRenderer.prototype.update = function () { - if (!this.sprite) - return; - this._scrollX += this.scrollSpeedX * es.Time.deltaTime; - this._scrollY += this.scroolSpeedY * es.Time.deltaTime; - this._sourceRect.x = Math.floor(this._scrollX); - this._sourceRect.y = Math.floor(this._scrollY); - this._sourceRect.width = this._scrollWidth + Math.abs(this._scrollX); - this._sourceRect.height = this._scrollHeight + Math.abs(this._scrollY); - }; - return ScrollingSpriteRenderer; - }(es.TiledSpriteRenderer)); - es.ScrollingSpriteRenderer = ScrollingSpriteRenderer; -})(es || (es = {})); -var es; -(function (es) { - var SpriteSheet = egret.SpriteSheet; - var Sprite = (function () { - function Sprite(texture, sourceRect, origin) { - if (sourceRect === void 0) { sourceRect = new es.Rectangle(0, 0, texture.textureWidth, texture.textureHeight); } - if (origin === void 0) { origin = sourceRect.getHalfSize(); } - this.uvs = new es.Rectangle(); - this.texture2D = texture; - this.sourceRect = sourceRect; - this.center = new es.Vector2(sourceRect.width * 0.5, sourceRect.height * 0.5); - this.origin = origin; - var inverseTexW = 1 / texture.textureWidth; - var inverseTexH = 1 / texture.textureHeight; - this.uvs.x = sourceRect.x * inverseTexW; - this.uvs.y = sourceRect.y * inverseTexH; - this.uvs.width = sourceRect.width * inverseTexW; - this.uvs.height = sourceRect.height * inverseTexH; - } - Sprite.spritesFromAtlas = function (texture, cellWidth, cellHeight, cellOffset, maxCellsToInclude) { - if (cellOffset === void 0) { cellOffset = 0; } - if (maxCellsToInclude === void 0) { maxCellsToInclude = Number.MAX_VALUE; } - var sprites = []; - var cols = texture.textureWidth / cellWidth; - var rows = texture.textureHeight / cellHeight; - var i = 0; - var spriteSheet = new SpriteSheet(texture); - for (var y = 0; y < rows; y++) { - for (var x = 0; x < cols; x++) { - if (i++ < cellOffset) - continue; - var texture_1 = spriteSheet.getTexture(y + "_" + x); - if (!texture_1) - texture_1 = spriteSheet.createTexture(y + "_" + x, x * cellWidth, y * cellHeight, cellWidth, cellHeight); - sprites.push(new Sprite(texture_1)); - if (sprites.length == maxCellsToInclude) - return sprites; - } - } - return sprites; - }; - return Sprite; - }()); - es.Sprite = Sprite; -})(es || (es = {})); -var es; -(function (es) { - var SpriteAnimation = (function () { - function SpriteAnimation(sprites, frameRate) { - if (frameRate === void 0) { frameRate = 10; } - this.sprites = sprites; - this.frameRate = frameRate; - } - return SpriteAnimation; - }()); - es.SpriteAnimation = SpriteAnimation; -})(es || (es = {})); -var es; -(function (es) { - var LoopMode; - (function (LoopMode) { - LoopMode[LoopMode["loop"] = 0] = "loop"; - LoopMode[LoopMode["once"] = 1] = "once"; - LoopMode[LoopMode["clampForever"] = 2] = "clampForever"; - LoopMode[LoopMode["pingPong"] = 3] = "pingPong"; - LoopMode[LoopMode["pingPongOnce"] = 4] = "pingPongOnce"; - })(LoopMode = es.LoopMode || (es.LoopMode = {})); - var State; - (function (State) { - State[State["none"] = 0] = "none"; - State[State["running"] = 1] = "running"; - State[State["paused"] = 2] = "paused"; - State[State["completed"] = 3] = "completed"; - })(State = es.State || (es.State = {})); - var SpriteAnimator = (function (_super) { - __extends(SpriteAnimator, _super); - function SpriteAnimator(sprite) { - var _this = _super.call(this, sprite) || this; - _this.speed = 1; - _this.animationState = State.none; - _this._elapsedTime = 0; - _this._animations = new Map(); - return _this; - } - Object.defineProperty(SpriteAnimator.prototype, "isRunning", { - get: function () { - return this.animationState == State.running; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(SpriteAnimator.prototype, "animations", { - get: function () { - return this._animations; - }, - enumerable: true, - configurable: true - }); - SpriteAnimator.prototype.update = function () { - if (this.animationState != State.running || !this.currentAnimation) - return; - var animation = this.currentAnimation; - var secondsPerFrame = 1 / (animation.frameRate * this.speed); - var iterationDuration = secondsPerFrame * animation.sprites.length; - this._elapsedTime += es.Time.deltaTime; - var time = Math.abs(this._elapsedTime); - if (this._loopMode == LoopMode.once && time > iterationDuration || - this._loopMode == LoopMode.pingPongOnce && time > iterationDuration * 2) { - this.animationState = State.completed; - this._elapsedTime = 0; - this.currentFrame = 0; - this.displayObject.texture = animation.sprites[this.currentFrame].texture2D; - return; - } - var i = Math.floor(time / secondsPerFrame); - var n = animation.sprites.length; - if (n > 2 && (this._loopMode == LoopMode.pingPong || this._loopMode == LoopMode.pingPongOnce)) { - var maxIndex = n - 1; - this.currentFrame = maxIndex - Math.abs(maxIndex - i % (maxIndex * 2)); - } - else { - this.currentFrame = i % n; - } - this.displayObject.texture = animation.sprites[this.currentFrame].texture2D; - }; - SpriteAnimator.prototype.addAnimation = function (name, animation) { - if (!this.sprite && animation.sprites.length > 0) - this.setSprite(animation.sprites[0]); - this._animations[name] = animation; - return this; - }; - SpriteAnimator.prototype.play = function (name, loopMode) { - if (loopMode === void 0) { loopMode = null; } - this.currentAnimation = this._animations[name]; - this.currentAnimationName = name; - this.currentFrame = 0; - this.animationState = State.running; - this.displayObject.texture = this.currentAnimation.sprites[0].texture2D; - this._elapsedTime = 0; - this._loopMode = loopMode ? loopMode : LoopMode.loop; - }; - SpriteAnimator.prototype.isAnimationActive = function (name) { - return this.currentAnimation && this.currentAnimationName == name; - }; - SpriteAnimator.prototype.pause = function () { - this.animationState = State.paused; - }; - SpriteAnimator.prototype.unPause = function () { - this.animationState = State.running; - }; - SpriteAnimator.prototype.stop = function () { - this.currentAnimation = null; - this.currentAnimationName = null; - this.currentFrame = 0; - this.animationState = State.none; - }; - return SpriteAnimator; - }(es.SpriteRenderer)); - es.SpriteAnimator = SpriteAnimator; -})(es || (es = {})); -var es; -(function (es) { - var Bitmap = egret.Bitmap; - var StaticSpriteContainerRenderer = (function (_super) { - __extends(StaticSpriteContainerRenderer, _super); - function StaticSpriteContainerRenderer(sprite) { - if (sprite === void 0) { sprite = null; } - var _this = _super.call(this) || this; - _this.displayObject = new egret.DisplayObjectContainer(); - _this.displayObjectCache = new Map(); - for (var _i = 0, sprite_1 = sprite; _i < sprite_1.length; _i++) { - var s = sprite_1[_i]; - if (s instanceof es.Sprite) - _this.pushSprite(s); - else if (s instanceof egret.Texture) - _this.pushSprite(new es.Sprite(s)); - } - _this.displayObject.cacheAsBitmap = true; - return _this; - } - Object.defineProperty(StaticSpriteContainerRenderer.prototype, "bounds", { - get: function () { - if (this._areBoundsDirty) { - if (this.displayObject) { - this._bounds.calculateBounds(this.entity.transform.position, this._localOffset, this._origin, this.entity.transform.scale, this.entity.transform.rotation, this.displayObject.width, this.displayObject.height); - this._areBoundsDirty = false; - } - } - return this._bounds; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(StaticSpriteContainerRenderer.prototype, "originNormalized", { - get: function () { - return new es.Vector2(this._origin.x / this.width * this.entity.transform.scale.x, this._origin.y / this.height * this.entity.transform.scale.y); - }, - set: function (value) { - this.setOrigin(new es.Vector2(value.x * this.width / this.entity.transform.scale.x, value.y * this.height / this.entity.transform.scale.y)); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(StaticSpriteContainerRenderer.prototype, "origin", { - get: function () { - return this._origin; - }, - set: function (value) { - this.setOrigin(value); - }, - enumerable: true, - configurable: true - }); - StaticSpriteContainerRenderer.prototype.pushSprite = function (sprite) { - if (sprite) { - this._origin = sprite.origin; - this.displayObject.anchorOffsetX = this._origin.x; - this.displayObject.anchorOffsetY = this._origin.y; - } - var bitmap = new Bitmap(sprite.texture2D); - this.displayObject.addChild(new Bitmap(sprite.texture2D)); - this.displayObjectCache.set(sprite, bitmap); - return this; - }; - StaticSpriteContainerRenderer.prototype.getSprite = function (sprite) { - return this.displayObjectCache.get(sprite); - }; - StaticSpriteContainerRenderer.prototype.setOrigin = function (origin) { - if (this._origin != origin) { - this._origin = origin; - this.displayObject.anchorOffsetX = this._origin.x; - this.displayObject.anchorOffsetY = this._origin.y; - this._areBoundsDirty = true; - } - return this; - }; - StaticSpriteContainerRenderer.prototype.setOriginNormalized = function (value) { - this.setOrigin(new es.Vector2(value.x * this.width / this.entity.transform.scale.x, value.y * this.height / this.entity.transform.scale.y)); - return this; - }; - StaticSpriteContainerRenderer.prototype.render = function (camera) { - this.sync(camera); - if (this.displayObject.x != this.bounds.x - camera.bounds.x) - this.displayObject.x = this.bounds.x - camera.bounds.x; - if (this.displayObject.y != this.bounds.y - camera.bounds.y) - this.displayObject.y = this.bounds.y - camera.bounds.y; - }; - return StaticSpriteContainerRenderer; - }(es.RenderableComponent)); - es.StaticSpriteContainerRenderer = StaticSpriteContainerRenderer; -})(es || (es = {})); -var es; (function (es) { var EntitySystem = (function () { function EntitySystem(matcher) { @@ -4673,6 +3104,7 @@ var es; var ComponentList = (function () { function ComponentList(entity) { this._components = new es.FastList(); + this._updatableComponents = new es.FastList(); this._componentsToAdd = []; this._componentsToRemove = []; this._tempBufferList = []; @@ -4712,6 +3144,7 @@ var es; this.handleRemove(this._components[i]); } this._components.clear(); + this._updatableComponents.clear(); this._componentsToAdd.length = 0; this._componentsToRemove.length = 0; }; @@ -4720,13 +3153,8 @@ var es; var component = this._components.buffer[i]; if (!component) continue; - if (component instanceof es.RenderableComponent) { - if (component.displayObject.parent) - component.displayObject.parent.removeChild(component.displayObject); - this._entity.scene.renderableComponents.remove(component); - } - if (component.debugDisplayObject.parent) - component.debugDisplayObject.parent.removeChild(component.debugDisplayObject); + if (es.isIUpdatable(component)) + this._updatableComponents.remove(component); this._entity.componentBits.set(es.ComponentTypeManager.getIndexFor(component), false); this._entity.scene.entityProcessors.onComponentRemoved(this._entity); } @@ -4734,18 +3162,11 @@ var es; ComponentList.prototype.registerAllComponents = function () { for (var i = 0; i < this._components.length; i++) { var component = this._components.buffer[i]; - if (component instanceof es.RenderableComponent) { - if (!this._entity.scene.dynamicBatch) - this._entity.scene.addChild(component.displayObject); - this._entity.scene.renderableComponents.add(component); - } - if (!this._entity.scene.dynamicBatch) - this._entity.scene.addChild(component.debugDisplayObject); + if (es.isIUpdatable(component)) + this._updatableComponents.add(component); this._entity.componentBits.set(es.ComponentTypeManager.getIndexFor(component)); this._entity.scene.entityProcessors.onComponentAdded(this._entity); } - if (this._entity.scene.dynamicBatch) - this._entity.scene.dynamicInBatch(); }; ComponentList.prototype.updateLists = function () { if (this._componentsToRemove.length > 0) { @@ -4758,20 +3179,13 @@ var es; if (this._componentsToAdd.length > 0) { for (var i = 0, count = this._componentsToAdd.length; i < count; i++) { var component = this._componentsToAdd[i]; - if (component instanceof es.RenderableComponent) { - if (!this._entity.scene.dynamicBatch) - this._entity.scene.addChild(component.displayObject); - this._entity.scene.renderableComponents.add(component); - } - if (!this._entity.scene.dynamicBatch) - this._entity.scene.addChild(component.debugDisplayObject); + if (es.isIUpdatable(component)) + this._updatableComponents.add(component); this._entity.componentBits.set(es.ComponentTypeManager.getIndexFor(component)); this._entity.scene.entityProcessors.onComponentAdded(this._entity); this._components.add(component); this._tempBufferList.push(component); } - if (this._entity.scene.dynamicBatch) - this._entity.scene.dynamicInBatch(); this._componentsToAdd.length = 0; this._isComponentListUnsorted = true; for (var i = 0; i < this._tempBufferList.length; i++) { @@ -4784,20 +3198,15 @@ var es; this._tempBufferList.length = 0; } if (this._isComponentListUnsorted) { - this._components.sort(ComponentList.compareUpdatableOrder); + this._updatableComponents.sort(ComponentList.compareUpdatableOrder); this._isComponentListUnsorted = false; } }; ComponentList.prototype.handleRemove = function (component) { if (!component) return; - if (component instanceof es.RenderableComponent) { - if (component.displayObject.parent) - component.displayObject.parent.removeChild(component.displayObject); - this._entity.scene.renderableComponents.remove(component); - } - if (component.debugDisplayObject.parent) - component.debugDisplayObject.parent.removeChild(component.debugDisplayObject); + if (es.isIUpdatable(component)) + this._updatableComponents.remove(component); this._entity.componentBits.set(es.ComponentTypeManager.getIndexFor(component), false); this._entity.scene.entityProcessors.onComponentRemoved(this._entity); component.onRemovedFromEntity(); @@ -4823,40 +3232,23 @@ var es; components = []; for (var i = 0; i < this._components.length; i++) { var component = this._components.buffer[i]; - if (typeof (typeName) == "string") { - if (egret.is(component, typeName)) { - components.push(component); - } - } - else { - if (component instanceof typeName) { - components.push(component); - } + if (component instanceof typeName) { + components.push(component); } } for (var i = 0; i < this._componentsToAdd.length; i++) { var component = this._componentsToAdd[i]; - if (typeof (typeName) == "string") { - if (egret.is(component, typeName)) { - components.push(component); - } - } - else { - if (component instanceof typeName) { - components.push(component); - } + if (component instanceof typeName) { + components.push(component); } } return components; }; ComponentList.prototype.update = function () { this.updateLists(); - for (var i = 0; i < this._components.length; i++) { - var updatableComponent = this._components.buffer[i]; - if (updatableComponent.enabled && - (updatableComponent.updateInterval == 1 || - es.Time.frameCount % updatableComponent.updateInterval == 0)) - updatableComponent.update(); + for (var i = 0; i < this._updatableComponents.length; i++) { + if (this._updatableComponents.buffer[i].enabled) + this._updatableComponents.buffer[i].update(); } }; ComponentList.prototype.onEntityTransformChanged = function (comp) { @@ -5599,40 +3991,6 @@ var es; }()); es.Matcher = Matcher; })(es || (es = {})); -var ObjectUtils = (function () { - function ObjectUtils() { - } - ObjectUtils.clone = function (p, c) { - if (c === void 0) { c = null; } - var c = c || {}; - for (var i in p) { - if (typeof p[i] === 'object') { - c[i] = p[i] instanceof Array ? [] : {}; - this.clone(p[i], c[i]); - } - else { - c[i] = p[i]; - } - } - return c; - }; - ObjectUtils.elements = function (p) { - var c = []; - for (var i in p) { - if (Array.isArray(p[i])) { - for (var _i = 0, _a = p[i]; _i < _a.length; _i++) { - var v = _a[_i]; - c.push(v); - } - } - else { - c.push(p[i]); - } - } - return c; - }; - return ObjectUtils; -}()); var es; (function (es) { var RenderableComparer = (function () { @@ -5660,7 +4018,6 @@ var es; }, set: function (value) { this._componentsNeedSort = value; - es.Core.scene.sortableChildren = value; }, enumerable: true, configurable: true @@ -5883,136 +4240,6 @@ var StringUtils = (function () { return StringUtils; }()); var es; -(function (es) { - var TextureUtils = (function () { - function TextureUtils() { - } - TextureUtils.convertImageToCanvas = function (texture, rect) { - if (!this.sharedCanvas) { - this.sharedCanvas = egret.sys.createCanvas(); - this.sharedContext = this.sharedCanvas.getContext("2d"); - } - var w = texture.$getTextureWidth(); - var h = texture.$getTextureHeight(); - if (!rect) { - rect = egret.$TempRectangle; - rect.x = 0; - rect.y = 0; - rect.width = w; - rect.height = h; - } - rect.x = Math.min(rect.x, w - 1); - rect.y = Math.min(rect.y, h - 1); - rect.width = Math.min(rect.width, w - rect.x); - rect.height = Math.min(rect.height, h - rect.y); - var iWidth = Math.floor(rect.width); - var iHeight = Math.floor(rect.height); - var surface = this.sharedCanvas; - surface["style"]["width"] = iWidth + "px"; - surface["style"]["height"] = iHeight + "px"; - this.sharedCanvas.width = iWidth; - this.sharedCanvas.height = iHeight; - if (egret.Capabilities.renderMode == "webgl") { - var renderTexture = void 0; - if (!texture.$renderBuffer) { - if (egret.sys.systemRenderer["renderClear"]) { - egret.sys.systemRenderer["renderClear"](); - } - renderTexture = new egret.RenderTexture(); - renderTexture.drawToTexture(new egret.Bitmap(texture)); - } - else { - renderTexture = texture; - } - var pixels = renderTexture.$renderBuffer.getPixels(rect.x, rect.y, iWidth, iHeight); - var x = 0; - var y = 0; - for (var i = 0; i < pixels.length; i += 4) { - this.sharedContext.fillStyle = - 'rgba(' + pixels[i] - + ',' + pixels[i + 1] - + ',' + pixels[i + 2] - + ',' + (pixels[i + 3] / 255) + ')'; - this.sharedContext.fillRect(x, y, 1, 1); - x++; - if (x == iWidth) { - x = 0; - y++; - } - } - if (!texture.$renderBuffer) { - renderTexture.dispose(); - } - return surface; - } - else { - var bitmapData = texture; - var offsetX = Math.round(bitmapData.$offsetX); - var offsetY = Math.round(bitmapData.$offsetY); - var bitmapWidth = bitmapData.$bitmapWidth; - var bitmapHeight = bitmapData.$bitmapHeight; - var $TextureScaleFactor = es.Core._instance.stage.textureScaleFactor; - this.sharedContext.drawImage(bitmapData.$bitmapData.source, bitmapData.$bitmapX + rect.x / $TextureScaleFactor, bitmapData.$bitmapY + rect.y / $TextureScaleFactor, bitmapWidth * rect.width / w, bitmapHeight * rect.height / h, offsetX, offsetY, rect.width, rect.height); - return surface; - } - }; - TextureUtils.toDataURL = function (type, texture, rect, encoderOptions) { - try { - var surface = this.convertImageToCanvas(texture, rect); - var result = surface.toDataURL(type, encoderOptions); - return result; - } - catch (e) { - egret.$error(1033); - } - return null; - }; - TextureUtils.eliFoTevas = function (type, texture, filePath, rect, encoderOptions) { - var surface = this.convertImageToCanvas(texture, rect); - var result = surface.toTempFilePathSync({ - fileType: type.indexOf("png") >= 0 ? "png" : "jpg" - }); - wx.getFileSystemManager().saveFile({ - tempFilePath: result, - filePath: wx.env.USER_DATA_PATH + "/" + filePath, - success: function (res) { - } - }); - return result; - }; - TextureUtils.getPixel32 = function (texture, x, y) { - egret.$warn(1041, "getPixel32", "getPixels"); - return texture.getPixels(x, y); - }; - TextureUtils.getPixels = function (texture, x, y, width, height) { - if (width === void 0) { width = 1; } - if (height === void 0) { height = 1; } - if (egret.Capabilities.renderMode == "webgl") { - var renderTexture = void 0; - if (!texture.$renderBuffer) { - renderTexture = new egret.RenderTexture(); - renderTexture.drawToTexture(new egret.Bitmap(texture)); - } - else { - renderTexture = texture; - } - var pixels = renderTexture.$renderBuffer.getPixels(x, y, width, height); - return pixels; - } - try { - var surface = this.convertImageToCanvas(texture); - var result = this.sharedContext.getImageData(x, y, width, height).data; - return result; - } - catch (e) { - egret.$error(1039); - } - }; - return TextureUtils; - }()); - es.TextureUtils = TextureUtils; -})(es || (es = {})); -var es; (function (es) { var Time = (function () { function Time() { @@ -6193,81 +4420,6 @@ var TimeUtils = (function () { return TimeUtils; }()); var es; -(function (es) { - var Graphics = (function () { - function Graphics() { - var _this = this; - var arrayBuffer = new ArrayBuffer(1); - arrayBuffer[0] = 0xffffff; - egret.BitmapData.create("arraybuffer", arrayBuffer, function (bitmapData) { - var tex = new egret.Texture(); - tex.bitmapData = bitmapData; - _this.pixelTexture = new es.Sprite(tex); - }); - } - return Graphics; - }()); - es.Graphics = Graphics; -})(es || (es = {})); -var es; -(function (es) { - var GraphicsCapabilities = (function (_super) { - __extends(GraphicsCapabilities, _super); - function GraphicsCapabilities() { - return _super !== null && _super.apply(this, arguments) || this; - } - GraphicsCapabilities.prototype.initialize = function (device) { - this.platformInitialize(device); - }; - GraphicsCapabilities.prototype.platformInitialize = function (device) { - if (GraphicsCapabilities.runtimeType != egret.RuntimeType.WXGAME) - return; - var capabilities = this; - capabilities["isMobile"] = true; - var systemInfo = wx.getSystemInfoSync(); - var systemStr = systemInfo.system.toLowerCase(); - if (systemStr.indexOf("ios") > -1) { - capabilities["os"] = "iOS"; - } - else if (systemStr.indexOf("android") > -1) { - capabilities["os"] = "Android"; - } - var language = systemInfo.language; - if (language.indexOf('zh') > -1) { - language = "zh-CN"; - } - else { - language = "en-US"; - } - capabilities["language"] = language; - }; - return GraphicsCapabilities; - }(egret.Capabilities)); - es.GraphicsCapabilities = GraphicsCapabilities; -})(es || (es = {})); -var es; -(function (es) { - var GraphicsDevice = (function () { - function GraphicsDevice() { - this.setup(); - this.graphicsCapabilities = new es.GraphicsCapabilities(); - this.graphicsCapabilities.initialize(this); - } - Object.defineProperty(GraphicsDevice.prototype, "viewport", { - get: function () { - return this._viewport; - }, - enumerable: true, - configurable: true - }); - GraphicsDevice.prototype.setup = function () { - this._viewport = new es.Viewport(0, 0, es.Core._instance.stage.stageWidth, es.Core._instance.stage.stageHeight); - }; - return GraphicsDevice; - }()); - es.GraphicsDevice = GraphicsDevice; -})(es || (es = {})); -var es; (function (es) { var Viewport = (function () { function Viewport(x, y, width, height) { @@ -6325,147 +4477,6 @@ var es; es.Viewport = Viewport; })(es || (es = {})); var es; -(function (es) { - var GaussianBlurEffect = (function (_super) { - __extends(GaussianBlurEffect, _super); - function GaussianBlurEffect() { - return _super.call(this, es.PostProcessor.default_vert, GaussianBlurEffect.blur_frag, { - screenWidth: es.Core.graphicsDevice.viewport.width, - screenHeight: es.Core.graphicsDevice.viewport.height - }) || this; - } - GaussianBlurEffect.blur_frag = "precision mediump float;\n" + - "uniform sampler2D uSampler;\n" + - "uniform float screenWidth;\n" + - "uniform float screenHeight;\n" + - "float normpdf(in float x, in float sigma)\n" + - "{\n" + - "return 0.39894*exp(-0.5*x*x/(sigma*sigma))/sigma;\n" + - "}\n" + - "void main()\n" + - "{\n" + - "vec3 c = texture2D(uSampler, gl_FragCoord.xy / vec2(screenWidth, screenHeight).xy).rgb;\n" + - "const int mSize = 11;\n" + - "const int kSize = (mSize - 1)/2;\n" + - "float kernel[mSize];\n" + - "vec3 final_colour = vec3(0.0);\n" + - "float sigma = 7.0;\n" + - "float z = 0.0;\n" + - "for (int j = 0; j <= kSize; ++j)\n" + - "{\n" + - "kernel[kSize+j] = kernel[kSize-j] = normpdf(float(j),sigma);\n" + - "}\n" + - "for (int j = 0; j < mSize; ++j)\n" + - "{\n" + - "z += kernel[j];\n" + - "}\n" + - "for (int i = -kSize; i <= kSize; ++i)\n" + - "{\n" + - "for (int j = -kSize; j <= kSize; ++j)\n" + - "{\n" + - "final_colour += kernel[kSize+j]*kernel[kSize+i]*texture2D(uSampler, (gl_FragCoord.xy+vec2(float(i),float(j))) / vec2(screenWidth, screenHeight).xy).rgb;\n" + - "}\n}\n" + - "gl_FragColor = vec4(final_colour/(z*z), 1.0);\n" + - "}"; - return GaussianBlurEffect; - }(egret.CustomFilter)); - es.GaussianBlurEffect = GaussianBlurEffect; -})(es || (es = {})); -var es; -(function (es) { - var PolygonLightEffect = (function (_super) { - __extends(PolygonLightEffect, _super); - function PolygonLightEffect() { - return _super.call(this, PolygonLightEffect.vertSrc, PolygonLightEffect.fragmentSrc) || this; - } - PolygonLightEffect.vertSrc = "attribute vec2 aVertexPosition;\n" + - "attribute vec2 aTextureCoord;\n" + - "uniform vec2 projectionVector;\n" + - "varying vec2 vTextureCoord;\n" + - "const vec2 center = vec2(-1.0, 1.0);\n" + - "void main(void) {\n" + - " gl_Position = vec4( (aVertexPosition / projectionVector) + center , 0.0, 1.0);\n" + - " vTextureCoord = aTextureCoord;\n" + - "}"; - PolygonLightEffect.fragmentSrc = "precision lowp float;\n" + - "varying vec2 vTextureCoord;\n" + - "uniform sampler2D uSampler;\n" + - "#define SAMPLE_COUNT 15\n" + - "uniform vec2 _sampleOffsets[SAMPLE_COUNT];\n" + - "uniform float _sampleWeights[SAMPLE_COUNT];\n" + - "void main(void) {\n" + - "vec4 c = vec4(0, 0, 0, 0);\n" + - "for( int i = 0; i < SAMPLE_COUNT; i++ )\n" + - " c += texture2D( uSampler, vTextureCoord + _sampleOffsets[i] ) * _sampleWeights[i];\n" + - "gl_FragColor = c;\n" + - "}"; - return PolygonLightEffect; - }(egret.CustomFilter)); - es.PolygonLightEffect = PolygonLightEffect; -})(es || (es = {})); -var es; -(function (es) { - var PostProcessor = (function () { - function PostProcessor(effect) { - if (effect === void 0) { effect = null; } - this.enabled = true; - this.effect = effect; - } - PostProcessor.prototype.onAddedToScene = function (scene) { - this.scene = scene; - this.shape = new egret.Shape(); - this.shape.graphics.beginFill(0xFFFFFF, 1); - this.shape.graphics.drawRect(0, 0, es.Core.graphicsDevice.viewport.width, es.Core.graphicsDevice.viewport.height); - this.shape.graphics.endFill(); - scene.addChild(this.shape); - }; - PostProcessor.prototype.process = function () { - this.drawFullscreenQuad(); - }; - PostProcessor.prototype.onSceneBackBufferSizeChanged = function (newWidth, newHeight) { - }; - PostProcessor.prototype.unload = function () { - if (this.effect) { - this.effect = null; - } - this.scene.removeChild(this.shape); - this.scene = null; - }; - PostProcessor.prototype.drawFullscreenQuad = function () { - this.scene.filters = [this.effect]; - }; - PostProcessor.default_vert = "attribute vec2 aVertexPosition;\n" + - "attribute vec2 aTextureCoord;\n" + - "attribute vec2 aColor;\n" + - "uniform vec2 projectionVector;\n" + - "varying vec2 vTextureCoord;\n" + - "varying vec4 vColor;\n" + - "const vec2 center = vec2(-1.0, 1.0);\n" + - "void main(void) {\n" + - "gl_Position = vec4( (aVertexPosition / projectionVector) + center , 0.0, 1.0);\n" + - "vTextureCoord = aTextureCoord;\n" + - "vColor = vec4(aColor.x, aColor.x, aColor.x, aColor.x);\n" + - "}"; - return PostProcessor; - }()); - es.PostProcessor = PostProcessor; -})(es || (es = {})); -var es; -(function (es) { - var GaussianBlurPostProcessor = (function (_super) { - __extends(GaussianBlurPostProcessor, _super); - function GaussianBlurPostProcessor() { - return _super !== null && _super.apply(this, arguments) || this; - } - GaussianBlurPostProcessor.prototype.onAddedToScene = function (scene) { - _super.prototype.onAddedToScene.call(this, scene); - this.effect = new es.GaussianBlurEffect(); - }; - return GaussianBlurPostProcessor; - }(es.PostProcessor)); - es.GaussianBlurPostProcessor = GaussianBlurPostProcessor; -})(es || (es = {})); -var es; (function (es) { var Renderer = (function () { function Renderer(renderOrder, camera) { @@ -6475,13 +4486,6 @@ var es; this.camera = camera; this.renderOrder = renderOrder; } - Object.defineProperty(Renderer.prototype, "wantsToRenderToSceneRenderTarget", { - get: function () { - return !!this.renderTexture; - }, - enumerable: true, - configurable: true - }); Renderer.prototype.onAddedToScene = function (scene) { }; Renderer.prototype.unload = function () { @@ -6528,255 +4532,6 @@ var es; es.DefaultRenderer = DefaultRenderer; })(es || (es = {})); var es; -(function (es) { - var RenderLayerExcludeRenderer = (function (_super) { - __extends(RenderLayerExcludeRenderer, _super); - function RenderLayerExcludeRenderer(renderOrder) { - var excludedRenderLayers = []; - for (var _i = 1; _i < arguments.length; _i++) { - excludedRenderLayers[_i - 1] = arguments[_i]; - } - var _this = _super.call(this, renderOrder, null) || this; - _this.excludedRenderLayers = excludedRenderLayers; - return _this; - } - RenderLayerExcludeRenderer.prototype.render = function (scene) { - var cam = this.camera ? this.camera : scene.camera; - this.beginRender(cam); - for (var i = 0; i < scene.renderableComponents.count; i++) { - var renderable = scene.renderableComponents.buffer[i]; - if (!this.excludedRenderLayers.contains(renderable.renderLayer) && renderable.enabled && - renderable.isVisibleFromCamera(cam)) - this.renderAfterStateCheck(renderable, cam); - } - if (this.shouldDebugRender && es.Core.debugRenderEndabled) - this.debugRender(scene, cam); - }; - RenderLayerExcludeRenderer.prototype.debugRender = function (scene, cam) { - for (var i = 0; i < scene.renderableComponents.count; i++) { - var renderable = scene.renderableComponents.buffer[i]; - if (!this.excludedRenderLayers.contains(renderable.renderLayer) && renderable.enabled && - renderable.isVisibleFromCamera(cam)) - renderable.debugRender(cam); - } - _super.prototype.debugRender.call(this, scene, cam); - }; - return RenderLayerExcludeRenderer; - }(es.Renderer)); - es.RenderLayerExcludeRenderer = RenderLayerExcludeRenderer; -})(es || (es = {})); -var es; -(function (es) { - var ScreenSpaceRenderer = (function (_super) { - __extends(ScreenSpaceRenderer, _super); - function ScreenSpaceRenderer(renderOrder) { - var renderLayers = []; - for (var _i = 1; _i < arguments.length; _i++) { - renderLayers[_i - 1] = arguments[_i]; - } - var _this = _super.call(this, renderOrder, null) || this; - renderLayers.sort(); - renderLayers.reverse(); - _this.renderLayers = renderLayers; - return _this; - } - ScreenSpaceRenderer.prototype.render = function (scene) { - this.beginRender(this.camera); - for (var i = 0; i < this.renderLayers.length; i++) { - var renderables = scene.renderableComponents.componentsWithRenderLayer(this.renderLayers[i]); - for (var j = 0; j < renderables.length; j++) { - var renderable = renderables[j]; - if (renderable.enabled && renderable.isVisibleFromCamera(this.camera)) - this.renderAfterStateCheck(renderable, this.camera); - } - } - if (this.shouldDebugRender && es.Core.debugRenderEndabled) - this.debugRender(scene, this.camera); - }; - ScreenSpaceRenderer.prototype.debugRender = function (scene, cam) { - for (var i = 0; i < this.renderLayers.length; i++) { - var renderables = scene.renderableComponents.componentsWithRenderLayer(this.renderLayers[i]); - for (var j = 0; j < renderables.length; j++) { - var entity = renderables[j]; - if (entity.enabled) - entity.debugRender(cam); - } - } - }; - ScreenSpaceRenderer.prototype.onSceneBackBufferSizeChanged = function (newWidth, newHeight) { - _super.prototype.onSceneBackBufferSizeChanged.call(this, newWidth, newHeight); - if (!this.camera) - this.camera = es.Core.scene.createEntity("screenspace camera").addComponent(new es.Camera()); - }; - return ScreenSpaceRenderer; - }(es.Renderer)); - es.ScreenSpaceRenderer = ScreenSpaceRenderer; -})(es || (es = {})); -var es; -(function (es) { - var PolyLight = (function (_super) { - __extends(PolyLight, _super); - function PolyLight(radius, color, power) { - var _this = _super.call(this) || this; - _this._indices = []; - _this.radius = radius; - _this.power = power; - _this.color = color; - _this.computeTriangleIndices(); - return _this; - } - Object.defineProperty(PolyLight.prototype, "radius", { - get: function () { - return this._radius; - }, - set: function (value) { - this.setRadius(value); - }, - enumerable: true, - configurable: true - }); - PolyLight.prototype.setRadius = function (radius) { - if (radius != this._radius) { - this._radius = radius; - this._areBoundsDirty = true; - } - }; - PolyLight.prototype.render = function (camera) { - }; - PolyLight.prototype.reset = function () { - }; - PolyLight.prototype.computeTriangleIndices = function (totalTris) { - if (totalTris === void 0) { totalTris = 20; } - this._indices.length = 0; - for (var i = 0; i < totalTris; i += 2) { - this._indices.push(0); - this._indices.push(i + 2); - this._indices.push(i + 1); - } - }; - return PolyLight; - }(es.RenderableComponent)); - es.PolyLight = PolyLight; -})(es || (es = {})); -var es; -(function (es) { - var GaussianBlur = (function () { - function GaussianBlur() { - } - GaussianBlur.createBlurredTexture = function (image, deviation) { - if (deviation === void 0) { deviation = 1; } - var pixelData = image.getPixels(0, 0, image.textureWidth, image.textureHeight); - var srcData = new Array(image.textureWidth * image.textureHeight); - for (var i = 0; i < image.textureWidth; i++) { - for (var j = 0; j < image.textureHeight; j++) { - var width = image.textureWidth; - var r = pixelData[i * 4 + j * width]; - var g = pixelData[i * 4 + j * width + 1]; - var b = pixelData[i * 4 + j * width + 2]; - var a = pixelData[i * 4 + j * width + 3]; - srcData[i + j * width] = new es.Color(r, g, b, a); - } - } - var destData = this.createBlurredTextureData(srcData, image.textureWidth, image.textureHeight, deviation); - var arrayBuffer = new ArrayBuffer(destData.length); - destData.forEach(function (value, index) { - arrayBuffer[index] = value.packedValue; - }); - egret.BitmapData.create("arraybuffer", arrayBuffer, function (bitmapData) { - }); - }; - GaussianBlur.createBlurredTextureData = function (srcData, width, height, deviation) { - if (deviation === void 0) { deviation = 1; } - var matrixR = new es.FasterDictionary(); - var matrixG = new es.FasterDictionary(); - var matrixB = new es.FasterDictionary(); - var matrixA = new es.FasterDictionary(); - var destData = new Array(width * height); - for (var i = 0; i < width; i++) { - for (var j = 0; j < height; j++) { - matrixR.add({ x: i, y: j }, srcData[i + j * width].r); - matrixG.add({ x: i, y: j }, srcData[i + j * width].g); - matrixB.add({ x: i, y: j }, srcData[i + j * width].b); - matrixA.add({ x: i, y: j }, srcData[i + j * width].a); - } - } - matrixR = this.gaussianConvolution(matrixR, deviation); - matrixG = this.gaussianConvolution(matrixG, deviation); - matrixB = this.gaussianConvolution(matrixB, deviation); - matrixA = this.gaussianConvolution(matrixA, deviation); - for (var i = 0; i < width; i++) { - for (var j = 0; j < height; j++) { - var r = Math.min(255, matrixR.tryGetValue({ x: i, y: j })); - var g = Math.min(255, matrixG.tryGetValue({ x: i, y: j })); - var b = Math.min(255, matrixB.tryGetValue({ x: i, y: j })); - var a = Math.min(255, matrixA.tryGetValue({ x: i, y: j })); - destData[i + j * width] = new es.Color(r, g, b, a); - } - } - return destData; - }; - GaussianBlur.gaussianConvolution = function (matrix, deviation) { - var kernel = this.calculateNormalized1DSampleKernel(deviation); - var res1 = new es.FasterDictionary(); - var res2 = new es.FasterDictionary(); - for (var i = 0; i < matrix._valuesInfo.length; i++) { - for (var j = 0; j < matrix.valuesArray.length; j++) - res1.add({ x: i, y: j }, this.processPoint(matrix, i, j, kernel, 0)); - } - for (var i = 0; i < matrix._valuesInfo.length; i++) { - for (var j = 0; j < matrix.valuesArray.length; j++) - res2.add({ x: i, y: j }, this.processPoint(res1, i, j, kernel, 1)); - } - return res2; - }; - GaussianBlur.processPoint = function (matrix, x, y, kernel, direction) { - var res = 0; - var half = kernel._valuesInfo.length / 2; - for (var i = 0; i < kernel._valuesInfo.length; i++) { - var cox = direction == 0 ? x + i - half : x; - var coy = direction == 1 ? y + i - half : y; - if (cox >= 0 && cox < matrix._valuesInfo.length && coy >= 0 && coy < matrix.valuesArray.length) - res += matrix.tryGetValue({ x: cox, y: coy }) * kernel.tryGetValue({ x: i, y: 0 }); - } - return res; - }; - GaussianBlur.calculate1DSampleKernel = function (deviation) { - var size = Math.ceil(deviation * 3) * 3 + 1; - return this.calculate1DSampleKernelOfSize(deviation, size); - }; - GaussianBlur.calculate1DSampleKernelOfSize = function (deviation, size) { - var ret = new es.FasterDictionary(); - var half = (size - 1) / 2; - for (var i = 0; i < size; i++) { - ret.add({ x: i, y: 0 }, 1 / (Math.sqrt(2 * Math.PI) * deviation) * Math.exp(-(i - half) * (i - half) / (2 * deviation * deviation))); - } - return ret; - }; - GaussianBlur.calculateNormalized1DSampleKernel = function (deviation) { - return this.normalizeMatrix(this.calculate1DSampleKernel(deviation)); - }; - GaussianBlur.normalizeMatrix = function (matrix) { - var ret = new es.FasterDictionary(); - var sum = 0; - for (var i = 0; i < ret._valuesInfo.length; i++) { - for (var j = 0; j < ret.valuesArray.length; j++) { - sum += matrix.tryGetValue({ x: i, y: j }); - } - } - if (sum != 0) { - for (var i = 0; i < ret._valuesInfo.length; i++) { - for (var j = 0; j < ret.valuesArray.length; j++) { - ret.add({ x: i, y: j }, matrix.tryGetValue({ x: i, y: j }) / sum); - } - } - } - return ret; - }; - return GaussianBlur; - }()); - es.GaussianBlur = GaussianBlur; -})(es || (es = {})); -var es; (function (es) { var SceneTransition = (function () { function SceneTransition(sceneLoadAction) { @@ -6811,16 +4566,6 @@ var es; }); }); }; - SceneTransition.prototype.tickEffectProgressProperty = function (filter, duration, easeType, reverseDirection) { - if (reverseDirection === void 0) { reverseDirection = false; } - return new Promise(function (resolve) { - var start = reverseDirection ? 1 : 0; - var end = reverseDirection ? 0 : 1; - egret.Tween.get(filter.uniforms).set({ _progress: start }).to({ _progress: end }, duration * 1000, easeType).call(function () { - resolve(); - }); - }); - }; SceneTransition.prototype.transitionComplete = function () { es.Core._instance._sceneTransition = null; if (this.onTransitionCompleted) { @@ -6853,145 +4598,6 @@ var es; es.SceneTransition = SceneTransition; })(es || (es = {})); var es; -(function (es) { - var FadeTransition = (function (_super) { - __extends(FadeTransition, _super); - function FadeTransition(sceneLoadAction) { - var _this = _super.call(this, sceneLoadAction) || this; - _this.fadeToColor = 0x000000; - _this.fadeOutDuration = 0.4; - _this.fadeEaseType = egret.Ease.quadInOut; - _this.delayBeforeFadeInDuration = 0.1; - _this._alpha = 0; - _this._mask = new egret.Shape(); - return _this; - } - FadeTransition.prototype.onBeginTransition = function () { - return __awaiter(this, void 0, void 0, function () { - var _this = this; - return __generator(this, function (_a) { - if (!this._mask.parent) - es.Core.scene.stage.addChild(this._mask); - this._mask.graphics.beginFill(this.fadeToColor, 1); - this._mask.graphics.drawRect(0, 0, es.Core.graphicsDevice.viewport.width, es.Core.graphicsDevice.viewport.height); - this._mask.graphics.endFill(); - egret.Tween.get(this).to({ _alpha: 1 }, this.fadeOutDuration * 1000, this.fadeEaseType) - .call(function () { return __awaiter(_this, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4, this.loadNextScene()]; - case 1: - _a.sent(); - return [2]; - } - }); - }); }).wait(this.delayBeforeFadeInDuration).call(function () { - egret.Tween.get(_this).to({ _alpha: 0 }, _this.fadeOutDuration * 1000, _this.fadeEaseType).call(function () { - _this.transitionComplete(); - }); - }); - return [2]; - }); - }); - }; - FadeTransition.prototype.transitionComplete = function () { - _super.prototype.transitionComplete.call(this); - if (this._mask.parent) - this._mask.parent.removeChild(this._mask); - }; - FadeTransition.prototype.render = function () { - this._mask.graphics.clear(); - this._mask.graphics.beginFill(this.fadeToColor, this._alpha); - this._mask.graphics.drawRect(0, 0, es.Core.graphicsDevice.viewport.width, es.Core.graphicsDevice.viewport.height); - this._mask.graphics.endFill(); - }; - return FadeTransition; - }(es.SceneTransition)); - es.FadeTransition = FadeTransition; -})(es || (es = {})); -var es; -(function (es) { - var WindTransition = (function (_super) { - __extends(WindTransition, _super); - function WindTransition(sceneLoadAction) { - var _this = _super.call(this, sceneLoadAction) || this; - _this.duration = 1; - _this.easeType = egret.Ease.quadOut; - var vertexSrc = "attribute vec2 aVertexPosition;\n" + - "attribute vec2 aTextureCoord;\n" + - "uniform vec2 projectionVector;\n" + - "varying vec2 vTextureCoord;\n" + - "const vec2 center = vec2(-1.0, 1.0);\n" + - "void main(void) {\n" + - " gl_Position = vec4( (aVertexPosition / projectionVector) + center , 0.0, 1.0);\n" + - " vTextureCoord = aTextureCoord;\n" + - "}"; - var fragmentSrc = "precision lowp float;\n" + - "varying vec2 vTextureCoord;\n" + - "uniform sampler2D uSampler;\n" + - "uniform float _progress;\n" + - "uniform float _size;\n" + - "uniform float _windSegments;\n" + - "void main(void) {\n" + - "vec2 co = floor(vec2(0.0, vTextureCoord.y * _windSegments));\n" + - "float x = sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453;\n" + - "float r = x - floor(x);\n" + - "float m = smoothstep(0.0, -_size, vTextureCoord.x * (1.0 - _size) + _size * r - (_progress * (1.0 + _size)));\n" + - "vec4 fg = texture2D(uSampler, vTextureCoord);\n" + - "gl_FragColor = mix(fg, vec4(0, 0, 0, 0), m);\n" + - "}"; - _this._windEffect = new egret.CustomFilter(vertexSrc, fragmentSrc, { - _progress: 0, - _size: 0.3, - _windSegments: 100 - }); - _this._mask = new egret.Shape(); - _this._mask.graphics.beginFill(0xFFFFFF, 1); - _this._mask.graphics.drawRect(0, 0, es.Core.graphicsDevice.viewport.width, es.Core.graphicsDevice.viewport.height); - _this._mask.graphics.endFill(); - _this._mask.filters = [_this._windEffect]; - es.Core.scene.stage.addChild(_this._mask); - return _this; - } - Object.defineProperty(WindTransition.prototype, "windSegments", { - set: function (value) { - this._windEffect.uniforms._windSegments = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(WindTransition.prototype, "size", { - set: function (value) { - this._windEffect.uniforms._size = value; - }, - enumerable: true, - configurable: true - }); - WindTransition.prototype.onBeginTransition = function () { - return __awaiter(this, void 0, void 0, function () { - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - this.loadNextScene(); - return [4, this.tickEffectProgressProperty(this._windEffect, this.duration, this.easeType)]; - case 1: - _a.sent(); - this.transitionComplete(); - return [2]; - } - }); - }); - }; - WindTransition.prototype.transitionComplete = function () { - _super.prototype.transitionComplete.call(this); - if (this._mask.parent) - this._mask.parent.removeChild(this._mask); - }; - return WindTransition; - }(es.SceneTransition)); - es.WindTransition = WindTransition; -})(es || (es = {})); -var es; (function (es) { var Bezier = (function () { function Bezier() { @@ -7134,125 +4740,115 @@ var es; })(es || (es = {})); var es; (function (es) { - es.matrixPool = []; - var Matrix2D = (function (_super) { - __extends(Matrix2D, _super); - function Matrix2D() { - return _super !== null && _super.apply(this, arguments) || this; + var Matrix2D = (function () { + function Matrix2D(m11, m12, m21, m22, m31, m32) { + this.m11 = 0; + this.m12 = 0; + this.m21 = 0; + this.m22 = 0; + this.m31 = 0; + this.m32 = 0; + this.m11 = m11; + this.m12 = m12; + this.m21 = m21; + this.m22 = m22; + this.m31 = m31; + this.m32 = m32; } - Object.defineProperty(Matrix2D.prototype, "m11", { + Object.defineProperty(Matrix2D, "identity", { get: function () { - return this.a; - }, - set: function (value) { - this.a = value; + return this._identity; }, enumerable: true, configurable: true }); - Object.defineProperty(Matrix2D.prototype, "m12", { + Object.defineProperty(Matrix2D.prototype, "translation", { get: function () { - return this.b; + return new es.Vector2(this.m31, this.m32); }, set: function (value) { - this.b = value; + this.m31 = value.x; + this.m32 = value.y; }, enumerable: true, configurable: true }); - Object.defineProperty(Matrix2D.prototype, "m21", { + Object.defineProperty(Matrix2D.prototype, "rotation", { get: function () { - return this.c; + return Math.atan2(this.m21, this.m11); }, set: function (value) { - this.c = value; + var val1 = Math.cos(value); + var val2 = Math.sin(value); + this.m11 = val1; + this.m12 = val2; + this.m21 = -val2; + this.m22 = val1; }, enumerable: true, configurable: true }); - Object.defineProperty(Matrix2D.prototype, "m22", { + Object.defineProperty(Matrix2D.prototype, "rotationDegrees", { get: function () { - return this.d; + return es.MathHelper.toDegrees(this.rotation); }, set: function (value) { - this.d = value; + this.rotation = es.MathHelper.toRadians(value); }, enumerable: true, configurable: true }); - Object.defineProperty(Matrix2D.prototype, "m31", { + Object.defineProperty(Matrix2D.prototype, "scale", { get: function () { - return this.tx; + return new es.Vector2(this.m11, this.m22); }, set: function (value) { - this.tx = value; + this.m11 = value.x; + this.m22 = value.y; }, enumerable: true, configurable: true }); - Object.defineProperty(Matrix2D.prototype, "m32", { - get: function () { - return this.ty; - }, - set: function (value) { - this.ty = value; - }, - enumerable: true, - configurable: true - }); - Matrix2D.create = function () { - var matrix = es.matrixPool.pop(); - if (!matrix) - matrix = new Matrix2D(); - return matrix; + Matrix2D.createRotation = function (radians) { + var result = this.identity; + var val1 = Math.cos(radians); + var val2 = Math.sin(radians); + result.m11 = val1; + result.m12 = val2; + result.m21 = -val2; + result.m22 = val1; + return result; }; - Matrix2D.prototype.identity = function () { - this.a = this.d = 1; - this.b = this.c = this.tx = this.ty = 0; - return this; + Matrix2D.createScale = function (xScale, yScale) { + var result = this.identity; + result.m11 = xScale; + result.m12 = 0; + result.m21 = 0; + result.m22 = yScale; + result.m31 = 0; + result.m32 = 0; + return result; }; - Matrix2D.prototype.translate = function (dx, dy) { - this.tx += dx; - this.ty += dy; - return this; + Matrix2D.createTranslation = function (xPosition, yPosition) { + var result = this.identity; + result.m11 = 1; + result.m12 = 0; + result.m21 = 0; + result.m22 = 1; + result.m31 = xPosition; + result.m32 = yPosition; + return result; }; - Matrix2D.prototype.scale = function (sx, sy) { - if (sx !== 1) { - this.a *= sx; - this.c *= sx; - this.tx *= sx; - } - if (sy !== 1) { - this.b *= sy; - this.d *= sy; - this.ty *= sy; - } - return this; - }; - Matrix2D.prototype.rotate = function (angle) { - angle = +angle; - if (angle !== 0) { - angle = angle / DEG_TO_RAD; - var u = Math.cos(angle); - var v = Math.sin(angle); - var ta = this.a; - var tb = this.b; - var tc = this.c; - var td = this.d; - var ttx = this.tx; - var tty = this.ty; - this.a = ta * u - tb * v; - this.b = ta * v + tb * u; - this.c = tc * u - td * v; - this.d = tc * v + td * u; - this.tx = ttx * u - tty * v; - this.ty = ttx * v + tty * u; - } - return this; - }; - Matrix2D.prototype.invert = function () { - this.$invertInto(this); - return this; + Matrix2D.invert = function (matrix) { + var det = 1 / matrix.determinant(); + var result = this.identity; + result.m11 = matrix.m22 * det; + result.m12 = -matrix.m12 * det; + result.m21 = -matrix.m21 * det; + result.m22 = matrix.m11 * det; + result.m31 = (matrix.m32 * matrix.m21 - matrix.m31 * matrix.m22) * det; + result.m32 = -(matrix.m32 * matrix.m11 - matrix.m31 * matrix.m12) * det; + return result; }; Matrix2D.prototype.add = function (matrix) { this.m11 += matrix.m11; @@ -7299,22 +4895,164 @@ var es; Matrix2D.prototype.determinant = function () { return this.m11 * this.m22 - this.m12 * this.m21; }; - Matrix2D.prototype.release = function (matrix) { - if (!matrix) - return; - es.matrixPool.push(matrix); + Matrix2D.lerp = function (matrix1, matrix2, amount) { + matrix1.m11 = matrix1.m11 + ((matrix2.m11 - matrix1.m11) * amount); + matrix1.m12 = matrix1.m12 + ((matrix2.m12 - matrix1.m12) * amount); + matrix1.m21 = matrix1.m21 + ((matrix2.m21 - matrix1.m21) * amount); + matrix1.m22 = matrix1.m22 + ((matrix2.m22 - matrix1.m22) * amount); + matrix1.m31 = matrix1.m31 + ((matrix2.m31 - matrix1.m31) * amount); + matrix1.m32 = matrix1.m32 + ((matrix2.m32 - matrix1.m32) * amount); + return matrix1; }; + Matrix2D.transpose = function (matrix) { + var ret = this.identity; + ret.m11 = matrix.m11; + ret.m12 = matrix.m21; + ret.m21 = matrix.m12; + ret.m22 = matrix.m22; + ret.m31 = 0; + ret.m32 = 0; + return ret; + }; + Matrix2D.prototype.mutiplyTranslation = function (x, y) { + var trans = Matrix2D.createTranslation(x, y); + return es.MatrixHelper.mutiply(this, trans); + }; + Matrix2D.prototype.equals = function (other) { + return this == other; + }; + Matrix2D.prototype.toString = function () { + return "{m11:" + this.m11 + " m12:" + this.m12 + " m21:" + this.m21 + " m22:" + this.m22 + " m31:" + this.m31 + " m32:" + this.m32 + "}"; + }; + Matrix2D._identity = new Matrix2D(1, 0, 0, 1, 0, 0); return Matrix2D; - }(egret.Matrix)); + }()); es.Matrix2D = Matrix2D; })(es || (es = {})); var es; (function (es) { - var Rectangle = (function (_super) { - __extends(Rectangle, _super); - function Rectangle() { - return _super !== null && _super.apply(this, arguments) || this; + var MatrixHelper = (function () { + function MatrixHelper() { } + MatrixHelper.add = function (matrix1, matrix2) { + var result = es.Matrix2D.identity; + result.m11 = matrix1.m11 + matrix2.m11; + result.m12 = matrix1.m12 + matrix2.m12; + result.m21 = matrix1.m21 + matrix2.m21; + result.m22 = matrix1.m22 + matrix2.m22; + result.m31 = matrix1.m31 + matrix2.m31; + result.m32 = matrix1.m32 + matrix2.m32; + return result; + }; + MatrixHelper.divide = function (matrix1, matrix2) { + var result = es.Matrix2D.identity; + result.m11 = matrix1.m11 / matrix2.m11; + result.m12 = matrix1.m12 / matrix2.m12; + result.m21 = matrix1.m21 / matrix2.m21; + result.m22 = matrix1.m22 / matrix2.m22; + result.m31 = matrix1.m31 / matrix2.m31; + result.m32 = matrix1.m32 / matrix2.m32; + return result; + }; + MatrixHelper.mutiply = function (matrix1, matrix2) { + var result = es.Matrix2D.identity; + if (matrix2 instanceof es.Matrix2D) { + var m11 = (matrix1.m11 * matrix2.m11) + (matrix1.m12 * matrix2.m21); + var m12 = (matrix2.m11 * matrix2.m12) + (matrix1.m12 * matrix2.m22); + var m21 = (matrix1.m21 * matrix2.m11) + (matrix1.m22 * matrix2.m21); + var m22 = (matrix1.m21 * matrix2.m12) + (matrix1.m22 * matrix2.m22); + var m31 = (matrix1.m31 * matrix2.m11) + (matrix1.m32 * matrix2.m21) + matrix2.m31; + var m32 = (matrix1.m31 * matrix2.m12) + (matrix1.m32 * matrix2.m22) + matrix2.m32; + result.m11 = m11; + result.m12 = m12; + result.m21 = m21; + result.m22 = m22; + result.m31 = m31; + result.m32 = m32; + } + else if (typeof matrix2 == "number") { + result.m11 = matrix1.m11 * matrix2; + result.m12 = matrix1.m12 * matrix2; + result.m21 = matrix1.m21 * matrix2; + result.m22 = matrix1.m22 * matrix2; + result.m31 = matrix1.m31 * matrix2; + result.m32 = matrix1.m32 * matrix2; + } + return result; + }; + MatrixHelper.subtract = function (matrix1, matrix2) { + var result = es.Matrix2D.identity; + result.m11 = matrix1.m11 - matrix2.m11; + result.m12 = matrix1.m12 - matrix2.m12; + result.m21 = matrix1.m21 - matrix2.m21; + result.m22 = matrix1.m22 - matrix2.m22; + result.m31 = matrix1.m31 - matrix2.m31; + result.m32 = matrix1.m32 - matrix2.m32; + return result; + }; + return MatrixHelper; + }()); + es.MatrixHelper = MatrixHelper; +})(es || (es = {})); +var es; +(function (es) { + var Rectangle = (function () { + function Rectangle(x, y, width, height) { + if (x === void 0) { x = 0; } + if (y === void 0) { y = 0; } + if (width === void 0) { width = 0; } + if (height === void 0) { height = 0; } + this.x = 0; + this.y = 0; + this.width = 0; + this.height = 0; + this.x = x; + this.y = y; + this.width = width; + this.height = height; + } + Object.defineProperty(Rectangle, "empty", { + get: function () { + return this.emptyRectangle; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Rectangle, "maxRect", { + get: function () { + return new Rectangle(Number.MIN_VALUE / 2, Number.MIN_VALUE / 2, Number.MAX_VALUE, Number.MAX_VALUE); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Rectangle.prototype, "left", { + get: function () { + return this.x; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Rectangle.prototype, "right", { + get: function () { + return this.x + this.width; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Rectangle.prototype, "top", { + get: function () { + return this.y; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Rectangle.prototype, "bottom", { + get: function () { + return this.y + this.height; + }, + enumerable: true, + configurable: true + }); Object.defineProperty(Rectangle.prototype, "max", { get: function () { return new es.Vector2(this.right, this.bottom); @@ -7322,13 +5060,9 @@ var es; enumerable: true, configurable: true }); - Object.defineProperty(Rectangle.prototype, "center", { - get: function () { - return new es.Vector2(this.x + (this.width / 2), this.y + (this.height / 2)); - }, - enumerable: true, - configurable: true - }); + Rectangle.prototype.isEmpty = function () { + return ((((this.width == 0) && (this.height == 0)) && (this.x == 0)) && (this.y == 0)); + }; Object.defineProperty(Rectangle.prototype, "location", { get: function () { return new es.Vector2(this.x, this.y); @@ -7351,6 +5085,13 @@ var es; enumerable: true, configurable: true }); + Object.defineProperty(Rectangle.prototype, "center", { + get: function () { + return new es.Vector2(this.x + (this.width / 2), this.y + (this.height / 2)); + }, + enumerable: true, + configurable: true + }); Rectangle.fromMinMax = function (minX, minY, maxX, maxY) { return new Rectangle(minX, minY, maxX - minX, maxY - minY); }; @@ -7372,6 +5113,30 @@ var es; } return this.fromMinMax(minX, minY, maxX, maxY); }; + Rectangle.prototype.getSide = function (edge) { + switch (edge) { + case es.Edge.top: + return this.top; + case es.Edge.bottom: + return this.bottom; + case es.Edge.left: + return this.left; + case es.Edge.right: + return this.right; + default: + throw new Error("Argument Out Of Range"); + } + }; + 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.inflate = function (horizontalAmount, verticalAmount) { + this.x -= horizontalAmount; + this.y -= verticalAmount; + this.width += horizontalAmount * 2; + this.height += verticalAmount * 2; + }; Rectangle.prototype.intersects = function (value) { return value.left < this.right && this.left < value.right && @@ -7424,12 +5189,36 @@ 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); }; + Rectangle.prototype.getClosestPointOnBoundsToOrigin = function () { + var max = this.max; + var minDist = Math.abs(this.location.x); + var boundsPoint = new es.Vector2(this.location.x, 0); + if (Math.abs(max.x) < minDist) { + minDist = Math.abs(max.x); + boundsPoint.x = max.x; + boundsPoint.y = 0; + } + if (Math.abs(max.y) < minDist) { + minDist = Math.abs(max.y); + boundsPoint.x = 0; + boundsPoint.y = max.y; + } + if (Math.abs(this.location.y) < minDist) { + minDist = Math.abs(this.location.y); + boundsPoint.x = 0; + boundsPoint.y = this.location.y; + } + return boundsPoint; + }; + Rectangle.prototype.getClosestPointOnRectangleToPoint = function (point) { + var res = new es.Vector2(); + res.x = es.MathHelper.clamp(point.x, this.left, this.right); + res.y = es.MathHelper.clamp(point.y, this.top, this.bottom); + return res; + }; Rectangle.prototype.getClosestPointOnRectangleBorderToPoint = function (point, edgeNormal) { edgeNormal = es.Vector2.zero; var res = new es.Vector2(); @@ -7470,26 +5259,31 @@ var es; } return res; }; - Rectangle.prototype.getClosestPointOnBoundsToOrigin = function () { - var max = this.max; - var minDist = Math.abs(this.location.x); - var boundsPoint = new es.Vector2(this.location.x, 0); - if (Math.abs(max.x) < minDist) { - minDist = Math.abs(max.x); - boundsPoint.x = max.x; - boundsPoint.y = 0; + Rectangle.intersect = function (value1, value2) { + if (value1.intersects(value2)) { + var right_side = Math.min(value1.x + value1.width, value2.x + value2.width); + var left_side = Math.max(value1.x, value2.x); + var top_side = Math.max(value1.y, value2.y); + var bottom_side = Math.min(value1.y + value1.height, value2.y + value2.height); + return new Rectangle(left_side, top_side, right_side - left_side, bottom_side - top_side); } - if (Math.abs(max.y) < minDist) { - minDist = Math.abs(max.y); - boundsPoint.x = 0; - boundsPoint.y = max.y; + else { + return new Rectangle(0, 0, 0, 0); } - if (Math.abs(this.location.y) < minDist) { - minDist = Math.abs(this.location.y); - boundsPoint.x = 0; - boundsPoint.y = this.location.y; - } - return boundsPoint; + }; + Rectangle.prototype.offset = function (offsetX, offsetY) { + this.x += offsetX; + this.y += offsetY; + }; + Rectangle.union = function (value1, value2) { + var x = Math.min(value1.x, value2.x); + var y = Math.min(value1.y, value2.y); + return new Rectangle(x, y, Math.max(value1.right, value2.right) - x, Math.max(value1.bottom, value2.bottom) - y); + }; + Rectangle.overlap = function (value1, value2) { + var x = Math.max(Math.max(value1.x, value2.x), 0); + var y = Math.max(Math.max(value1.y, value2.y), 0); + return new Rectangle(x, y, Math.max(Math.min(value1.right, value2.right) - x, 0), Math.max(Math.min(value1.bottom, value2.bottom) - y, 0)); }; Rectangle.prototype.calculateBounds = function (parentPosition, position, origin, scale, rotation, width, height) { if (rotation == 0) { @@ -7501,12 +5295,12 @@ var es; else { var worldPosX = parentPosition.x + position.x; var worldPosY = parentPosition.y + position.y; - this._transformMat = es.Matrix2D.create().translate(-worldPosX - origin.x, -worldPosY - origin.y); - this._tempMat = es.Matrix2D.create().scale(scale.x, scale.y); + this._transformMat = es.Matrix2D.createTranslation(-worldPosX - origin.x, -worldPosY - origin.y); + this._tempMat = es.Matrix2D.createScale(scale.x, scale.y); this._transformMat = this._transformMat.multiply(this._tempMat); - this._tempMat = es.Matrix2D.create().rotate(rotation); + this._tempMat = es.Matrix2D.createRotation(rotation); this._transformMat = this._transformMat.multiply(this._tempMat); - this._tempMat = es.Matrix2D.create().translate(worldPosX, worldPosY); + this._tempMat = es.Matrix2D.createTranslation(worldPosX, worldPosY); this._transformMat = this._transformMat.multiply(this._tempMat); var topLeft = new es.Vector2(worldPosX, worldPosY); var topRight = new es.Vector2(worldPosX + width, worldPosY); @@ -7525,8 +5319,56 @@ var es; this.height = maxY - minY; } }; + Rectangle.prototype.getSweptBroadphaseBounds = function (deltaX, deltaY) { + var broadphasebox = Rectangle.empty; + broadphasebox.x = deltaX > 0 ? this.x : this.x + deltaX; + broadphasebox.y = deltaY > 0 ? this.y : this.y + deltaY; + broadphasebox.width = deltaX > 0 ? deltaX + this.width : this.width - deltaX; + broadphasebox.height = deltaY > 0 ? deltaY + this.height : this.height - deltaY; + return broadphasebox; + }; + Rectangle.prototype.collisionCheck = function (other, moveX, moveY) { + moveX.value = moveY.value = 0; + var l = other.x - (this.x + this.width); + var r = (other.x + other.width) - this.x; + var t = (other.y - (this.y + this.height)); + var b = (other.y + other.height) - this.y; + if (l > 0 || r < 0 || t > 0 || b < 0) + return false; + moveX.value = Math.abs(l) < r ? l : r; + moveY.value = Math.abs(t) < b ? t : b; + if (Math.abs(moveX.value) < Math.abs(moveY.value)) + moveY.value = 0; + else + moveX.value = 0; + return true; + }; + Rectangle.getIntersectionDepth = function (rectA, rectB) { + var halfWidthA = rectA.width / 2; + var halfHeightA = rectA.height / 2; + var halfWidthB = rectB.width / 2; + var halfHeightB = rectB.height / 2; + var centerA = new es.Vector2(rectA.left + halfWidthA, rectA.top + halfHeightA); + var centerB = new es.Vector2(rectB.left + halfWidthB, rectB.top + halfHeightB); + var distanceX = centerA.x - centerB.x; + var distanceY = centerA.y - centerB.y; + var minDistanceX = halfWidthA + halfWidthB; + var minDistanceY = halfHeightA + halfHeightB; + if (Math.abs(distanceX) >= minDistanceX || Math.abs(distanceY) >= minDistanceY) + return es.Vector2.zero; + var depthX = distanceX > 0 ? minDistanceX - distanceX : -minDistanceX - distanceX; + var depthY = distanceY > 0 ? minDistanceY - distanceY : -minDistanceY - distanceY; + return new es.Vector2(depthX, depthY); + }; + Rectangle.prototype.equals = function (other) { + return this === other; + }; + Rectangle.prototype.getHashCode = function () { + return (this.x ^ this.y ^ this.width ^ this.height); + }; + Rectangle.emptyRectangle = new Rectangle(); return Rectangle; - }(egret.Rectangle)); + }()); es.Rectangle = Rectangle; })(es || (es = {})); var es; @@ -7964,7 +5806,7 @@ var es; for (var x = p1.x; x <= p2.x; x++) { for (var y = p1.y; y <= p2.y; y++) { var c = this.cellAtPosition(x, y, true); - if (!c.firstOrDefault(function (c) { return c.hashCode == collider.hashCode; })) + if (!c.firstOrDefault(function (c) { return c == collider; })) c.push(collider); } } @@ -8013,7 +5855,7 @@ var es; if (collider == excludeCollider || !es.Flags.isFlagSet(layerMask, collider.physicsLayer.value)) return "continue"; if (bounds.intersects(collider.bounds)) { - if (!this_3._tempHashSet.firstOrDefault(function (c) { return c.hashCode == collider.hashCode; })) + if (!this_3._tempHashSet.firstOrDefault(function (c) { return c == collider; })) this_3._tempHashSet.push(collider); } }; @@ -8328,22 +6170,22 @@ var es; if (collider.shouldColliderScaleAndRotateWithTransform) { var hasUnitScale = true; var tempMat = void 0; - var combinedMatrix = es.Matrix2D.create().translate(-this._polygonCenter.x, -this._polygonCenter.y); + var combinedMatrix = es.Matrix2D.createTranslation(-this._polygonCenter.x, -this._polygonCenter.y); if (!collider.entity.transform.scale.equals(es.Vector2.one)) { - tempMat = es.Matrix2D.create().scale(collider.entity.transform.scale.x, collider.entity.transform.scale.y); + tempMat = es.Matrix2D.createScale(collider.entity.transform.scale.x, collider.entity.transform.scale.y); combinedMatrix = combinedMatrix.multiply(tempMat); hasUnitScale = false; this.center = es.Vector2.multiply(collider.localOffset, collider.entity.transform.scale); } if (collider.entity.transform.rotation != 0) { - tempMat = es.Matrix2D.create().rotate(collider.entity.transform.rotation); + tempMat = es.Matrix2D.createRotation(collider.entity.transform.rotation); combinedMatrix = combinedMatrix.multiply(tempMat); var offsetAngle = Math.atan2(collider.localOffset.y, collider.localOffset.x) * es.MathHelper.Rad2Deg; var offsetLength = hasUnitScale ? collider._localOffsetLength : es.Vector2.multiply(collider.localOffset, collider.entity.transform.scale).length(); this.center = es.MathHelper.pointOnCirlce(es.Vector2.zero, offsetLength, collider.entity.transform.rotationDegrees + offsetAngle); } - tempMat = es.Matrix2D.create().translate(this._polygonCenter.x, this._polygonCenter.y); + tempMat = es.Matrix2D.createTranslation(this._polygonCenter.x, this._polygonCenter.y); combinedMatrix = combinedMatrix.multiply(tempMat); es.Vector2Ext.transform(this._originalPoints, combinedMatrix, this.points); this.isUnrotated = collider.entity.transform.rotation == 0; @@ -9379,74 +7221,6 @@ var es; es.Color = Color; })(es || (es = {})); var es; -(function (es) { - var ContentManager = (function () { - function ContentManager() { - this.loadedAssets = new Map(); - } - ContentManager.prototype.loadRes = function (name, local) { - var _this = this; - if (local === void 0) { local = true; } - return new Promise(function (resolve, reject) { - var res = _this.loadedAssets.get(name); - if (res) { - resolve(res); - return; - } - if (local) { - RES.getResAsync(name).then(function (data) { - _this.loadedAssets.set(name, data); - resolve(data); - }).catch(function (err) { - console.error("资源加载错误:", name, err); - reject(err); - }); - } - else { - RES.getResByUrl(name).then(function (data) { - _this.loadedAssets.set(name, data); - resolve(data); - }).catch(function (err) { - console.error("资源加载错误:", name, err); - reject(err); - }); - } - }); - }; - ContentManager.prototype.dispose = function () { - this.loadedAssets.forEach(function (value) { - var assetsToRemove = value; - if (RES.destroyRes(assetsToRemove)) - assetsToRemove.dispose(); - }); - this.loadedAssets.clear(); - }; - return ContentManager; - }()); - es.ContentManager = ContentManager; -})(es || (es = {})); -var es; -(function (es) { - var DrawUtils = (function () { - function DrawUtils() { - } - DrawUtils.getColorMatrix = function (color) { - var colorMatrix = [ - 1, 0, 0, 0, 0, - 0, 1, 0, 0, 0, - 0, 0, 1, 0, 0, - 0, 0, 0, 1, 0 - ]; - colorMatrix[0] = Math.floor(color / 256 / 256) / 255; - colorMatrix[6] = Math.floor(color / 256 % 256) / 255; - colorMatrix[12] = color % 256 / 255; - return new egret.ColorMatrixFilter(colorMatrix); - }; - return DrawUtils; - }()); - es.DrawUtils = DrawUtils; -})(es || (es = {})); -var es; (function (es) { var EdgeExt = (function () { function EdgeExt() { @@ -9688,7 +7462,7 @@ var es; }; Pool.free = function (obj) { this._objectQueue.unshift(obj); - if (egret.is(obj, "IPoolable")) { + if (es.isIPoolable(obj)) { obj["reset"](); } }; @@ -9696,6 +7470,7 @@ var es; return Pool; }()); es.Pool = Pool; + es.isIPoolable = function (props) { return typeof props['js'] !== 'undefined'; }; })(es || (es = {})); var RandomUtils = (function () { function RandomUtils() { @@ -10014,70 +7789,6 @@ var WebGLUtils = (function () { }; return WebGLUtils; }()); -var es; -(function (es) { - var Layout = (function () { - function Layout() { - this.clientArea = new es.Rectangle(0, 0, es.Core.graphicsDevice.viewport.width, es.Core.graphicsDevice.viewport.height); - this.safeArea = this.clientArea; - } - Layout.prototype.place = function (size, horizontalMargin, verticalMargine, alignment) { - var rc = new es.Rectangle(0, 0, size.x, size.y); - if ((alignment & Alignment.left) != 0) { - rc.x = this.clientArea.x + (this.clientArea.width * horizontalMargin); - } - else if ((alignment & Alignment.right) != 0) { - rc.x = this.clientArea.x + (this.clientArea.width * (1 - horizontalMargin)) - rc.width; - } - else if ((alignment & Alignment.horizontalCenter) != 0) { - rc.x = this.clientArea.x + (this.clientArea.width - rc.width) / 2 + (horizontalMargin * this.clientArea.width); - } - else { - } - if ((alignment & Alignment.top) != 0) { - rc.y = this.clientArea.y + (this.clientArea.height * verticalMargine); - } - else if ((alignment & Alignment.bottom) != 0) { - rc.y = this.clientArea.y + (this.clientArea.height * (1 - verticalMargine)) - rc.height; - } - else if ((alignment & Alignment.verticalCenter) != 0) { - rc.y = this.clientArea.y + (this.clientArea.height - rc.height) / 2 + (verticalMargine * this.clientArea.height); - } - else { - } - if (rc.left < this.safeArea.left) - rc.x = this.safeArea.left; - if (rc.right > this.safeArea.right) - rc.x = this.safeArea.right - rc.width; - if (rc.top < this.safeArea.top) - rc.y = this.safeArea.top; - if (rc.bottom > this.safeArea.bottom) - rc.y = this.safeArea.bottom - rc.height; - return rc; - }; - return Layout; - }()); - es.Layout = Layout; - var Alignment; - (function (Alignment) { - Alignment[Alignment["none"] = 0] = "none"; - Alignment[Alignment["left"] = 1] = "left"; - Alignment[Alignment["right"] = 2] = "right"; - Alignment[Alignment["horizontalCenter"] = 4] = "horizontalCenter"; - Alignment[Alignment["top"] = 8] = "top"; - Alignment[Alignment["bottom"] = 16] = "bottom"; - Alignment[Alignment["verticalCenter"] = 32] = "verticalCenter"; - Alignment[Alignment["topLeft"] = 9] = "topLeft"; - Alignment[Alignment["topRight"] = 10] = "topRight"; - Alignment[Alignment["topCenter"] = 12] = "topCenter"; - Alignment[Alignment["bottomLeft"] = 17] = "bottomLeft"; - Alignment[Alignment["bottomRight"] = 18] = "bottomRight"; - Alignment[Alignment["bottomCenter"] = 20] = "bottomCenter"; - Alignment[Alignment["centerLeft"] = 33] = "centerLeft"; - Alignment[Alignment["centerRight"] = 34] = "centerRight"; - Alignment[Alignment["center"] = 36] = "center"; - })(Alignment = es.Alignment || (es.Alignment = {})); -})(es || (es = {})); var stopwatch; (function (stopwatch) { var Stopwatch = (function () { @@ -10210,1514 +7921,6 @@ var stopwatch; var _defaultSystemTimeGetter = Date.now; })(stopwatch || (stopwatch = {})); var es; -(function (es) { - var TimeRuler = (function () { - function TimeRuler() { - this.showLog = false; - this.markers = []; - this.stopwacth = new stopwatch.Stopwatch(); - this._markerNameToIdMap = new Map(); - this._rectShape1 = new egret.Shape(); - this._rectShape2 = new egret.Shape(); - this._rectShape3 = new egret.Shape(); - this._rectShape4 = new egret.Shape(); - this._rectShape5 = new egret.Shape(); - this._rectShape6 = new egret.Shape(); - this.logs = new Array(2); - for (var i = 0; i < this.logs.length; ++i) - this.logs[i] = new FrameLog(); - this.sampleFrames = this.targetSampleFrames = 1; - this.width = Math.floor(es.Core.graphicsDevice.viewport.width * 0.8); - es.Core.emitter.addObserver(es.CoreEvents.GraphicsDeviceReset, this.onGraphicsDeviceReset, this); - this.onGraphicsDeviceReset(); - es.Core.Instance.stage.addChild(this._rectShape1); - es.Core.Instance.stage.addChild(this._rectShape2); - es.Core.Instance.stage.addChild(this._rectShape3); - es.Core.Instance.stage.addChild(this._rectShape4); - es.Core.Instance.stage.addChild(this._rectShape5); - es.Core.Instance.stage.addChild(this._rectShape6); - } - Object.defineProperty(TimeRuler, "Instance", { - get: function () { - if (!this._instance) - this._instance = new TimeRuler(); - return this._instance; - }, - enumerable: true, - configurable: true - }); - TimeRuler.prototype.startFrame = function () { - if (isNaN(this._updateCount)) - this._updateCount = 0; - var count = this._updateCount++; - if (this.enabled && (1 < count && count < TimeRuler.maxSampleFrames)) - return; - this.prevLog = this.logs[this.frameCount++ & 0x1]; - this.curLog = this.logs[this.frameCount & 0x1]; - var endFrameTime = this.stopwacth.getTime(); - for (var barIdx = 0; barIdx < this.prevLog.bars.length; ++barIdx) { - var prevBar = this.prevLog.bars[barIdx]; - var nextBar = this.curLog.bars[barIdx]; - for (var nest = 0; nest < prevBar.nestCount; ++nest) { - var markerIdx = prevBar.markerNests[nest]; - prevBar.markers[markerIdx].endTime = endFrameTime; - nextBar.markerNests[nest] = nest; - nextBar.markers[nest].markerId = prevBar.markers[markerIdx].markerId; - nextBar.markers[nest].beginTime = 0; - nextBar.markers[nest].endTime = -1; - nextBar.markers[nest].color = prevBar.markers[markerIdx].color; - } - for (var markerIdx = 0; markerIdx < prevBar.markCount; ++markerIdx) { - var duration = prevBar.markers[markerIdx].endTime - prevBar.markers[markerIdx].beginTime; - var markerId = prevBar.markers[markerIdx].markerId; - var m = this.markers[markerId]; - m.logs[barIdx].color = prevBar.markers[markerIdx].color; - if (!m.logs[barIdx].initialized) { - m.logs[barIdx].min = duration; - m.logs[barIdx].max = duration; - m.logs[barIdx].avg = duration; - m.logs[barIdx].initialized = true; - } - else { - m.logs[barIdx].min = Math.min(m.logs[barIdx].min, duration); - m.logs[barIdx].max = Math.min(m.logs[barIdx].max, duration); - m.logs[barIdx].avg += duration; - m.logs[barIdx].avg *= 0.5; - if (m.logs[barIdx].samples++ >= TimeRuler.logSnapDuration) { - m.logs[barIdx].snapMin = m.logs[barIdx].min; - m.logs[barIdx].snapMax = m.logs[barIdx].max; - m.logs[barIdx].snapAvg = m.logs[barIdx].avg; - m.logs[barIdx].samples = 0; - } - } - } - nextBar.markCount = prevBar.nestCount; - nextBar.nestCount = prevBar.nestCount; - } - this.stopwacth.reset(); - this.stopwacth.start(); - }; - TimeRuler.prototype.beginMark = function (markerName, color, barIndex) { - if (barIndex === void 0) { barIndex = 0; } - if (barIndex < 0 || barIndex >= TimeRuler.maxBars) - throw new Error("barIndex argument out of range"); - var bar = this.curLog.bars[barIndex]; - if (bar.markCount >= TimeRuler.maxSamples) { - throw new Error("超出采样次数,可以设置更大的数字为timeruler.maxsaple,或者降低采样次数"); - } - if (bar.nestCount >= TimeRuler.maxNestCall) { - throw new Error("超出采样次数,可以设置更大的数字为timeruler.maxsaple,或者降低采样次数"); - } - var markerId = this._markerNameToIdMap.get(markerName); - if (isNaN(markerId)) { - markerId = this.markers.length; - this._markerNameToIdMap.set(markerName, markerId); - this.markers.push(new MarkerInfo(markerName)); - } - bar.markerNests[bar.nestCount++] = bar.markCount; - bar.markers[bar.markCount].markerId = markerId; - bar.markers[bar.markCount].color = color; - bar.markers[bar.markCount].beginTime = this.stopwacth.getTime(); - bar.markers[bar.markCount].endTime = -1; - bar.markCount++; - }; - TimeRuler.prototype.endMark = function (markerName, barIndex) { - if (barIndex === void 0) { barIndex = 0; } - if (barIndex < 0 || barIndex >= TimeRuler.maxBars) - throw new Error("barIndex参数超出范围"); - var bar = this.curLog.bars[barIndex]; - if (bar.nestCount <= 0) { - throw new Error("先调用beginMark方法,再调用endMark方法"); - } - var markerId = this._markerNameToIdMap.get(markerName); - if (isNaN(markerId)) { - throw new Error("\u6807\u8BB0 " + markerName + " \u672A\u6CE8\u518C\u3002\u8BF7\u786E\u8BA4\u60A8\u6307\u5B9A\u7684\u540D\u79F0\u4E0E beginMark \u65B9\u6CD5\u4F7F\u7528\u7684\u540D\u79F0\u76F8\u540C"); - } - var markerIdx = bar.markerNests[--bar.nestCount]; - if (bar.markers[markerIdx].markerId != markerId) { - throw new Error("beginMark/endMark方法的调用顺序不正确,beginMark(A),beginMark(B),endMark(B),endMark(A),但你不能像beginMark(A),beginMark(B),endMark(A),endMark(B)这样调用。"); - } - bar.markers[markerIdx].endTime = this.stopwacth.getTime(); - }; - TimeRuler.prototype.getAverageTime = function (barIndex, markerName) { - if (barIndex < 0 || barIndex >= TimeRuler.maxBars) { - throw new Error("barIndex参数超出范围"); - } - var result = 0; - var markerId = this._markerNameToIdMap.get(markerName); - if (markerId) { - result = this.markers[markerId].logs[barIndex].avg; - } - return result; - }; - TimeRuler.prototype.resetLog = function () { - this.markers.forEach(function (markerInfo) { - for (var i = 0; i < markerInfo.logs.length; ++i) { - markerInfo.logs[i].initialized = false; - markerInfo.logs[i].snapMin = 0; - markerInfo.logs[i].snapMax = 0; - markerInfo.logs[i].snapAvg = 0; - markerInfo.logs[i].min = 0; - markerInfo.logs[i].max = 0; - markerInfo.logs[i].avg = 0; - markerInfo.logs[i].samples = 0; - } - }); - }; - TimeRuler.prototype.render = function (position, width) { - if (position === void 0) { position = this._position; } - if (width === void 0) { width = this.width; } - if (!this.showLog) - return; - var height = 0; - var maxTime = 0; - this.prevLog.bars.forEach(function (bar) { - if (bar.markCount > 0) { - height += TimeRuler.barHeight + TimeRuler.barPadding * 2; - maxTime = Math.max(maxTime, bar.markers[bar.markCount - 1].endTime); - } - }); - var frameSpan = 1 / 60 * 1000; - var sampleSpan = this.sampleFrames * frameSpan; - if (maxTime > sampleSpan) { - this._frameAdjust = Math.max(0, this._frameAdjust) + 1; - } - else { - this._frameAdjust = Math.min(0, this._frameAdjust) - 1; - } - if (Math.max(this._frameAdjust) > TimeRuler.autoAdjustDelay) { - this.sampleFrames = Math.min(TimeRuler.maxSampleFrames, this.sampleFrames); - this.sampleFrames = Math.max(this.targetSampleFrames, Math.floor(maxTime / frameSpan) + 1); - this._frameAdjust = 0; - } - var msToPs = width / sampleSpan; - var startY = position.y - (height - TimeRuler.barHeight); - var y = startY; - var rc = new es.Rectangle(position.x, y, width, height); - this._rectShape1.graphics.clear(); - this._rectShape1.graphics.beginFill(0x000000, 128 / 255); - this._rectShape1.graphics.drawRect(rc.x, rc.y, rc.width, rc.height); - this._rectShape1.graphics.endFill(); - rc.height = TimeRuler.barHeight; - this._rectShape2.graphics.clear(); - for (var _i = 0, _a = this.prevLog.bars; _i < _a.length; _i++) { - var bar = _a[_i]; - rc.y = y + TimeRuler.barPadding; - if (bar.markCount > 0) { - for (var j = 0; j < bar.markCount; ++j) { - var bt = bar.markers[j].beginTime; - var et = bar.markers[j].endTime; - var sx = Math.floor(position.x + bt * msToPs); - var ex = Math.floor(position.x + et * msToPs); - rc.x = sx; - rc.width = Math.max(ex - sx, 1); - this._rectShape2.graphics.beginFill(bar.markers[j].color); - this._rectShape2.graphics.drawRect(rc.x, rc.y, rc.width, rc.height); - this._rectShape2.graphics.endFill(); - } - } - y += TimeRuler.barHeight + TimeRuler.barPadding; - } - rc = new es.Rectangle(position.x, startY, 1, height); - this._rectShape3.graphics.clear(); - for (var t = 1; t < sampleSpan; t += 1) { - rc.x = Math.floor(position.x + t * msToPs); - this._rectShape3.graphics.beginFill(0x808080); - this._rectShape3.graphics.drawRect(rc.x, rc.y, rc.width, rc.height); - this._rectShape3.graphics.endFill(); - } - this._rectShape4.graphics.clear(); - for (var i = 0; i <= this.sampleFrames; ++i) { - rc.x = Math.floor(position.x + frameSpan * i * msToPs); - this._rectShape4.graphics.beginFill(0xFFFFFF); - this._rectShape4.graphics.drawRect(rc.x, rc.y, rc.width, rc.height); - this._rectShape4.graphics.endFill(); - } - }; - TimeRuler.prototype.onGraphicsDeviceReset = function () { - var layout = new es.Layout(); - this._position = layout.place(new es.Vector2(this.width, TimeRuler.barHeight), 0, 0.01, es.Alignment.bottomCenter).location; - }; - TimeRuler.maxBars = 8; - TimeRuler.maxSamples = 256; - TimeRuler.maxNestCall = 32; - TimeRuler.barHeight = 8; - TimeRuler.maxSampleFrames = 4; - TimeRuler.logSnapDuration = 120; - TimeRuler.barPadding = 2; - TimeRuler.autoAdjustDelay = 30; - return TimeRuler; - }()); - es.TimeRuler = TimeRuler; - var FrameLog = (function () { - function FrameLog() { - this.bars = new Array(TimeRuler.maxBars); - this.bars.fill(new MarkerCollection(), 0, TimeRuler.maxBars); - } - return FrameLog; - }()); - es.FrameLog = FrameLog; - var MarkerCollection = (function () { - function MarkerCollection() { - this.markers = new Array(TimeRuler.maxSamples); - this.markCount = 0; - this.markerNests = new Array(TimeRuler.maxNestCall); - this.nestCount = 0; - this.markers.fill(new Marker(), 0, TimeRuler.maxSamples); - this.markerNests.fill(0, 0, TimeRuler.maxNestCall); - } - return MarkerCollection; - }()); - es.MarkerCollection = MarkerCollection; - var Marker = (function () { - function Marker() { - this.markerId = 0; - this.beginTime = 0; - this.endTime = 0; - this.color = 0x000000; - } - return Marker; - }()); - es.Marker = Marker; - var MarkerInfo = (function () { - function MarkerInfo(name) { - this.logs = new Array(TimeRuler.maxBars); - this.name = name; - this.logs.fill(new MarkerLog(), 0, TimeRuler.maxBars); - } - return MarkerInfo; - }()); - es.MarkerInfo = MarkerInfo; - var MarkerLog = (function () { - function MarkerLog() { - this.snapMin = 0; - this.snapMax = 0; - this.snapAvg = 0; - this.min = 0; - this.max = 0; - this.avg = 0; - this.samples = 0; - this.color = 0x000000; - this.initialized = false; - } - return MarkerLog; - }()); - es.MarkerLog = MarkerLog; -})(es || (es = {})); -var es; -(function (es) { - var Coroutine = (function () { - function Coroutine() { - } - Coroutine.waitForSeconds = function (seconds) { - return WaitForSeconds.waiter.wait(seconds); - }; - return Coroutine; - }()); - es.Coroutine = Coroutine; - var WaitForSeconds = (function () { - function WaitForSeconds() { - } - WaitForSeconds.prototype.wait = function (seconds) { - WaitForSeconds.waiter.waitTime = seconds; - return WaitForSeconds.waiter; - }; - WaitForSeconds.waiter = new WaitForSeconds(); - return WaitForSeconds; - }()); - es.WaitForSeconds = WaitForSeconds; -})(es || (es = {})); -var es; -(function (es) { - var CoroutineImpl = (function () { - function CoroutineImpl() { - this.useUnscaledDeltaTime = false; - } - CoroutineImpl.prototype.stop = function () { - this.isDone = true; - }; - CoroutineImpl.prototype.setUseUnscaledDeltaTime = function (useUnscaledDeltaTime) { - this.useUnscaledDeltaTime = useUnscaledDeltaTime; - return this; - }; - CoroutineImpl.prototype.prepareForuse = function () { - this.isDone = false; - }; - CoroutineImpl.prototype.reset = function () { - this.isDone = true; - this.waitTimer = 0; - this.waitForCoroutine = null; - this.enumerator = null; - this.useUnscaledDeltaTime = false; - }; - return CoroutineImpl; - }()); - es.CoroutineImpl = CoroutineImpl; - var CoroutineManager = (function (_super) { - __extends(CoroutineManager, _super); - function CoroutineManager() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this._unblockedCoroutines = []; - _this._shouldRunNextFrame = []; - return _this; - } - CoroutineManager.prototype.startCoroutine = function (enumerator) { - var coroutine = es.Pool.obtain(CoroutineImpl); - coroutine.prepareForuse(); - coroutine.enumerator = enumerator; - var shouldContinueCoroutine = this.tickCoroutine(coroutine); - if (!shouldContinueCoroutine) - return null; - if (this._isInUpdate) - this._shouldRunNextFrame.push(coroutine); - else - this._unblockedCoroutines.push(coroutine); - return coroutine; - }; - CoroutineManager.prototype.update = function () { - this._isInUpdate = true; - for (var i = 0; i < this._unblockedCoroutines.length; i++) { - var coroutine = this._unblockedCoroutines[i]; - if (coroutine.isDone) { - es.Pool.free(coroutine); - continue; - } - if (coroutine.waitForCoroutine != null) { - if (coroutine.waitForCoroutine.isDone) { - coroutine.waitForCoroutine = null; - } - else { - this._shouldRunNextFrame.push(coroutine); - continue; - } - } - if (coroutine.waitTimer > 0) { - coroutine.waitTimer -= coroutine.useUnscaledDeltaTime ? es.Time.unscaledDeltaTime : es.Time.deltaTime; - this._shouldRunNextFrame.push(coroutine); - continue; - } - if (this.tickCoroutine(coroutine)) - this._shouldRunNextFrame.push(coroutine); - } - this._unblockedCoroutines.length = 0; - this._unblockedCoroutines.concat(this._shouldRunNextFrame); - this._shouldRunNextFrame.length = 0; - this._isInUpdate = false; - }; - CoroutineManager.prototype.tickCoroutine = function (coroutine) { - var current = coroutine.enumerator.next(); - if (!current.value || current.done) { - es.Pool.free(coroutine); - return false; - } - if (!current.value) { - return true; - } - if (current.value instanceof es.WaitForSeconds) { - coroutine.waitTimer = current.value.waitTime; - return true; - } - if (current.value instanceof Number) { - console.warn("协同程序检查返回一个Number类型,请不要在生产环境使用"); - coroutine.waitTimer = Number(current); - return true; - } - if (current.value instanceof CoroutineImpl) { - coroutine.waitForCoroutine = current.value; - return true; - } - else { - return true; - } - }; - return CoroutineManager; - }(es.GlobalManager)); - es.CoroutineManager = CoroutineManager; -})(es || (es = {})); -var es; -(function (es) { - var TouchState = (function () { - function TouchState() { - this.x = 0; - this.y = 0; - this.touchPoint = -1; - this.touchDown = false; - } - Object.defineProperty(TouchState.prototype, "position", { - get: function () { - return new es.Vector2(this.x, this.y); - }, - enumerable: true, - configurable: true - }); - TouchState.prototype.reset = function () { - this.x = 0; - this.y = 0; - this.touchDown = false; - this.touchPoint = -1; - }; - return TouchState; - }()); - es.TouchState = TouchState; - var Input = (function () { - function Input() { - } - Object.defineProperty(Input, "gameTouchs", { - get: function () { - return this._gameTouchs; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Input, "resolutionScale", { - get: function () { - return this._resolutionScale; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Input, "totalTouchCount", { - get: function () { - return this._totalTouchCount; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Input, "touchPosition", { - get: function () { - if (!this._gameTouchs[0]) - return es.Vector2.zero; - return this._gameTouchs[0].position; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Input, "maxSupportedTouch", { - get: function () { - return es.Core._instance.stage.maxTouches; - }, - set: function (value) { - es.Core._instance.stage.maxTouches = value; - this.initTouchCache(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Input, "touchPositionDelta", { - get: function () { - var delta = es.Vector2.subtract(this.touchPosition, this._previousTouchState.position); - if (delta.length() > 0) { - this.setpreviousTouchState(this._gameTouchs[0]); - } - return delta; - }, - enumerable: true, - configurable: true - }); - Input.initialize = function () { - if (this._init) - return; - this._init = true; - es.Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.touchBegin, this); - es.Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_MOVE, this.touchMove, this); - es.Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_END, this.touchEnd, this); - es.Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_CANCEL, this.touchEnd, this); - es.Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_RELEASE_OUTSIDE, this.touchEnd, this); - this.initTouchCache(); - }; - Input.update = function () { - KeyboardUtils.update(); - for (var i = 0; i < this._virtualInputs.length; i++) - this._virtualInputs[i].update(); - }; - Input.scaledPosition = function (position) { - var scaledPos = new es.Vector2(position.x - this._resolutionOffset.x, position.y - this._resolutionOffset.y); - return es.Vector2.multiply(scaledPos, this.resolutionScale); - }; - Input.isKeyPressed = function (key) { - return KeyboardUtils.currentKeys.contains(key) && !KeyboardUtils.previousKeys.contains(key); - }; - Input.isKeyPressedBoth = function (keyA, keyB) { - return this.isKeyPressed(keyA) || this.isKeyPressed(keyB); - }; - Input.isKeyDown = function (key) { - return KeyboardUtils.currentKeys.contains(key); - }; - Input.isKeyDownBoth = function (keyA, keyB) { - return this.isKeyDown(keyA) || this.isKeyDown(keyB); - }; - Input.isKeyReleased = function (key) { - return !KeyboardUtils.currentKeys.contains(key) && KeyboardUtils.previousKeys.contains(key); - }; - Input.isKeyReleasedBoth = function (keyA, keyB) { - return this.isKeyReleased(keyA) || this.isKeyReleased(keyB); - }; - Input.initTouchCache = function () { - this._totalTouchCount = 0; - this._touchIndex = 0; - this._gameTouchs.length = 0; - for (var i = 0; i < this.maxSupportedTouch; i++) { - this._gameTouchs.push(new TouchState()); - } - }; - Input.touchBegin = function (evt) { - if (this._touchIndex < this.maxSupportedTouch) { - this._gameTouchs[this._touchIndex].touchPoint = evt.touchPointID; - this._gameTouchs[this._touchIndex].touchDown = evt.touchDown; - this._gameTouchs[this._touchIndex].x = evt.stageX; - this._gameTouchs[this._touchIndex].y = evt.stageY; - if (this._touchIndex == 0) { - this.setpreviousTouchState(this._gameTouchs[0]); - } - this._touchIndex++; - this._totalTouchCount++; - } - }; - Input.touchMove = function (evt) { - if (evt.touchPointID == this._gameTouchs[0].touchPoint) { - this.setpreviousTouchState(this._gameTouchs[0]); - } - var touchIndex = this._gameTouchs.findIndex(function (touch) { return touch.touchPoint == evt.touchPointID; }); - if (touchIndex != -1) { - var touchData = this._gameTouchs[touchIndex]; - touchData.x = evt.stageX; - touchData.y = evt.stageY; - } - }; - Input.touchEnd = function (evt) { - var touchIndex = this._gameTouchs.findIndex(function (touch) { return touch.touchPoint == evt.touchPointID; }); - if (touchIndex != -1) { - var touchData = this._gameTouchs[touchIndex]; - touchData.reset(); - if (touchIndex == 0) - this._previousTouchState.reset(); - this._totalTouchCount--; - if (this.totalTouchCount == 0) { - this._touchIndex = 0; - } - } - }; - Input.setpreviousTouchState = function (touchState) { - this._previousTouchState = new TouchState(); - this._previousTouchState.x = touchState.position.x; - this._previousTouchState.y = touchState.position.y; - this._previousTouchState.touchPoint = touchState.touchPoint; - this._previousTouchState.touchDown = touchState.touchDown; - }; - Input._init = false; - Input._previousTouchState = new TouchState(); - Input._resolutionOffset = new es.Vector2(); - Input._touchIndex = 0; - Input._gameTouchs = []; - Input._resolutionScale = es.Vector2.one; - Input._totalTouchCount = 0; - Input._virtualInputs = []; - return Input; - }()); - es.Input = Input; -})(es || (es = {})); -var Keys = es.Keys; -var KeyboardUtils = (function () { - function KeyboardUtils() { - } - KeyboardUtils.init = function () { - document.addEventListener("keydown", KeyboardUtils.onKeyDownHandler); - document.addEventListener("keyup", KeyboardUtils.onKeyUpHandler); - }; - KeyboardUtils.update = function () { - KeyboardUtils.previousKeys.length = 0; - for (var _i = 0, _a = KeyboardUtils.currentKeys; _i < _a.length; _i++) { - var key = _a[_i]; - KeyboardUtils.previousKeys.push(key); - KeyboardUtils.currentKeys.remove(key); - } - KeyboardUtils.currentKeys.length = 0; - for (var _b = 0, _c = KeyboardUtils.keyStatusKeys; _b < _c.length; _b++) { - var key = _c[_b]; - KeyboardUtils.currentKeys.push(key); - } - }; - KeyboardUtils.destroy = function () { - KeyboardUtils.currentKeys.length = 0; - document.removeEventListener("keyup", KeyboardUtils.onKeyUpHandler); - document.removeEventListener("keypress", KeyboardUtils.onKeyDownHandler); - }; - KeyboardUtils.onKeyDownHandler = function (event) { - if (!KeyboardUtils.keyStatusKeys.contains(event.keyCode)) - KeyboardUtils.keyStatusKeys.push(event.keyCode); - }; - KeyboardUtils.onKeyUpHandler = function (event) { - if (KeyboardUtils.keyStatusKeys.contains(event.keyCode)) - KeyboardUtils.keyStatusKeys.remove(event.keyCode); - }; - KeyboardUtils.currentKeys = []; - KeyboardUtils.previousKeys = []; - KeyboardUtils.keyStatusKeys = []; - return KeyboardUtils; -}()); -var es; -(function (es) { - var Keys; - (function (Keys) { - Keys[Keys["none"] = 0] = "none"; - Keys[Keys["back"] = 8] = "back"; - Keys[Keys["tab"] = 9] = "tab"; - Keys[Keys["enter"] = 13] = "enter"; - Keys[Keys["capsLock"] = 20] = "capsLock"; - Keys[Keys["escape"] = 27] = "escape"; - Keys[Keys["space"] = 32] = "space"; - Keys[Keys["pageUp"] = 33] = "pageUp"; - Keys[Keys["pageDown"] = 34] = "pageDown"; - Keys[Keys["end"] = 35] = "end"; - Keys[Keys["home"] = 36] = "home"; - Keys[Keys["left"] = 37] = "left"; - Keys[Keys["up"] = 38] = "up"; - Keys[Keys["right"] = 39] = "right"; - Keys[Keys["down"] = 40] = "down"; - Keys[Keys["select"] = 41] = "select"; - Keys[Keys["print"] = 42] = "print"; - Keys[Keys["execute"] = 43] = "execute"; - Keys[Keys["printScreen"] = 44] = "printScreen"; - Keys[Keys["insert"] = 45] = "insert"; - Keys[Keys["delete"] = 46] = "delete"; - Keys[Keys["help"] = 47] = "help"; - Keys[Keys["d0"] = 48] = "d0"; - Keys[Keys["d1"] = 49] = "d1"; - Keys[Keys["d2"] = 50] = "d2"; - Keys[Keys["d3"] = 51] = "d3"; - Keys[Keys["d4"] = 52] = "d4"; - Keys[Keys["d5"] = 53] = "d5"; - Keys[Keys["d6"] = 54] = "d6"; - Keys[Keys["d7"] = 55] = "d7"; - Keys[Keys["d8"] = 56] = "d8"; - Keys[Keys["d9"] = 57] = "d9"; - Keys[Keys["a"] = 65] = "a"; - Keys[Keys["b"] = 66] = "b"; - Keys[Keys["c"] = 67] = "c"; - Keys[Keys["d"] = 68] = "d"; - Keys[Keys["e"] = 69] = "e"; - Keys[Keys["f"] = 70] = "f"; - Keys[Keys["g"] = 71] = "g"; - Keys[Keys["h"] = 72] = "h"; - Keys[Keys["i"] = 73] = "i"; - Keys[Keys["j"] = 74] = "j"; - Keys[Keys["k"] = 75] = "k"; - Keys[Keys["l"] = 76] = "l"; - Keys[Keys["m"] = 77] = "m"; - Keys[Keys["n"] = 78] = "n"; - Keys[Keys["o"] = 79] = "o"; - Keys[Keys["p"] = 80] = "p"; - Keys[Keys["q"] = 81] = "q"; - Keys[Keys["r"] = 82] = "r"; - Keys[Keys["s"] = 83] = "s"; - Keys[Keys["t"] = 84] = "t"; - Keys[Keys["u"] = 85] = "u"; - Keys[Keys["v"] = 86] = "v"; - Keys[Keys["w"] = 87] = "w"; - Keys[Keys["x"] = 88] = "x"; - Keys[Keys["y"] = 89] = "y"; - Keys[Keys["z"] = 90] = "z"; - Keys[Keys["leftWindows"] = 91] = "leftWindows"; - Keys[Keys["rightWindows"] = 92] = "rightWindows"; - Keys[Keys["apps"] = 93] = "apps"; - Keys[Keys["sleep"] = 95] = "sleep"; - Keys[Keys["numPad0"] = 96] = "numPad0"; - Keys[Keys["numPad1"] = 97] = "numPad1"; - Keys[Keys["numPad2"] = 98] = "numPad2"; - Keys[Keys["numPad3"] = 99] = "numPad3"; - Keys[Keys["numPad4"] = 100] = "numPad4"; - Keys[Keys["numPad5"] = 101] = "numPad5"; - Keys[Keys["numPad6"] = 102] = "numPad6"; - Keys[Keys["numPad7"] = 103] = "numPad7"; - Keys[Keys["numPad8"] = 104] = "numPad8"; - Keys[Keys["numPad9"] = 105] = "numPad9"; - Keys[Keys["multiply"] = 106] = "multiply"; - Keys[Keys["add"] = 107] = "add"; - Keys[Keys["seperator"] = 108] = "seperator"; - Keys[Keys["subtract"] = 109] = "subtract"; - Keys[Keys["decimal"] = 110] = "decimal"; - Keys[Keys["divide"] = 111] = "divide"; - Keys[Keys["f1"] = 112] = "f1"; - Keys[Keys["f2"] = 113] = "f2"; - Keys[Keys["f3"] = 114] = "f3"; - Keys[Keys["f4"] = 115] = "f4"; - Keys[Keys["f5"] = 116] = "f5"; - Keys[Keys["f6"] = 117] = "f6"; - Keys[Keys["f7"] = 118] = "f7"; - Keys[Keys["f8"] = 119] = "f8"; - Keys[Keys["f9"] = 120] = "f9"; - Keys[Keys["f10"] = 121] = "f10"; - Keys[Keys["f11"] = 122] = "f11"; - Keys[Keys["f12"] = 123] = "f12"; - Keys[Keys["f13"] = 124] = "f13"; - Keys[Keys["f14"] = 125] = "f14"; - Keys[Keys["f15"] = 126] = "f15"; - Keys[Keys["f16"] = 127] = "f16"; - Keys[Keys["f17"] = 128] = "f17"; - Keys[Keys["f18"] = 129] = "f18"; - Keys[Keys["f19"] = 130] = "f19"; - Keys[Keys["f20"] = 131] = "f20"; - Keys[Keys["f21"] = 132] = "f21"; - Keys[Keys["f22"] = 133] = "f22"; - Keys[Keys["f23"] = 134] = "f23"; - Keys[Keys["f24"] = 135] = "f24"; - Keys[Keys["numLock"] = 144] = "numLock"; - Keys[Keys["scroll"] = 145] = "scroll"; - Keys[Keys["leftShift"] = 160] = "leftShift"; - Keys[Keys["rightShift"] = 161] = "rightShift"; - Keys[Keys["leftControl"] = 162] = "leftControl"; - Keys[Keys["rightControl"] = 163] = "rightControl"; - Keys[Keys["leftAlt"] = 164] = "leftAlt"; - Keys[Keys["rightAlt"] = 165] = "rightAlt"; - Keys[Keys["browserBack"] = 166] = "browserBack"; - Keys[Keys["browserForward"] = 167] = "browserForward"; - })(Keys = es.Keys || (es.Keys = {})); -})(es || (es = {})); -var es; -(function (es) { - var OverlapBehavior; - (function (OverlapBehavior) { - OverlapBehavior[OverlapBehavior["cancelOut"] = 0] = "cancelOut"; - OverlapBehavior[OverlapBehavior["takeOlder"] = 1] = "takeOlder"; - OverlapBehavior[OverlapBehavior["takeNewer"] = 2] = "takeNewer"; - })(OverlapBehavior = es.OverlapBehavior || (es.OverlapBehavior = {})); - var VirtualInput = (function () { - function VirtualInput() { - es.Input._virtualInputs.push(this); - } - VirtualInput.prototype.deregister = function () { - es.Input._virtualInputs.remove(this); - }; - return VirtualInput; - }()); - es.VirtualInput = VirtualInput; - var VirtualInputNode = (function () { - function VirtualInputNode() { - } - VirtualInputNode.prototype.update = function () { }; - return VirtualInputNode; - }()); - es.VirtualInputNode = VirtualInputNode; -})(es || (es = {})); -var es; -(function (es) { - var VirtualIntegerAxis = (function (_super) { - __extends(VirtualIntegerAxis, _super); - function VirtualIntegerAxis() { - var nodes = []; - for (var _i = 0; _i < arguments.length; _i++) { - nodes[_i] = arguments[_i]; - } - var _this = _super.call(this) || this; - _this.nodes = []; - _this.nodes.concat(nodes); - return _this; - } - Object.defineProperty(VirtualIntegerAxis.prototype, "value", { - get: function () { - for (var i = 0; i < this.nodes.length; i++) { - var val = this.nodes[i].value; - if (val != 0) - return Math.sign(val); - } - return 0; - }, - enumerable: true, - configurable: true - }); - VirtualIntegerAxis.prototype.update = function () { - for (var i = 0; i < this.nodes.length; i++) - this.nodes[i].update(); - }; - VirtualIntegerAxis.prototype.addKeyboardKeys = function (overlapBehavior, negative, positive) { - this.nodes.push(new es.KeyboardKeys(overlapBehavior, negative, positive)); - return this; - }; - return VirtualIntegerAxis; - }(es.VirtualInput)); - es.VirtualIntegerAxis = VirtualIntegerAxis; - var VirtualAxisNode = (function (_super) { - __extends(VirtualAxisNode, _super); - function VirtualAxisNode() { - return _super !== null && _super.apply(this, arguments) || this; - } - return VirtualAxisNode; - }(es.VirtualInputNode)); - es.VirtualAxisNode = VirtualAxisNode; -})(es || (es = {})); -var es; -(function (es) { - var VirtualAxis = (function (_super) { - __extends(VirtualAxis, _super); - function VirtualAxis() { - var nodes = []; - for (var _i = 0; _i < arguments.length; _i++) { - nodes[_i] = arguments[_i]; - } - var _this = _super.call(this) || this; - _this.nodes = []; - _this.nodes.concat(nodes); - return _this; - } - Object.defineProperty(VirtualAxis.prototype, "value", { - get: function () { - for (var i = 0; i < this.nodes.length; i++) { - var val = this.nodes[i].value; - if (val != 0) - return val; - } - return 0; - }, - enumerable: true, - configurable: true - }); - VirtualAxis.prototype.update = function () { - for (var i = 0; i < this.nodes.length; i++) - this.nodes[i].update(); - }; - return VirtualAxis; - }(es.VirtualInput)); - es.VirtualAxis = VirtualAxis; - var KeyboardKeys = (function (_super) { - __extends(KeyboardKeys, _super); - function KeyboardKeys(overlapBehavior, negative, positive) { - var _this = _super.call(this) || this; - _this._value = 0; - _this.overlapBehavior = overlapBehavior; - _this.negative = negative; - _this.positive = positive; - return _this; - } - KeyboardKeys.prototype.update = function () { - if (es.Input.isKeyDown(this.positive)) { - if (es.Input.isKeyDown(this.negative)) { - switch (this.overlapBehavior) { - default: - case es.OverlapBehavior.cancelOut: - this._value = 0; - break; - case es.OverlapBehavior.takeNewer: - if (!this._turned) { - this._value *= -1; - this._turned = true; - } - break; - case es.OverlapBehavior.takeOlder: - break; - } - } - else { - this._turned = false; - this._value = 1; - } - } - else if (es.Input.isKeyDown(this.negative)) { - this._turned = false; - this._value = -1; - } - else { - this._turned = false; - this._value = 0; - } - }; - Object.defineProperty(KeyboardKeys.prototype, "value", { - get: function () { - return this._value; - }, - enumerable: true, - configurable: true - }); - return KeyboardKeys; - }(es.VirtualAxisNode)); - es.KeyboardKeys = KeyboardKeys; -})(es || (es = {})); -var es; -(function (es) { - var VirtualButton = (function (_super) { - __extends(VirtualButton, _super); - function VirtualButton(bufferTime) { - if (bufferTime === void 0) { bufferTime = 0; } - var nodes = []; - for (var _i = 1; _i < arguments.length; _i++) { - nodes[_i - 1] = arguments[_i]; - } - var _this = _super.call(this) || this; - _this.nodes = []; - _this.bufferTime = 0; - _this.firstRepeatTime = 0; - _this.mutiRepeatTime = 0; - _this._bufferCounter = 0; - _this._repeatCounter = 0; - _this.nodes = nodes; - _this.bufferTime = bufferTime; - return _this; - } - VirtualButton.prototype.setRepeat = function (firstRepeatTime, mutiRepeatTime) { - if (mutiRepeatTime === void 0) { mutiRepeatTime = firstRepeatTime; } - this.firstRepeatTime = firstRepeatTime; - this.mutiRepeatTime = mutiRepeatTime; - this._willRepeat = this.firstRepeatTime > 0; - if (!this._willRepeat) - this.isRepeating = false; - }; - VirtualButton.prototype.update = function () { - this._bufferCounter -= es.Time.unscaledDeltaTime; - this.isRepeating = false; - var check = false; - for (var i = 0; i < this.nodes.length; i++) { - this.nodes[i].update(); - if (this.nodes[i].isPressed) { - this._bufferCounter = this.bufferTime; - check = true; - } - else if (this.nodes[i].isDown) { - check = true; - } - } - if (!check) { - this._repeatCounter = 0; - this._bufferCounter = 0; - } - else if (this._willRepeat) { - if (this._repeatCounter == 0) { - this._repeatCounter = this.firstRepeatTime; - } - else { - this._repeatCounter -= es.Time.unscaledDeltaTime; - if (this._repeatCounter <= 0) { - this.isRepeating = true; - this._repeatCounter = this.mutiRepeatTime; - } - } - } - }; - Object.defineProperty(VirtualButton.prototype, "isDown", { - get: function () { - for (var _i = 0, _a = this.nodes; _i < _a.length; _i++) { - var node = _a[_i]; - if (node.isDown) - return true; - } - return false; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(VirtualButton.prototype, "isPressed", { - get: function () { - if (this._bufferCounter > 0 || this.isRepeating) - return true; - for (var _i = 0, _a = this.nodes; _i < _a.length; _i++) { - var node = _a[_i]; - if (node.isPressed) - return true; - } - return false; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(VirtualButton.prototype, "isReleased", { - get: function () { - for (var _i = 0, _a = this.nodes; _i < _a.length; _i++) { - var node = _a[_i]; - if (node.isReleased) - return true; - } - return false; - }, - enumerable: true, - configurable: true - }); - VirtualButton.prototype.consumeBuffer = function () { - this._bufferCounter = 0; - }; - VirtualButton.prototype.addKeyboardKey = function (key) { - this.nodes.push(new KeyboardKey(key)); - return this; - }; - return VirtualButton; - }(es.VirtualInput)); - es.VirtualButton = VirtualButton; - var Node = (function (_super) { - __extends(Node, _super); - function Node() { - return _super !== null && _super.apply(this, arguments) || this; - } - return Node; - }(es.VirtualInputNode)); - es.Node = Node; - var KeyboardKey = (function (_super) { - __extends(KeyboardKey, _super); - function KeyboardKey(key) { - var _this = _super.call(this) || this; - _this.key = key; - return _this; - } - Object.defineProperty(KeyboardKey.prototype, "isDown", { - get: function () { - return es.Input.isKeyDown(this.key); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(KeyboardKey.prototype, "isPressed", { - get: function () { - return es.Input.isKeyPressed(this.key); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(KeyboardKey.prototype, "isReleased", { - get: function () { - return es.Input.isKeyReleased(this.key); - }, - enumerable: true, - configurable: true - }); - return KeyboardKey; - }(Node)); - es.KeyboardKey = KeyboardKey; -})(es || (es = {})); -var es; -(function (es) { - var Bitmap = egret.Bitmap; - var AssetPacker = (function () { - function AssetPacker() { - this.itemsToRaster = []; - this.useCache = false; - this.cacheName = ""; - this._sprites = new Map(); - this.allow4096Textures = false; - } - AssetPacker.prototype.addTextureToPack = function (texture, customID) { - this.itemsToRaster.push(new es.TextureToPack(texture, customID)); - }; - AssetPacker.prototype.process = function (allow4096Textures) { - if (allow4096Textures === void 0) { allow4096Textures = false; } - return __awaiter(this, void 0, void 0, function () { - var cacheExist; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: - this.allow4096Textures = allow4096Textures; - if (!this.useCache) return [3, 2]; - if (this.cacheName == "") { - console.error("未指定缓存名称"); - return [2]; - } - return [4, RES.getResByUrl(this.cacheName)]; - case 1: - cacheExist = _a.sent(); - if (!cacheExist) - this.createPack(); - else - this.loadPack(); - return [3, 3]; - case 2: - this.createPack(); - _a.label = 3; - case 3: return [2]; - } - }); - }); - }; - AssetPacker.prototype.loadPack = function () { - return __awaiter(this, void 0, void 0, function () { - var loaderTexture; - return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4, RES.getResByUrl(this.cacheName)]; - case 1: - loaderTexture = _a.sent(); - if (this.onProcessCompleted) - this.onProcessCompleted(); - return [2, loaderTexture]; - } - }); - }); - }; - AssetPacker.prototype.createPack = function () { - var textures = []; - var images = []; - for (var _i = 0, _a = this.itemsToRaster; _i < _a.length; _i++) { - var itemToRaster = _a[_i]; - textures.push(new Bitmap(itemToRaster.texture)); - images.push(itemToRaster.id); - } - var textureSize = this.allow4096Textures ? 4096 : 2048; - var rectangles = []; - for (var i = 0; i < textures.length; i++) { - if (textures[i].width > textureSize || textures[i].height > textureSize) { - throw new Error("一个纹理的大小比图集的大小大"); - } - else { - rectangles.push(new es.Rectangle(0, 0, textures[i].width, textures[i].height)); - } - } - var padding = 1; - var numSpriteSheet = 0; - while (rectangles.length > 0) { - var texture = new egret.RenderTexture(); - var packer = new es.RectanglePacker(textureSize, textureSize, padding); - for (var i = 0; i < rectangles.length; i++) - packer.insertRectangle(Math.floor(rectangles[i].width), Math.floor(rectangles[i].height), i); - packer.packRectangles(); - if (packer.rectangleCount > 0) { - var rect = new es.IntegerRectangle(); - var textureAssets = []; - var garbageRect = []; - var garabeTextures = []; - var garbageImages = []; - for (var j = 0; j < packer.rectangleCount; j++) { - rect = packer.getRectangle(j, rect); - var index = packer.getRectangleId(j); - texture.drawToTexture(textures[index], new es.Rectangle(rect.x, rect.y, rect.width, rect.height)); - var textureAsset = new es.TextureAsset(); - textureAsset.x = rect.x; - textureAsset.y = rect.y; - textureAsset.width = rect.width; - textureAsset.height = rect.height; - textureAsset.name = images[index]; - textureAssets.push(textureAsset); - garbageRect.push(rectangles[index]); - garabeTextures.push(textures[index].texture); - garbageImages.push(images[index]); - } - for (var _b = 0, garbageRect_1 = garbageRect; _b < garbageRect_1.length; _b++) { - var garbage = garbageRect_1[_b]; - rectangles.remove(garbage); - } - var _loop_8 = function (garbage) { - textures.removeAll(function (a) { return a.texture.hashCode == garbage.hashCode; }); - }; - for (var _c = 0, garabeTextures_1 = garabeTextures; _c < garabeTextures_1.length; _c++) { - var garbage = garabeTextures_1[_c]; - _loop_8(garbage); - } - for (var _d = 0, garbageImages_1 = garbageImages; _d < garbageImages_1.length; _d++) { - var garbage = garbageImages_1[_d]; - images.remove(garbage); - } - if (this.cacheName != "") { - texture.saveToFile("image/png", this.cacheName); - ++numSpriteSheet; - } - for (var _e = 0, textureAssets_1 = textureAssets; _e < textureAssets_1.length; _e++) { - var textureAsset = textureAssets_1[_e]; - this._sprites.set(textureAsset.name, texture); - } - } - } - if (this.onProcessCompleted) - this.onProcessCompleted(); - }; - AssetPacker.prototype.dispose = function () { - this._sprites.forEach(function (asset, name) { - asset.dispose(); - RES.destroyRes(name); - }); - this._sprites.clear(); - }; - AssetPacker.prototype.getTexture = function (id) { - return this._sprites.get(id); - }; - return AssetPacker; - }()); - es.AssetPacker = AssetPacker; -})(es || (es = {})); -var es; -(function (es) { - var IntegerRectangle = (function (_super) { - __extends(IntegerRectangle, _super); - function IntegerRectangle() { - return _super !== null && _super.apply(this, arguments) || this; - } - return IntegerRectangle; - }(es.Rectangle)); - es.IntegerRectangle = IntegerRectangle; -})(es || (es = {})); -var es; -(function (es) { - var RectanglePacker = (function () { - function RectanglePacker(width, height, padding) { - if (padding === void 0) { padding = 0; } - this._width = 0; - this._height = 0; - this._padding = 8; - this._packedWidth = 0; - this._packedHeight = 0; - this._insertList = []; - this._insertedRectangles = []; - this._freeAreas = []; - this._newFreeAreas = []; - this._sortableSizeStack = []; - this._rectangleStack = []; - this._outsideRectangle = new es.IntegerRectangle(width + 1, height + 1, 0, 0); - this.reset(width, height, padding); - } - Object.defineProperty(RectanglePacker.prototype, "rectangleCount", { - get: function () { - return this._insertedRectangles.length; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(RectanglePacker.prototype, "packedWidth", { - get: function () { - return this._packedWidth; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(RectanglePacker.prototype, "packedHeight", { - get: function () { - return this._packedHeight; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(RectanglePacker.prototype, "padding", { - get: function () { - return this._padding; - }, - enumerable: true, - configurable: true - }); - RectanglePacker.prototype.reset = function (width, height, padding) { - if (padding === void 0) { padding = 0; } - while (this._insertedRectangles.length > 0) - this.freeRectangle(this._insertedRectangles.pop()); - while (this._freeAreas.length > 0) - this.freeRectangle(this._freeAreas.pop()); - this._width = width; - this._height = height; - this._packedWidth = 0; - this._packedHeight = 0; - this._freeAreas.push(this.allocateRectangle(0, 0, this._width, this._height)); - while (this._insertedRectangles.length > 0) - this.freeSize(this._insertList.pop()); - this._padding = padding; - }; - RectanglePacker.prototype.insertRectangle = function (width, height, id) { - var sortableSize = this.allocateSize(width, height, id); - this._insertList.push(sortableSize); - }; - RectanglePacker.prototype.packRectangles = function (sort) { - if (sort === void 0) { sort = true; } - if (sort) - this._insertList.sort(function (emp1, emp2) { - return emp1.width - emp2.width; - }); - while (this._insertList.length > 0) { - var sortableSize = this._insertList.pop(); - var width = sortableSize.width; - var height = sortableSize.height; - var index = this.getFreeAreaIndex(width, height); - if (index >= 0) { - var freeArea = this._freeAreas[index]; - var target = this.allocateRectangle(freeArea.x, freeArea.y, width, height); - target.id = sortableSize.id; - this.generateNewFreeAreas(target, this._freeAreas, this._newFreeAreas); - while (this._newFreeAreas.length > 0) - this._freeAreas.push(this._newFreeAreas.pop()); - this._insertedRectangles.push(target); - if (target.right > this._packedWidth) - this._packedWidth = target.right; - if (target.bottom > this._packedHeight) - this._packedHeight = target.bottom; - } - this.freeSize(sortableSize); - } - return this.rectangleCount; - }; - RectanglePacker.prototype.getRectangle = function (index, rectangle) { - var inserted = this._insertedRectangles[index]; - rectangle.x = inserted.x; - rectangle.y = inserted.y; - rectangle.width = inserted.width; - rectangle.height = inserted.height; - return rectangle; - }; - RectanglePacker.prototype.getRectangleId = function (index) { - var inserted = this._insertedRectangles[index]; - return inserted.id; - }; - RectanglePacker.prototype.generateNewFreeAreas = function (target, areas, results) { - var x = target.x; - var y = target.y; - var right = target.right + 1 + this._padding; - var bottom = target.bottom + 1 + this._padding; - var targetWithPadding = null; - if (this._padding == 0) - targetWithPadding = target; - for (var i = areas.length - 1; i >= 0; i--) { - var area = areas[i]; - if (!(x >= area.right || right <= area.x || y >= area.bottom || bottom <= area.y)) { - if (targetWithPadding == null) - targetWithPadding = this.allocateRectangle(target.x, target.y, target.width + this._padding, target.height + this._padding); - this.generateDividedAreas(targetWithPadding, area, results); - var topOfStack = areas.pop(); - if (i < areas.length) { - areas[i] = topOfStack; - } - } - } - if (targetWithPadding != null && targetWithPadding != target) - this.freeRectangle(targetWithPadding); - this.filterSelfSubAreas(results); - }; - RectanglePacker.prototype.filterSelfSubAreas = function (areas) { - for (var i = areas.length - 1; i >= 0; i--) { - var filtered = areas[i]; - for (var j = areas.length - 1; j >= 0; j--) { - if (i != j) { - var area = areas[j]; - if (filtered.x >= area.x && filtered.y >= area.y && filtered.right <= area.right && filtered.bottom <= area.bottom) { - this.freeRectangle(filtered); - var topOfStack = areas.pop(); - if (i < areas.length) { - areas[i] = topOfStack; - } - break; - } - } - } - } - }; - RectanglePacker.prototype.generateDividedAreas = function (divider, area, results) { - var count = 0; - var rightDelta = area.right - divider.right; - if (rightDelta > 0) { - results.push(this.allocateRectangle(divider.right, area.y, rightDelta, area.height)); - count++; - } - var leftDelta = divider.x - area.x; - if (leftDelta > 0) { - results.push(this.allocateRectangle(area.x, area.y, leftDelta, area.height)); - count++; - } - var bottomDelta = area.bottom - divider.bottom; - if (bottomDelta > 0) { - results.push(this.allocateRectangle(area.x, divider.bottom, area.width, bottomDelta)); - count++; - } - var topDelta = divider.y - area.y; - if (topDelta > 0) { - results.push(this.allocateRectangle(area.x, area.y, area.width, topDelta)); - count++; - } - if (count == 0 && (divider.width < area.width || divider.height < area.height)) { - results.push(area); - } - else { - this.freeRectangle(area); - } - }; - RectanglePacker.prototype.getFreeAreaIndex = function (width, height) { - var best = this._outsideRectangle; - var index = -1; - var paddedWidth = width + this._padding; - var paddedHeight = height + this._padding; - var count = this._freeAreas.length; - for (var i = count - 1; i >= 0; i--) { - var free = this._freeAreas[i]; - if (free.x < this._packedWidth || free.y < this.packedHeight) { - if (free.x < best.x && paddedWidth <= free.width && paddedHeight <= free.height) { - index = i; - if ((paddedWidth == free.width && free.width <= free.height && free.right < this._width) || - (paddedHeight == free.height && free.height <= free.width)) { - break; - } - best = free; - } - } - else { - if (free.x < best.x && width <= free.width && height <= free.height) { - index = i; - if ((width == free.width && free.width <= free.height && free.right < this._width) || - (height == free.height && free.height <= free.width)) { - break; - } - best = free; - } - } - } - return index; - }; - RectanglePacker.prototype.allocateSize = function (width, height, id) { - if (this._sortableSizeStack.length > 0) { - var size = this._sortableSizeStack.pop(); - size.width = width; - size.height = height; - size.id = id; - return size; - } - return new es.SortableSize(width, height, id); - }; - RectanglePacker.prototype.freeSize = function (size) { - this._sortableSizeStack.push(size); - }; - RectanglePacker.prototype.allocateRectangle = function (x, y, width, height) { - if (this._rectangleStack.length > 0) { - var rectangle = this._rectangleStack.pop(); - rectangle.x = x; - rectangle.y = y; - rectangle.width = width; - rectangle.height = height; - rectangle.right = x + width; - rectangle.bottom = y + height; - return rectangle; - } - return new es.IntegerRectangle(x, y, width, height); - }; - RectanglePacker.prototype.freeRectangle = function (rectangle) { - this._rectangleStack.push(rectangle); - }; - return RectanglePacker; - }()); - es.RectanglePacker = RectanglePacker; -})(es || (es = {})); -var es; -(function (es) { - var SortableSize = (function () { - function SortableSize(width, height, id) { - this.width = width; - this.height = height; - this.id = id; - } - return SortableSize; - }()); - es.SortableSize = SortableSize; -})(es || (es = {})); -var es; -(function (es) { - var TextureAssets = (function () { - function TextureAssets(assets) { - this.assets = assets; - } - return TextureAssets; - }()); - es.TextureAssets = TextureAssets; - var TextureAsset = (function () { - function TextureAsset() { - } - return TextureAsset; - }()); - es.TextureAsset = TextureAsset; -})(es || (es = {})); -var es; -(function (es) { - var TextureToPack = (function () { - function TextureToPack(texture, id) { - this.texture = texture; - this.id = id; - } - return TextureToPack; - }()); - es.TextureToPack = TextureToPack; -})(es || (es = {})); -var es; (function (es) { var Timer = (function () { function Timer() { diff --git a/source/bin/framework.min.js b/source/bin/framework.min.js index 7e1100f6..88798b6a 100644 --- a/source/bin/framework.min.js +++ b/source/bin/framework.min.js @@ -1 +1 @@ -window.es={},window.__extends=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])};return function(e,i){function n(){this.constructor=e}t(e,i),e.prototype=null===i?Object.create(i):(n.prototype=i.prototype,new n)}}();var transform,__awaiter=this&&this.__awaiter||function(t,e,i,n){return new(i||(i=Promise))(function(r,o){function s(t){try{h(n.next(t))}catch(t){o(t)}}function a(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){t.done?r(t.value):new i(function(e){e(t.value)}).then(s,a)}h((n=n.apply(t,e||[])).next())})},__generator=this&&this.__generator||function(t,e){var i,n,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(i)throw new TypeError("Generator is already executing.");for(;s;)try{if(i=1,n&&(r=2&o[0]?n.return:o[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,o[1])).done)return r;switch(n=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(r=(r=s.trys).length>0&&r[r.length-1])&&(6===o[0]||2===o[0])){s=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]-1}(this,t)},Array.prototype.firstOrDefault=function(t){return function(t,e){var i=t.findIndex(e);return-1==i?null:t[i]}(this,t)},Array.prototype.find=function(t){return function(t,e){return t.firstOrDefault(e)}(this,t)},Array.prototype.where=function(t){return function(t,e){if("function"==typeof t.reduce)return t.reduce(function(i,n,r){return e.call(arguments[2],n,r,t)&&i.push(n),i},[]);for(var i=[],n=0,r=t.length;n=0&&t.splice(i,1)}while(i>=0)}(this,t)},Array.prototype.remove=function(t){return function(t,e){var i=t.findIndex(function(t){return t===e});return i>=0&&(t.splice(i,1),!0)}(this,t)},Array.prototype.removeAt=function(t){return function(t,e){t.splice(e,1)}(this,t)},Array.prototype.removeRange=function(t,e){return function(t,e,i){t.splice(e,i)}(this,t,e)},Array.prototype.select=function(t){return function(t,e){if("function"==typeof t.reduce)return t.reduce(function(i,n,r){return i.push(e.call(arguments[2],n,r,t)),i},[]);for(var i=[],n=0,r=t.length;no?1:-1}),t}(this,t,e)},Array.prototype.orderByDescending=function(t,e){return function(t,e,i){return t.sort(function(t,n){var r=e(t),o=e(n);return i?-i(r,o):r0;){if("break"===u())break}return s?this.recontructPath(a,n,r):null},e.recontructPath=function(t,e,i){var n=[],r=i;for(n.push(i);r!=e;)r=this.getKey(t,r),n.push(r);return n.reverse(),n},e.hasKey=function(e,i){for(var n,r=e.keys();!(n=r.next()).done;){if(n.value instanceof t.Vector2&&i instanceof t.Vector2&&n.value.equals(i))return!0;if(n.value==i)return!0}return!1},e.getKey=function(e,i){for(var n,r,o=e.keys(),s=e.values();n=o.next(),r=s.next(),!n.done;){if(n.value instanceof t.Vector2&&i instanceof t.Vector2&&n.value.equals(i))return r.value;if(n.value==i)return r.value}return null},e}();t.AStarPathfinder=e;var i=function(t){function e(e){var i=t.call(this)||this;return i.data=e,i}return __extends(e,t),e}(t.PriorityQueueNode)}(es||(es={})),function(t){var e=function(){function e(e,i){this.dirs=[new t.Vector2(1,0),new t.Vector2(0,-1),new t.Vector2(-1,0),new t.Vector2(0,1)],this.walls=[],this.weightedNodes=[],this.defaultWeight=1,this.weightedNodeWeight=5,this._neighbors=new Array(4),this._width=e,this._height=i}return e.prototype.isNodeInBounds=function(t){return 0<=t.x&&t.x=this._nodes.length?(console.error("node.QueueIndex has been corrupted. Did you change it manually? Or add this node to another queue?"),!1):this._nodes[t.queueIndex]==t:(console.error("node cannot be null"),!1)},t.prototype.enqueue=function(t,e){t.priority=e,this._numNodes++,this._nodes[this._numNodes]=t,t.queueIndex=this._numNodes,t.insertionIndex=this._numNodesEverEnqueued++,this.cascadeUp(this._nodes[this._numNodes])},t.prototype.dequeue=function(){var t=this._nodes[1];return this.remove(t),t},t.prototype.remove=function(t){if(t.queueIndex==this._numNodes)return this._nodes[this._numNodes]=null,void this._numNodes--;var e=this._nodes[this._numNodes];this.swap(t,e),delete this._nodes[this._numNodes],this._numNodes--,this.onNodeUpdated(e)},t.prototype.isValidQueue=function(){for(var t=1;t0&&this.hasHigherPriority(t,i)?this.cascadeUp(t):this.cascadeDown(t)},t.prototype.cascadeDown=function(t){for(var e,i=t.queueIndex;;){e=t;var n=2*i;if(n>this._numNodes){t.queueIndex=i,this._nodes[i]=t;break}var r=this._nodes[n];this.hasHigherPriority(r,e)&&(e=r);var o=n+1;if(o<=this._numNodes){var s=this._nodes[o];this.hasHigherPriority(s,e)&&(e=s)}if(e==t){t.queueIndex=i,this._nodes[i]=t;break}this._nodes[i]=e;var a=e.queueIndex;e.queueIndex=i,i=a}},t.prototype.cascadeUp=function(t){for(var e=Math.floor(t.queueIndex/2);e>=1;){var i=this._nodes[e];if(this.hasHigherPriority(i,t))break;this.swap(t,i),e=Math.floor(t.queueIndex/2)}},t.prototype.swap=function(t,e){this._nodes[t.queueIndex]=e,this._nodes[e.queueIndex]=t;var i=t.queueIndex;t.queueIndex=e.queueIndex,e.queueIndex=i},t.prototype.hasHigherPriority=function(t,e){return t.priority0;){if("break"===h())break}return o?t.AStarPathfinder.recontructPath(a,i,n):null},e.hasKey=function(t,e){for(var i,n=t.keys();!(i=n.next()).done;)if(JSON.stringify(i.value)==JSON.stringify(e))return!0;return!1},e}();t.BreadthFirstPathfinder=e}(es||(es={})),function(t){var e=function(){function t(){this.edges=new Map}return t.prototype.addEdgesForNode=function(t,e){return this.edges.set(t,e),this},t.prototype.getNeighbors=function(t){return this.edges.get(t)},t}();t.UnweightedGraph=e}(es||(es={})),function(t){var e=function(){function e(t,e){this.x=0,this.y=0,this.x=t||0,this.y=null!=e?e:this.x}return Object.defineProperty(e,"zero",{get:function(){return new e(0,0)},enumerable:!0,configurable:!0}),Object.defineProperty(e,"one",{get:function(){return new e(1,1)},enumerable:!0,configurable:!0}),Object.defineProperty(e,"unitX",{get:function(){return new e(1,0)},enumerable:!0,configurable:!0}),Object.defineProperty(e,"unitY",{get:function(){return new e(0,1)},enumerable:!0,configurable:!0}),e.add=function(t,i){var n=new e(0,0);return n.x=t.x+i.x,n.y=t.y+i.y,n},e.divide=function(t,i){var n=new e(0,0);return n.x=t.x/i.x,n.y=t.y/i.y,n},e.multiply=function(t,i){var n=new e(0,0);return n.x=t.x*i.x,n.y=t.y*i.y,n},e.subtract=function(t,i){var n=new e(0,0);return n.x=t.x-i.x,n.y=t.y-i.y,n},e.normalize=function(t){var i=new e(t.x,t.y),n=1/Math.sqrt(i.x*i.x+i.y*i.y);return i.x*=n,i.y*=n,i},e.dot=function(t,e){return t.x*e.x+t.y*e.y},e.distanceSquared=function(t,e){var i=t.x-e.x,n=t.y-e.y;return i*i+n*n},e.clamp=function(i,n,r){return new e(t.MathHelper.clamp(i.x,n.x,r.x),t.MathHelper.clamp(i.y,n.y,r.y))},e.lerp=function(i,n,r){return new e(t.MathHelper.lerp(i.x,n.x,r),t.MathHelper.lerp(i.y,n.y,r))},e.transform=function(t,i){return new e(t.x*i.m11+t.y*i.m21+i.m31,t.x*i.m12+t.y*i.m22+i.m32)},e.distance=function(t,e){var i=t.x-e.x,n=t.y-e.y;return Math.sqrt(i*i+n*n)},e.angle=function(i,n){return i=e.normalize(i),n=e.normalize(n),Math.acos(t.MathHelper.clamp(e.dot(i,n),-1,1))*t.MathHelper.Rad2Deg},e.negate=function(t){return t.x=-t.x,t.y=-t.y,t},e.prototype.add=function(t){return this.x+=t.x,this.y+=t.y,this},e.prototype.divide=function(t){return this.x/=t.x,this.y/=t.y,this},e.prototype.multiply=function(t){return this.x*=t.x,this.y*=t.y,this},e.prototype.subtract=function(t){return this.x-=t.x,this.y-=t.y,this},e.prototype.normalize=function(){var t=1/Math.sqrt(this.x*this.x+this.y*this.y);this.x*=t,this.y*=t},e.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y)},e.prototype.lengthSquared=function(){return this.x*this.x+this.y*this.y},e.prototype.round=function(){return new e(Math.round(this.x),Math.round(this.y))},e.prototype.equals=function(t){return t instanceof e&&(t.x==this.x&&t.y==this.y)},e}();t.Vector2=e}(es||(es={})),function(t){var e=function(){function e(t,i,n){void 0===n&&(n=!1),this.walls=[],this._neighbors=new Array(4),this._width=t,this._hegiht=i,this._dirs=n?e.COMPASS_DIRS:e.CARDINAL_DIRS}return e.prototype.isNodeInBounds=function(t){return 0<=t.x&&t.x0;){if("break"===u())break}return s?this.recontructPath(a,n,r):null},i.recontructPath=function(t,e,i){var n=[],r=i;for(n.push(i);r!=e;)r=this.getKey(t,r),n.push(r);return n.reverse(),n},i.hasKey=function(t,e){for(var i,n=t.keys();!(i=n.next()).done;)if(JSON.stringify(i.value)==JSON.stringify(e))return!0;return!1},i.getKey=function(t,e){for(var i,n,r=t.keys(),o=t.values();i=r.next(),n=o.next(),!i.done;)if(JSON.stringify(i.value)==JSON.stringify(e))return n.value;return null},i}();t.WeightedPathfinder=i}(es||(es={})),function(t){var e=function(){function e(){this._opened=new Array(e.MAX_NODES),this._closed=new Array(e.MAX_NODES)}return e.prototype.clear=function(){for(var e=0;e0},e.prototype.removeOpened=function(t){this._numOpened>0&&(this._opened[this._lastFoundOpened]=this._opened[this._numOpened-1]),this._numOpened--},e.prototype.removeClosed=function(t){this._numClosed>0&&(this._closed[this._lastFoundClosed]=this._closed[this._numClosed-1]),this._numClosed--},e.prototype.isOpen=function(t){return this._opened.indexOf(t)>-1},e.prototype.isClosed=function(t){return this._closed.indexOf(t)>-1},e.prototype.addToOpenList=function(t){this._opened[this._numOpened++]=t},e.prototype.addToClosedList=function(t){this._closed[this._numClosed++]=t},e.prototype.removeCheapestOpenNode=function(){var t=Number.MAX_VALUE;this._lastFoundOpened=-1;for(var e=0;e-1?e:(this._actions.push(t),this._actions.length-1)},e.MAX_CONDITIONS=64,e}();t.ActionPlanner=e}(es||(es={})),function(t){var e=function(){function e(){this._planner=new t.ActionPlanner}return e.prototype.plan=function(e){void 0===e&&(e=!1);var i=null;if(e&&(i=[]),this.actions=this._planner.plan(this.getWorldState(),this.getGoalState(),i),null!=i&&i.length>0){console.log("---- ActionPlanner plan ----"),console.log("plan cost = "+i[i.length-1].costSoFar),console.log(" start\t"+this.getWorldState().describe(this._planner));for(var n=0;n0},e}();t.Agent=e}(es||(es={})),function(t){var e=function(){function e(t,e,i){this.planner=t,this.values=e,this.dontCare=i}return e.create=function(t){return new e(t,0,-1)},e.prototype.set=function(t,e){return"string"==typeof t?this.set(this.planner.findConditionNameIndex(t),e):(this.values=e?this.values|1<0&&(i+=", "),i+=o?r.toUpperCase():r}return i},e}();t.WorldState=e}(es||(es={})),function(t){var e=function(e){function i(){var n=e.call(this)||this;return n._globalManagers=[],n._coroutineManager=new t.CoroutineManager,n._timerManager=new t.TimerManager,n._frameCounterElapsedTime=0,n._frameCounter=0,i._instance=n,i.emitter=new t.Emitter,i.content=new t.ContentManager,n.addEventListener(egret.Event.ADDED_TO_STAGE,n.onAddToStage,n),i.registerGlobalManager(n._coroutineManager),i.registerGlobalManager(n._timerManager),n}return __extends(i,e),Object.defineProperty(i,"Instance",{get:function(){return this._instance},enumerable:!0,configurable:!0}),Object.defineProperty(i,"scene",{get:function(){return this._instance?this._instance._scene:null},set:function(t){t?null==this._instance._scene?(this._instance.addChild(t),this._instance._scene=t,this._instance._scene.begin(),i.Instance.onSceneChanged()):this._instance._nextScene=t:console.error("场景不能为空")},enumerable:!0,configurable:!0}),i.startSceneTransition=function(t){if(!this._instance._sceneTransition)return this._instance._sceneTransition=t,t;console.warn("在前一个场景完成之前,不能开始一个新的场景转换。")},i.registerGlobalManager=function(t){this._instance._globalManagers.push(t),t.enabled=!0},i.unregisterGlobalManager=function(t){this._instance._globalManagers.remove(t),t.enabled=!1},i.getGlobalManager=function(t){for(var e=0;e=1&&(this._frameCounter=0,this._frameCounterElapsedTime-=1)},i.prototype.endDebugDraw=function(){t.TimeRuler.Instance.endMark("draw"),t.TimeRuler.Instance.render()},i.prototype.onSceneChanged=function(){i.emitter.emit(t.CoreEvents.SceneChanged),t.Time.sceneChanged()},i.prototype.onGraphicsDeviceReset=function(){i.emitter.emit(t.CoreEvents.GraphicsDeviceReset)},i.prototype.initialize=function(){t.Graphics.Instance=new t.Graphics},i.prototype.update=function(){return __awaiter(this,void 0,void 0,function(){var e;return __generator(this,function(i){switch(i.label){case 0:if(t.Time.update(egret.getTimer()),t.Input.update(),!this._scene)return[3,2];for(e=this._globalManagers.length-1;e>=0;e--)this._globalManagers[e].enabled&&this._globalManagers[e].update();return this._sceneTransition&&(!this._sceneTransition||this._sceneTransition.loadsNewScene&&!this._sceneTransition.isNewSceneLoaded)||this._scene.update(),this._nextScene?(this._scene.parent&&this._scene.parent.removeChild(this._scene),this._scene.end(),this._scene=this._nextScene,this._nextScene=null,this.onSceneChanged(),[4,this._scene.begin()]):[3,2];case 1:i.sent(),this.addChild(this._scene),i.label=2;case 2:return[4,this.draw()];case 3:return i.sent(),[2]}})})},i.prototype.onAddToStage=function(){i.graphicsDevice=new t.GraphicsDevice,this.addEventListener(egret.Event.RESIZE,this.onGraphicsDeviceReset,this),this.addEventListener(egret.StageOrientationEvent.ORIENTATION_CHANGE,this.onOrientationChanged,this),this.addEventListener(egret.Event.ENTER_FRAME,this.update,this),t.Input.initialize(),KeyboardUtils.init(),this.initialize()},i.debugRenderEndabled=!1,i}(egret.DisplayObjectContainer);t.Core=e}(es||(es={})),function(t){var e=function(){function t(){}return t.renderableBounds=16776960,t.renderableCenter=10040012,t.colliderBounds=5592405,t.colliderEdge=9109504,t.colliderPosition=16776960,t.colliderCenter=16711680,t}();t.Colors=e;var i=function(){function e(){}return Object.defineProperty(e,"lineSizeMultiplier",{get:function(){return Math.max(Math.ceil(t.Core.scene.x/t.Core.scene.width),1)},enumerable:!0,configurable:!0}),e}();t.Size=i;var n=function(){function e(){}return e.drawHollowRect=function(e,i,n){void 0===n&&(n=0),this._debugDrawItems.push(new t.DebugDrawItem(e,i,n))},e.render=function(){if(this._debugDrawItems.length>0){var e=new egret.Shape;t.Core.scene&&t.Core.scene.addChild(e);for(var i=this._debugDrawItems.length-1;i>=0;i--){this._debugDrawItems[i].draw(e)&&this._debugDrawItems.removeAt(i)}}},e._debugDrawItems=[],e}();t.Debug=n}(es||(es={})),function(t){var e=function(){function t(){}return t.verletParticle=14431326,t.verletConstraintEdge=4406838,t}();t.DebugDefaults=e}(es||(es={})),function(t){var e;!function(t){t[t.line=0]="line",t[t.hollowRectangle=1]="hollowRectangle",t[t.pixel=2]="pixel",t[t.text=3]="text"}(e=t.DebugDrawType||(t.DebugDrawType={}));var i=function(){function i(t,i,n){this.rectangle=t,this.color=i,this.duration=n,this.drawType=e.hollowRectangle}return i.prototype.draw=function(i){switch(this.drawType){case e.line:case e.hollowRectangle:case e.pixel:case e.text:}return this.duration-=t.Time.deltaTime,this.duration<0},i}();t.DebugDrawItem=i}(es||(es={})),function(t){var e=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.updateInterval=1,e.debugDisplayObject=new egret.DisplayObjectContainer,e._enabled=!0,e._updateOrder=0,e}return __extends(e,t),Object.defineProperty(e.prototype,"transform",{get:function(){return this.entity.transform},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"enabled",{get:function(){return this.entity?this.entity.enabled&&this._enabled:this._enabled},set:function(t){this.setEnabled(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"updateOrder",{get:function(){return this._updateOrder},set:function(t){this.setUpdateOrder(t)},enumerable:!0,configurable:!0}),e.prototype.initialize=function(){},e.prototype.onAddedToEntity=function(){},e.prototype.onRemovedFromEntity=function(){},e.prototype.onEntityTransformChanged=function(t){},e.prototype.debugRender=function(t){},e.prototype.onEnabled=function(){},e.prototype.onDisabled=function(){},e.prototype.update=function(){},e.prototype.setEnabled=function(t){return this._enabled!=t&&(this._enabled=t,this._enabled?this.onEnabled():this.onDisabled()),this},e.prototype.setUpdateOrder=function(t){return this._updateOrder!=t&&(this._updateOrder=t),this},e}(egret.HashObject);t.Component=e}(es||(es={})),function(t){!function(t){t[t.GraphicsDeviceReset=0]="GraphicsDeviceReset",t[t.SceneChanged=1]="SceneChanged",t[t.OrientationChanged=2]="OrientationChanged"}(t.CoreEvents||(t.CoreEvents={}))}(es||(es={})),function(t){var e=function(){function e(i){this.updateInterval=1,this._tag=0,this._enabled=!0,this._updateOrder=0,this.components=new t.ComponentList(this),this.transform=new t.Transform(this),this.name=i,this.id=e._idGenerator++,this.componentBits=new t.BitSet}return Object.defineProperty(e.prototype,"isDestroyed",{get:function(){return this._isDestroyed},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"tag",{get:function(){return this._tag},set:function(t){this.setTag(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"enabled",{get:function(){return this._enabled},set:function(t){this.setEnabled(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"updateOrder",{get:function(){return this._updateOrder},set:function(t){this.setUpdateOrder(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"parent",{get:function(){return this.transform.parent},set:function(t){this.transform.setParent(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"childCount",{get:function(){return this.transform.childCount},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"position",{get:function(){return this.transform.position},set:function(t){this.transform.setPosition(t.x,t.y)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"localPosition",{get:function(){return this.transform.localPosition},set:function(t){this.transform.setLocalPosition(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rotation",{get:function(){return this.transform.rotation},set:function(t){this.transform.setRotation(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rotationDegrees",{get:function(){return this.transform.rotationDegrees},set:function(t){this.transform.setRotationDegrees(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"localRotation",{get:function(){return this.transform.localRotation},set:function(t){this.transform.setLocalRotation(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"localRotationDegrees",{get:function(){return this.transform.localRotationDegrees},set:function(t){this.transform.setLocalRotationDegrees(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"scale",{get:function(){return this.transform.scale},set:function(t){this.transform.setScale(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"localScale",{get:function(){return this.transform.localScale},set:function(t){this.transform.setLocalScale(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"worldInverseTransform",{get:function(){return this.transform.worldInverseTransform},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"localToWorldTransform",{get:function(){return this.transform.localToWorldTransform},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"worldToLocalTransform",{get:function(){return this.transform.worldToLocalTransform},enumerable:!0,configurable:!0}),e.prototype.onTransformChanged=function(t){this.components.onEntityTransformChanged(t)},e.prototype.setTag=function(t){return this._tag!=t&&(this.scene&&this.scene.entities.removeFromTagList(this),this._tag=t,this.scene&&this.scene.entities.addToTagList(this)),this},e.prototype.setEnabled=function(t){return this._enabled!=t&&(this._enabled=t,this._enabled?this.components.onEntityEnabled():this.components.onEntityDisabled()),this},e.prototype.setUpdateOrder=function(t){if(this._updateOrder!=t)return this._updateOrder=t,this.scene&&(this.scene.entities.markEntityListUnsorted(),this.scene.entities.markTagUnsorted(this.tag)),this},e.prototype.destroy=function(){this._isDestroyed=!0,this.scene.entities.remove(this),this.transform.parent=null;for(var t=this.transform.childCount-1;t>=0;t--){this.transform.getChild(t).entity.destroy()}},e.prototype.detachFromScene=function(){this.scene.entities.remove(this),this.components.deregisterAllComponents();for(var t=0;t=0;t--)this._sceneComponents[t].enabled&&this._sceneComponents[t].update();this.entityProcessors&&this.entityProcessors.update(),this.entities.update(),this.entityProcessors&&this.entityProcessors.lateUpdate(),this.renderableComponents.updateList()},i.prototype.render=function(){if(0!=this._renderers.length)for(var t=0;te.x?-1:1,n=t.Vector2.normalize(t.Vector2.subtract(this.position,e));this.rotation=i*Math.acos(t.Vector2.dot(n,t.Vector2.unitY))},n.prototype.setLocalRotation=function(t){return this._localRotation=t,this._localDirty=this._positionDirty=this._localPositionDirty=this._localRotationDirty=this._localScaleDirty=!0,this.setDirty(e.rotationDirty),this},n.prototype.setLocalRotationDegrees=function(e){return this.setLocalRotation(t.MathHelper.toRadians(e))},n.prototype.setScale=function(e){return this._scale=e,this.parent?this.localScale=t.Vector2.divide(e,this.parent._scale):this.localScale=e,this},n.prototype.setLocalScale=function(t){return this._localScale=t,this._localDirty=this._positionDirty=this._localScaleDirty=!0,this.setDirty(e.scaleDirty),this},n.prototype.roundPosition=function(){this.position=this._position.round()},n.prototype.updateTransform=function(){this.hierarchyDirty!=e.clean&&(this.parent&&this.parent.updateTransform(),this._localDirty&&(this._localPositionDirty&&(this._translationMatrix=t.Matrix2D.create().translate(this._localPosition.x,this._localPosition.y),this._localPositionDirty=!1),this._localRotationDirty&&(this._rotationMatrix=t.Matrix2D.create().rotate(this._localRotation),this._localRotationDirty=!1),this._localScaleDirty&&(this._scaleMatrix=t.Matrix2D.create().scale(this._localScale.x,this._localScale.y),this._localScaleDirty=!1),this._localTransform=this._scaleMatrix.multiply(this._rotationMatrix),this._localTransform=this._localTransform.multiply(this._translationMatrix),this.parent||(this._worldTransform=this._localTransform,this._rotation=this._localRotation,this._scale=this._localScale,this._worldInverseDirty=!0),this._localDirty=!1),this.parent&&(this._worldTransform=this._localTransform.multiply(this.parent._worldTransform),this._rotation=this._localRotation+this.parent._rotation,this._scale=t.Vector2.multiply(this.parent._scale,this._localScale),this._worldInverseDirty=!0),this._worldToLocalDirty=!0,this._positionDirty=!0,this.hierarchyDirty=e.clean)},n.prototype.setDirty=function(e){if(0==(this.hierarchyDirty&e)){switch(this.hierarchyDirty|=e,e){case t.DirtyType.positionDirty:this.entity.onTransformChanged(transform.Component.position);break;case t.DirtyType.rotationDirty:this.entity.onTransformChanged(transform.Component.rotation);break;case t.DirtyType.scaleDirty:this.entity.onTransformChanged(transform.Component.scale)}this._children||(this._children=[]);for(var i=0;it&&(this._zoom=t),this._maximumZoom=t,this;console.error("maximumZoom must be greater than zero")},i.prototype.forceMatrixUpdate=function(){this._areMatrixedDirty=!0},i.prototype.onEntityTransformChanged=function(t){this._areMatrixedDirty=!0},i.prototype.zoomIn=function(t){this.zoom+=t},i.prototype.zoomOut=function(t){this.zoom-=t},i.prototype.worldToScreenPoint=function(e){return this.updateMatrixes(),t.Vector2Ext.transformR(e,this._transformMatrix,e),e},i.prototype.screenToWorldPoint=function(e){return this.updateMatrixes(),t.Vector2Ext.transformR(e,this._inverseTransformMatrix,e),e},i.prototype.onSceneRenderTargetSizeChanged=function(e,i){this._isProjectionMatrixDirty=!0;var n=this._origin;this.origin=new t.Vector2(e/2,i/2),this.entity.transform.position.add(t.Vector2.subtract(this._origin,n))},i.prototype.mouseToWorldPoint=function(){return this.screenToWorldPoint(t.Input.touchPosition)},i.prototype.updateMatrixes=function(){var e;this._areMatrixedDirty&&(this._transformMatrix=t.Matrix2D.create().translate(-this.entity.transform.position.x,-this.entity.transform.position.y),1!=this._zoom&&(e=t.Matrix2D.create().scale(this._zoom,this._zoom),this._transformMatrix=this._transformMatrix.multiply(e)),0!=this.entity.transform.rotation&&(e=t.Matrix2D.create().rotate(this.entity.transform.rotation),this._transformMatrix=this._transformMatrix.multiply(e)),e=t.Matrix2D.create().translate(Math.floor(this._origin.x),Math.floor(this._origin.y)),this._transformMatrix=this._transformMatrix.multiply(e),this._inverseTransformMatrix=this._transformMatrix.invert(),this._areBoundsDirty=!0,this._areMatrixedDirty=!1)},i}(t.Component);t.Camera=e}(es||(es={})),function(t){var e=function(e){function i(){var i=null!==e&&e.apply(this,arguments)||this;return i._shakeDirection=t.Vector2.zero,i._shakeOffset=t.Vector2.zero,i._shakeIntensity=0,i._shakeDegredation=.95,i}return __extends(i,e),i.prototype.shake=function(e,i,n){void 0===e&&(e=15),void 0===i&&(i=.9),void 0===n&&(n=t.Vector2.zero),this.enabled=!0,this._shakeIntensity=1)&&(i=.95),this._shakeDegredation=i)},i.prototype.update=function(){Math.abs(this._shakeIntensity)>0&&(this._shakeOffset=this._shakeDirection,0!=this._shakeOffset.x||0!=this._shakeOffset.y?this._shakeOffset.normalize():(this._shakeOffset.x=this._shakeOffset.x+Math.random()-.5,this._shakeOffset.y=this._shakeOffset.y+Math.random()-.5),this._shakeOffset.multiply(new t.Vector2(this._shakeIntensity)),this._shakeIntensity*=-this._shakeDegredation,Math.abs(this._shakeIntensity)<=.01&&(this._shakeIntensity=0,this.enabled=!1)),this.entity.scene.camera.position.add(this._shakeOffset)},i}(t.Component);t.CameraShake=e}(es||(es={})),function(t){var e=function(){function t(t){this._type=t,this._cache=[]}return t.prototype.obtain=function(){try{return this._cache.length>0?this._cache.shift():new this._type}catch(t){throw new Error(this._type+t)}},t.prototype.free=function(t){t.reset(),this._cache.push(t)},t}();t.ComponentPool=e}(es||(es={})),function(t){var e;!function(t){t[t.lockOn=0]="lockOn",t[t.cameraWindow=1]="cameraWindow"}(e=t.CameraStyle||(t.CameraStyle={}));var i=function(i){function n(n,r,o){void 0===n&&(n=null),void 0===r&&(r=null),void 0===o&&(o=e.lockOn);var s=i.call(this)||this;return s.followLerp=.1,s.deadzone=new t.Rectangle,s.focusOffset=t.Vector2.zero,s.mapLockEnabled=!1,s.mapSize=new t.Rectangle,s._desiredPositionDelta=new t.Vector2,s._worldSpaceDeadZone=new t.Rectangle,s.rectShape=new egret.Shape,s._targetEntity=n,s._cameraStyle=o,s.camera=r,s}return __extends(n,i),n.prototype.onAddedToEntity=function(){this.camera||(this.camera=this.entity.scene.camera),this.follow(this._targetEntity,this._cameraStyle),t.Core.emitter.addObserver(t.CoreEvents.GraphicsDeviceReset,this.onGraphicsDeviceReset,this)},n.prototype.onGraphicsDeviceReset=function(){t.Core.schedule(0,!1,this,function(t){var e=t.context;e.follow(e._targetEntity,e._cameraStyle)})},n.prototype.update=function(){var e=t.Vector2.multiply(this.camera.bounds.size,new t.Vector2(.5));this._worldSpaceDeadZone.x=this.camera.position.x-e.x*t.Core.scene.scaleX+this.deadzone.x+this.focusOffset.x,this._worldSpaceDeadZone.y=this.camera.position.y-e.y*t.Core.scene.scaleY+this.deadzone.y+this.focusOffset.y,this._worldSpaceDeadZone.width=this.deadzone.width,this._worldSpaceDeadZone.height=this.deadzone.height,this._targetEntity&&this.updateFollow(),this.camera.position=t.Vector2.lerp(this.camera.position,t.Vector2.add(this.camera.position,this._desiredPositionDelta),this.followLerp),this.entity.transform.roundPosition(),this.mapLockEnabled&&(this.camera.position=this.clampToMapSize(this.camera.position),this.entity.transform.roundPosition())},n.prototype.debugRender=function(t){this.rectShape||this.debugDisplayObject.addChild(this.rectShape),this.rectShape.graphics.clear(),this._cameraStyle==e.lockOn?(this.rectShape.graphics.beginFill(9109504,0),this.rectShape.graphics.lineStyle(1,9109504),this.rectShape.graphics.drawRect(this._worldSpaceDeadZone.x-5-t.bounds.x,this._worldSpaceDeadZone.y-5-t.bounds.y,this._worldSpaceDeadZone.width,this._worldSpaceDeadZone.height),this.rectShape.graphics.endFill()):(this.rectShape.graphics.beginFill(9109504,0),this.rectShape.graphics.lineStyle(1,9109504),this.rectShape.graphics.drawRect(this._worldSpaceDeadZone.x-t.bounds.x,this._worldSpaceDeadZone.y-t.bounds.y,this._worldSpaceDeadZone.width,this._worldSpaceDeadZone.height),this.rectShape.graphics.endFill())},n.prototype.clampToMapSize=function(e){var i=t.Vector2.multiply(this.camera.bounds.size,new t.Vector2(.5)).add(new t.Vector2(this.mapSize.x,this.mapSize.y)),n=new t.Vector2(this.mapSize.width-i.x,this.mapSize.height-i.y);return t.Vector2.clamp(e,i,n)},n.prototype.follow=function(i,n){void 0===n&&(n=e.cameraWindow),this._targetEntity=i,this._cameraStyle=n;var r=this.camera.bounds;switch(this._cameraStyle){case e.cameraWindow:var o=r.width/6,s=r.height/3;this.deadzone=new t.Rectangle((r.width-o)/2,(r.height-s)/2,o,s);break;case e.lockOn:this.deadzone=new t.Rectangle(r.width/2,r.height/2,10,10)}},n.prototype.updateFollow=function(){if(this._desiredPositionDelta.x=this._desiredPositionDelta.y=0,this._cameraStyle==e.lockOn){var i=this._targetEntity.transform.position.x,n=this._targetEntity.transform.position.y;this._worldSpaceDeadZone.x>i?this._desiredPositionDelta.x=i-this._worldSpaceDeadZone.x:this._worldSpaceDeadZone.xn&&(this._desiredPositionDelta.y=n-this._worldSpaceDeadZone.y)}else{if(!this._targetCollider&&(this._targetCollider=this._targetEntity.getComponent(t.Collider),!this._targetCollider))return;var r=this._targetEntity.getComponent(t.Collider).bounds;this._worldSpaceDeadZone.containsRect(r)||(this._worldSpaceDeadZone.left>r.left?this._desiredPositionDelta.x=r.left-this._worldSpaceDeadZone.left:this._worldSpaceDeadZone.rightr.top&&(this._desiredPositionDelta.y=r.top-this._worldSpaceDeadZone.top))}},n.prototype.setCenteredDeadzone=function(e,i){if(this.camera){var n=this.camera.bounds;this.deadzone=new t.Rectangle((n.width-e)/2,(n.height-i)/2,e,i)}else console.error("相机是null。我们不能得到它的边界。请等到该组件添加到实体之后")},n}(t.Component);t.FollowCamera=i}(es||(es={})),function(t){var e=function(){function t(){}return t.prototype.compare=function(t,e){return t.updateOrder-e.updateOrder},t}();t.IUpdatableComparer=e}(es||(es={})),function(t){var e=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e}(t.Component);t.PooledComponent=e}(es||(es={})),function(t){var e=function(){function e(){this.updateOrder=0,this._enabled=!0}return Object.defineProperty(e.prototype,"enabled",{get:function(){return this._enabled},set:function(t){this.setEnabled(t)},enumerable:!0,configurable:!0}),e.prototype.onEnabled=function(){},e.prototype.onDisabled=function(){},e.prototype.onRemovedFromScene=function(){},e.prototype.update=function(){},e.prototype.setEnabled=function(t){return this._enabled!=t&&(this._enabled=t,this._enabled),this},e.prototype.setUpdateOrder=function(e){return this.updateOrder!=e&&(this.updateOrder=e,t.Core.scene._sceneComponents.sort(this.compareTo)),this},e.prototype.compareTo=function(t){return this.updateOrder-t.updateOrder},e}();t.SceneComponent=e}(es||(es={})),function(t){var e=function(e){function i(){return null!==e&&e.apply(this,arguments)||this}return __extends(i,e),i.prototype.onAddedToEntity=function(){this._triggerHelper=new t.ColliderTriggerHelper(this.entity)},i.prototype.calculateMovement=function(e,i){if(!this.entity.getComponent(t.Collider)||!this._triggerHelper)return!1;for(var n=this.entity.getComponents(t.Collider),r=0;r=2){this.polygonShape.graphics.beginFill(t.Colors.colliderEdge,0),this.polygonShape.graphics.lineStyle(t.Size.lineSizeMultiplier,t.Colors.colliderEdge);for(var n=0;no||this._loopMode==e.pingPongOnce&&s>2*o)return this.animationState=i.completed,this._elapsedTime=0,this.currentFrame=0,void(this.displayObject.texture=n.sprites[this.currentFrame].texture2D);var a=Math.floor(s/r),h=n.sprites.length;if(h>2&&(this._loopMode==e.pingPong||this._loopMode==e.pingPongOnce)){var c=h-1;this.currentFrame=c-Math.abs(c-a%(2*c))}else this.currentFrame=a%h;this.displayObject.texture=n.sprites[this.currentFrame].texture2D}},r.prototype.addAnimation=function(t,e){return!this.sprite&&e.sprites.length>0&&this.setSprite(e.sprites[0]),this._animations[t]=e,this},r.prototype.play=function(t,n){void 0===n&&(n=null),this.currentAnimation=this._animations[t],this.currentAnimationName=t,this.currentFrame=0,this.animationState=i.running,this.displayObject.texture=this.currentAnimation.sprites[0].texture2D,this._elapsedTime=0,this._loopMode=n||e.loop},r.prototype.isAnimationActive=function(t){return this.currentAnimation&&this.currentAnimationName==t},r.prototype.pause=function(){this.animationState=i.paused},r.prototype.unPause=function(){this.animationState=i.running},r.prototype.stop=function(){this.currentAnimation=null,this.currentAnimationName=null,this.currentFrame=0,this.animationState=i.none},r}(t.SpriteRenderer);t.SpriteAnimator=n}(es||(es={})),function(t){var e=egret.Bitmap,i=function(i){function n(e){void 0===e&&(e=null);var n=i.call(this)||this;n.displayObject=new egret.DisplayObjectContainer,n.displayObjectCache=new Map;for(var r=0,o=e;r>6;0!=(e&t.LONG_MASK)&&i++,this._bits=new Array(i)}return t.prototype.and=function(t){for(var e,i=Math.min(this._bits.length,t._bits.length),n=0;n=0;)this._bits[e]&=~t._bits[e]},t.prototype.cardinality=function(){for(var t=0,e=this._bits.length-1;e>=0;e--){var i=this._bits[e];if(0!=i)if(-1!=i){var n=((i=((i=(i>>1&0x5555555555555400)+(0x5555555555555400&i))>>2&0x3333333333333400)+(0x3333333333333400&i))>>32)+i;t+=((n=((n=(n>>4&252645135)+(252645135&n))>>8&16711935)+(16711935&n))>>16&65535)+(65535&n)}else t+=64}return t},t.prototype.clear=function(t){if(null!=t){var e=t>>6;this.ensure(e),this._bits[e]&=~(1<>6;return!(e>=this._bits.length)&&0!=(this._bits[e]&1<=0;)if(0!=(this._bits[e]&t._bits[e]))return!0;return!1},t.prototype.isEmpty=function(){for(var t=this._bits.length-1;t>=0;t--)if(this._bits[t])return!1;return!0},t.prototype.nextSetBit=function(t){for(var e=t>>6,i=1<>6;this.ensure(i),this._bits[i]|=1<=this._bits.length){var e=new Number[t+1];e=this._bits.copyWithin(0,0,this._bits.length),this._bits=e}},t.LONG_MASK=63,t}();t.BitSet=e}(es||(es={})),function(t){var e=function(){function e(e){this._components=new t.FastList,this._componentsToAdd=[],this._componentsToRemove=[],this._tempBufferList=[],this._entity=e}return Object.defineProperty(e.prototype,"count",{get:function(){return this._components.length},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"buffer",{get:function(){return this._components.buffer},enumerable:!0,configurable:!0}),e.prototype.markEntityListUnsorted=function(){this._isComponentListUnsorted=!0},e.prototype.add=function(t){this._componentsToAdd.push(t)},e.prototype.remove=function(t){this._componentsToRemove.contains(t)&&console.warn("您正在尝试删除一个您已经删除的组件("+t+")"),this._componentsToAdd.contains(t)?this._componentsToAdd.remove(t):this._componentsToRemove.push(t)},e.prototype.removeAllComponents=function(){for(var t=0;t0){for(var i=0;i0){i=0;for(var n=this._componentsToAdd.length;i0){for(var e=0,i=this._entitiesToRemove;e0;){(n=this._addToSceneEntityList.shift()).onAddedToScene()}if(this._entitiesToAdded.length>0)if(this.frameAllocate&&this._entitiesToAdded.length>this.maxAllocate){for(var r=0;r0;)this.perEntityAddToScene();this._isEntityListUnsorted=!0}this._isEntityListUnsorted&&(this._entities.sort(function(t,e){return t.compareTo(e)}),this._isEntityListUnsorted=!1),0==this._addToSceneEntityList.length&&this._unsortedTags.size>0&&(this._unsortedTags.forEach(function(e){t._entityDict.get(e).sort(function(t,e){return t.compareTo(e)})}),this._unsortedTags.clear())},e.prototype.perEntityAddToScene=function(){var t=this._entitiesToAdded.shift();this._addToSceneEntityList.push(t),-1==this._entities.findIndex(function(e){return e.id==t.id})&&(this._entities.push(t),t.scene=this.scene,this.addToTagList(t),this.scene.entityProcessors.onEntityAdded(t))},e.prototype.findEntity=function(t){for(var e=0;ethis._buckets.length){this._buckets=new Array(t.HashHelpers.expandPrime(this._collisions)),this._collisions=0;for(var l=0;l=e?t%e:t},e}();t.FasterDictionary=e;var i=function(){return function(t,e,i){void 0===i&&(i=-1),this.key=t,this.hashcode=e,this.previous=i,this.next=-1}}();t.FastNode=i}(es||(es={})),function(t){var e=function(){function e(t){void 0===t&&(t=5),this.length=0,this.buffer=new Array(t)}return e.prototype.clear=function(){this.buffer.length=0,this.length=0},e.prototype.reset=function(){this.length=0},e.prototype.add=function(t){this.length==this.buffer.length&&(this.buffer.length=Math.max(this.buffer.length<<1,10)),this.buffer[this.length++]=t},e.prototype.remove=function(e){for(var i=t.EqualityComparer.default(),n=0;n=this.length)throw new Error("index超出范围!");this.length--,this.buffer.removeAt(t)},e.prototype.contains=function(e){for(var i=t.EqualityComparer.default(),n=0;n=this.buffer.length&&(this.buffer.length=Math.max(this.buffer.length<<1,this.length+t))},e.prototype.addRange=function(t){for(var e=0,i=t;e=t)return i}for(e=1|t;ethis.maxPrimeArrayLength&&this.maxPrimeArrayLength>t?this.maxPrimeArrayLength:this.getPrime(e)},t.getHashCode=function(t){var e,i=0;if(0==(e="object"==typeof t?JSON.stringify(t):t.toString()).length)return i;for(var n=0;n=0;e=this.allSet.nextSetBit(e+1))if(!t.componentBits.get(e))return!1;return!(!this.exclusionSet.isEmpty()&&this.exclusionSet.intersects(t.componentBits))&&!(!this.oneSet.isEmpty()&&!this.oneSet.intersects(t.componentBits))},e.prototype.all=function(){for(var e=this,i=[],n=0;n0){for(var t=0,i=this._unsortedRenderLayers.length;t=e)return t;var n=!1;"-"==t.substr(0,1)&&(n=!0,t=t.substr(1));for(var r=e-i,o=0;o1?this.reverse(t.substring(1))+t.substring(0,1):t},t.cutOff=function(t,e,i,n){void 0===n&&(n=!0),e=Math.floor(e),i=Math.floor(i);var r=t.length;e>r&&(e=r);var o,s=e,a=e+i;return n?o=t.substring(0,s)+t.substr(a,r):(a=(s=r-1-e-i)+i,o=t.substring(0,s+1)+t.substr(a+1,r)),o},t.strReplace=function(t,e){for(var i=0,n=e.length;i",">",'"',""","'","'","®","®","©","©","™","™"],t}();!function(t){var e=function(){function e(){}return e.convertImageToCanvas=function(e,i){this.sharedCanvas||(this.sharedCanvas=egret.sys.createCanvas(),this.sharedContext=this.sharedCanvas.getContext("2d"));var n=e.$getTextureWidth(),r=e.$getTextureHeight();i||((i=egret.$TempRectangle).x=0,i.y=0,i.width=n,i.height=r),i.x=Math.min(i.x,n-1),i.y=Math.min(i.y,r-1),i.width=Math.min(i.width,n-i.x),i.height=Math.min(i.height,r-i.y);var o=Math.floor(i.width),s=Math.floor(i.height),a=this.sharedCanvas;if(a.style.width=o+"px",a.style.height=s+"px",this.sharedCanvas.width=o,this.sharedCanvas.height=s,"webgl"==egret.Capabilities.renderMode){var h=void 0;e.$renderBuffer?h=e:(egret.sys.systemRenderer.renderClear&&egret.sys.systemRenderer.renderClear(),(h=new egret.RenderTexture).drawToTexture(new egret.Bitmap(e)));for(var c=h.$renderBuffer.getPixels(i.x,i.y,o,s),u=0,l=0,p=0;p=0?"png":"jpg"});return wx.getFileSystemManager().saveFile({tempFilePath:o,filePath:wx.env.USER_DATA_PATH+"/"+i,success:function(t){}}),o},e.getPixel32=function(t,e,i){return egret.$warn(1041,"getPixel32","getPixels"),t.getPixels(e,i)},e.getPixels=function(t,e,i,n,r){if(void 0===n&&(n=1),void 0===r&&(r=1),"webgl"==egret.Capabilities.renderMode){var o=void 0;return t.$renderBuffer?o=t:(o=new egret.RenderTexture).drawToTexture(new egret.Bitmap(t)),o.$renderBuffer.getPixels(e,i,n,r)}try{this.convertImageToCanvas(t);return this.sharedContext.getImageData(e,i,n,r).data}catch(t){egret.$error(1039)}},e}();t.TextureUtils=e}(es||(es={})),function(t){var e=function(){function t(){}return t.update=function(t){var e=(t-this._lastTime)/1e3;this.deltaTime=e*this.timeScale,this.unscaledDeltaTime=e,this._timeSinceSceneLoad+=e,this.frameCount++,this._lastTime=t},t.sceneChanged=function(){this._timeSinceSceneLoad=0},t.checkEvery=function(t){return Math.floor(this._timeSinceSceneLoad/t)>Math.floor((this._timeSinceSceneLoad-this.deltaTime)/t)},t.deltaTime=0,t.timeScale=1,t.frameCount=0,t._lastTime=0,t}();t.Time=e}(es||(es={}));var TimeUtils=function(){function t(){}return t.monthId=function(t){void 0===t&&(t=null);var e=(t=t||new Date).getFullYear(),i=t.getMonth()+1;return parseInt(e+(i<10?"0":"")+i)},t.dateId=function(t){void 0===t&&(t=null);var e=(t=t||new Date).getMonth()+1,i=e<10?"0":"",n=t.getDate(),r=n<10?"0":"";return parseInt(t.getFullYear()+i+e+r+n)},t.weekId=function(t,e){void 0===t&&(t=null),void 0===e&&(e=!0),t=t||new Date;var i=new Date;i.setTime(t.getTime()),i.setDate(1),i.setMonth(0);var n=i.getFullYear(),r=i.getDay();0==r&&(r=7);var o=!1;r<=4?(o=r>1,i.setDate(i.getDate()-(r-1))):i.setDate(i.getDate()+7-r+1);var s=this.diffDay(t,i,!1);if(s<0)return i.setDate(1),i.setMonth(0),i.setDate(i.getDate()-1),this.weekId(i,!1);var a=s/7,h=Math.floor(a)+1;if(53==h){i.setTime(t.getTime()),i.setDate(i.getDate()-1);var c=i.getDay();if(0==c&&(c=7),e&&(!o||c<4))return i.setFullYear(i.getFullYear()+1),i.setDate(1),i.setMonth(0),this.weekId(i,!1)}return parseInt(n+"00"+(h>9?"":"0")+h)},t.diffDay=function(t,e,i){void 0===i&&(i=!1);var n=(t.getTime()-e.getTime())/864e5;return i?Math.ceil(n):Math.floor(n)},t.getFirstDayOfWeek=function(t){var e=(t=t||new Date).getDay()||7;return new Date(t.getFullYear(),t.getMonth(),t.getDate()+1-e,0,0,0,0)},t.getFirstOfDay=function(t){return(t=t||new Date).setHours(0,0,0,0),t},t.getNextFirstOfDay=function(t){return new Date(this.getFirstOfDay(t).getTime()+864e5)},t.formatDate=function(t){var e=t.getFullYear(),i=t.getMonth()+1;i=i<10?"0"+i:i;var n=t.getDate();return e+"-"+i+"-"+(n=n<10?"0"+n:n)},t.formatDateTime=function(t){var e=t.getFullYear(),i=t.getMonth()+1;i=i<10?"0"+i:i;var n=t.getDate();n=n<10?"0"+n:n;var r=t.getHours(),o=t.getMinutes();o=o<10?"0"+o:o;var s=t.getSeconds();return e+"-"+i+"-"+n+" "+r+":"+o+":"+(s=s<10?"0"+s:s)},t.parseDate=function(t){var e=Date.parse(t);return isNaN(e)?new Date:new Date(Date.parse(t.replace(/-/g,"/")))},t.secondToTime=function(t,e,i){void 0===t&&(t=0),void 0===e&&(e=":"),void 0===i&&(i=!0);var n=Math.floor(t/3600),r=Math.floor(t%3600/60),o=Math.floor(t%3600%60),s=n.toString(),a=r.toString(),h=o.toString();return n<10&&(s="0"+s),r<10&&(a="0"+a),o<10&&(h="0"+h),i?s+e+a+e+h:a+e+h},t.timeToMillisecond=function(t,e){void 0===e&&(e=":");for(var i=t.split(e),n=0,r=i.length,o=0;o-1?this.os="iOS":n.indexOf("android")>-1&&(this.os="Android");var r=i.language;r=r.indexOf("zh")>-1?"zh-CN":"en-US",this.language=r}},e}(egret.Capabilities);t.GraphicsCapabilities=e}(es||(es={})),function(t){var e=function(){function e(){this.setup(),this.graphicsCapabilities=new t.GraphicsCapabilities,this.graphicsCapabilities.initialize(this)}return Object.defineProperty(e.prototype,"viewport",{get:function(){return this._viewport},enumerable:!0,configurable:!0}),e.prototype.setup=function(){this._viewport=new t.Viewport(0,0,t.Core._instance.stage.stageWidth,t.Core._instance.stage.stageHeight)},e}();t.GraphicsDevice=e}(es||(es={})),function(t){var e=function(){function e(t,e,i,n){this._x=t,this._y=e,this._width=i,this._height=n,this._minDepth=0,this._maxDepth=1}return Object.defineProperty(e.prototype,"width",{get:function(){return this._width},set:function(t){this._width=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"height",{get:function(){return this._height},set:function(t){this._height=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"aspectRatio",{get:function(){return 0!=this._height&&0!=this._width?this._width/this._height:0},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"bounds",{get:function(){return new t.Rectangle(this._x,this._y,this._width,this._height)},set:function(t){this._x=t.x,this._y=t.y,this._width=t.width,this._height=t.height},enumerable:!0,configurable:!0}),e}();t.Viewport=e}(es||(es={})),function(t){var e=function(e){function i(){return e.call(this,t.PostProcessor.default_vert,i.blur_frag,{screenWidth:t.Core.graphicsDevice.viewport.width,screenHeight:t.Core.graphicsDevice.viewport.height})||this}return __extends(i,e),i.blur_frag="precision mediump float;\nuniform sampler2D uSampler;\nuniform float screenWidth;\nuniform float screenHeight;\nfloat normpdf(in float x, in float sigma)\n{\nreturn 0.39894*exp(-0.5*x*x/(sigma*sigma))/sigma;\n}\nvoid main()\n{\nvec3 c = texture2D(uSampler, gl_FragCoord.xy / vec2(screenWidth, screenHeight).xy).rgb;\nconst int mSize = 11;\nconst int kSize = (mSize - 1)/2;\nfloat kernel[mSize];\nvec3 final_colour = vec3(0.0);\nfloat sigma = 7.0;\nfloat z = 0.0;\nfor (int j = 0; j <= kSize; ++j)\n{\nkernel[kSize+j] = kernel[kSize-j] = normpdf(float(j),sigma);\n}\nfor (int j = 0; j < mSize; ++j)\n{\nz += kernel[j];\n}\nfor (int i = -kSize; i <= kSize; ++i)\n{\nfor (int j = -kSize; j <= kSize; ++j)\n{\nfinal_colour += kernel[kSize+j]*kernel[kSize+i]*texture2D(uSampler, (gl_FragCoord.xy+vec2(float(i),float(j))) / vec2(screenWidth, screenHeight).xy).rgb;\n}\n}\ngl_FragColor = vec4(final_colour/(z*z), 1.0);\n}",i}(egret.CustomFilter);t.GaussianBlurEffect=e}(es||(es={})),function(t){var e=function(t){function e(){return t.call(this,e.vertSrc,e.fragmentSrc)||this}return __extends(e,t),e.vertSrc="attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\nuniform vec2 projectionVector;\nvarying vec2 vTextureCoord;\nconst vec2 center = vec2(-1.0, 1.0);\nvoid main(void) {\n gl_Position = vec4( (aVertexPosition / projectionVector) + center , 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}",e.fragmentSrc="precision lowp float;\nvarying vec2 vTextureCoord;\nuniform sampler2D uSampler;\n#define SAMPLE_COUNT 15\nuniform vec2 _sampleOffsets[SAMPLE_COUNT];\nuniform float _sampleWeights[SAMPLE_COUNT];\nvoid main(void) {\nvec4 c = vec4(0, 0, 0, 0);\nfor( int i = 0; i < SAMPLE_COUNT; i++ )\n c += texture2D( uSampler, vTextureCoord + _sampleOffsets[i] ) * _sampleWeights[i];\ngl_FragColor = c;\n}",e}(egret.CustomFilter);t.PolygonLightEffect=e}(es||(es={})),function(t){var e=function(){function e(t){void 0===t&&(t=null),this.enabled=!0,this.effect=t}return e.prototype.onAddedToScene=function(e){this.scene=e,this.shape=new egret.Shape,this.shape.graphics.beginFill(16777215,1),this.shape.graphics.drawRect(0,0,t.Core.graphicsDevice.viewport.width,t.Core.graphicsDevice.viewport.height),this.shape.graphics.endFill(),e.addChild(this.shape)},e.prototype.process=function(){this.drawFullscreenQuad()},e.prototype.onSceneBackBufferSizeChanged=function(t,e){},e.prototype.unload=function(){this.effect&&(this.effect=null),this.scene.removeChild(this.shape),this.scene=null},e.prototype.drawFullscreenQuad=function(){this.scene.filters=[this.effect]},e.default_vert="attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\nattribute vec2 aColor;\nuniform vec2 projectionVector;\nvarying vec2 vTextureCoord;\nvarying vec4 vColor;\nconst vec2 center = vec2(-1.0, 1.0);\nvoid main(void) {\ngl_Position = vec4( (aVertexPosition / projectionVector) + center , 0.0, 1.0);\nvTextureCoord = aTextureCoord;\nvColor = vec4(aColor.x, aColor.x, aColor.x, aColor.x);\n}",e}();t.PostProcessor=e}(es||(es={})),function(t){var e=function(e){function i(){return null!==e&&e.apply(this,arguments)||this}return __extends(i,e),i.prototype.onAddedToScene=function(i){e.prototype.onAddedToScene.call(this,i),this.effect=new t.GaussianBlurEffect},i}(t.PostProcessor);t.GaussianBlurPostProcessor=e}(es||(es={})),function(t){var e=function(){function t(t,e){void 0===e&&(e=null),this.renderOrder=0,this.shouldDebugRender=!0,this.camera=e,this.renderOrder=t}return Object.defineProperty(t.prototype,"wantsToRenderToSceneRenderTarget",{get:function(){return!!this.renderTexture},enumerable:!0,configurable:!0}),t.prototype.onAddedToScene=function(t){},t.prototype.unload=function(){},t.prototype.onSceneBackBufferSizeChanged=function(t,e){},t.prototype.compareTo=function(t){return this.renderOrder-t.renderOrder},t.prototype.beginRender=function(t){},t.prototype.renderAfterStateCheck=function(t,e){t.render(e)},t.prototype.debugRender=function(t,e){for(var i=0;i=0&&h=0&&ci?i:t},e.pointOnCirlce=function(i,n,r){var o=e.toRadians(r);return new t.Vector2(Math.cos(o)*o+i.x,Math.sin(o)*o+i.y)},e.isEven=function(t){return t%2==0},e.clamp01=function(t){return t<0?0:t>1?1:t},e.angleBetweenVectors=function(t,e){return Math.atan2(e.y-t.y,e.x-t.x)},e.incrementWithWrap=function(t,e){return++t==e?0:t},e.approach=function(t,e,i){return tn&&(n=s.x),s.yr&&(r=s.y)}return this.fromMinMax(e,i,n,r)},i.prototype.intersects=function(t){return t.leftthis.x+this.width)return!1}else{var n=1/t.direction.x,r=(this.x-t.start.x)*n,o=(this.x+this.width-t.start.x)*n;if(r>o){var s=r;r=o,o=s}if(e.value=Math.max(r,e.value),i=Math.min(o,i),e.value>i)return!1}if(Math.abs(t.direction.y)<1e-6){if(t.start.ythis.y+this.height)return!1}else{var a=1/t.direction.y,h=(this.y-t.start.y)*a,c=(this.y+this.height-t.start.y)*a;if(h>c){var u=h;h=c,c=u}if(e.value=Math.max(h,e.value),i=Math.max(c,i),e.value>i)return!1}return!0},i.prototype.containsRect=function(t){return this.x<=t.x&&t.x1)return!1;var u=(h.x*o.y-h.y*o.x)/a;return!(u<0||u>1)},i.lineToLineIntersection=function(e,i,n,r){var o=new t.Vector2(0,0),s=t.Vector2.subtract(i,e),a=t.Vector2.subtract(r,n),h=s.x*a.y-s.y*a.x;if(0==h)return o;var c=t.Vector2.subtract(n,e),u=(c.x*a.y-c.y*a.x)/h;if(u<0||u>1)return o;var l=(c.x*s.y-c.y*s.x)/h;return l<0||l>1?o:o=t.Vector2.add(e,new t.Vector2(u*s.x,u*s.y))},i.closestPointOnLine=function(e,i,n){var r=t.Vector2.subtract(i,e),o=t.Vector2.subtract(n,e),s=t.Vector2.dot(o,r)/t.Vector2.dot(r,r);return s=t.MathHelper.clamp(s,0,1),t.Vector2.add(e,new t.Vector2(r.x*s,r.y*s))},i.circleToCircle=function(e,i,n,r){return t.Vector2.distanceSquared(e,n)<(i+r)*(i+r)},i.circleToLine=function(e,i,n,r){return t.Vector2.distanceSquared(e,this.closestPointOnLine(n,r,e))=t&&r.y>=e&&r.x=t+n&&(s|=e.right),o.y=i+r&&(s|=e.bottom),s},i}();t.Collisions=i}(es||(es={})),function(t){var e=function(){function e(e,i,n,r,o){this.fraction=0,this.distance=0,this.point=t.Vector2.zero,this.normal=t.Vector2.zero,this.collider=e,this.fraction=i,this.distance=n,this.point=r,this.centroid=t.Vector2.zero}return e.prototype.setValues=function(t,e,i,n){this.collider=t,this.fraction=e,this.distance=i,this.point=n},e.prototype.setValuesNonCollider=function(t,e,i,n){this.fraction=t,this.distance=e,this.point=i,this.normal=n},e.prototype.reset=function(){this.collider=null,this.fraction=this.distance=0},e.prototype.toString=function(){return"[RaycastHit] fraction: "+this.fraction+", distance: "+this.distance+", normal: "+this.normal+", centroid: "+this.centroid+", point: "+this.point},e}();t.RaycastHit=e}(es||(es={})),function(t){var e=function(){function e(){}return e.reset=function(){this._spatialHash=new t.SpatialHash(this.spatialHashCellSize)},e.clear=function(){this._spatialHash.clear()},e.overlapCircleAll=function(t,e,i,n){if(void 0===n&&(n=-1),0!=i.length)return this._spatialHash.overlapCircle(t,e,i,n);console.error("An empty results array was passed in. No results will ever be returned.")},e.boxcastBroadphase=function(t,e){return void 0===e&&(e=this.allLayers),this._spatialHash.aabbBroadphase(t,null,e)},e.boxcastBroadphaseExcludingSelf=function(t,e,i){return void 0===i&&(i=this.allLayers),this._spatialHash.aabbBroadphase(e,t,i)},e.addCollider=function(t){e._spatialHash.register(t)},e.removeCollider=function(t){e._spatialHash.remove(t)},e.updateCollider=function(t){this._spatialHash.remove(t),this._spatialHash.register(t)},e.linecast=function(t,i,n){return void 0===n&&(n=e.allLayers),this._hitArray[0].reset(),this.linecastAll(t,i,this._hitArray,n),this._hitArray[0]},e.linecastAll=function(t,i,n,r){return void 0===r&&(r=e.allLayers),0==n.length?(console.warn("传入了一个空的hits数组。没有点击会被返回"),0):this._spatialHash.linecast(t,i,n,r)},e.debugDraw=function(t){this._spatialHash.debugDraw(t,2)},e.spatialHashCellSize=100,e.allLayers=-1,e.raycastsHitTriggers=!1,e.raycastsStartInColliders=!1,e._hitArray=[new t.RaycastHit],e}();t.Physics=e}(es||(es={})),function(t){var e=function(){return function(e,i){this.start=e,this.end=i,this.direction=t.Vector2.subtract(this.end,this.start)}}();t.Ray2D=e}(es||(es={})),function(t){var e=function(){function e(e){void 0===e&&(e=100),this.gridBounds=new t.Rectangle,this._overlapTestCircle=new t.Circle(0),this._cellDict=new i,this._tempHashSet=[],this._cellSize=e,this._inverseCellSize=1/this._cellSize,this._raycastParser=new n}return e.prototype.register=function(e){var i=e.bounds;e.registeredPhysicsBounds=i;var n=this.cellCoords(i.x,i.y),r=this.cellCoords(i.right,i.bottom);this.gridBounds.contains(n.x,n.y)||(this.gridBounds=t.RectangleExt.union(this.gridBounds,n)),this.gridBounds.contains(r.x,r.y)||(this.gridBounds=t.RectangleExt.union(this.gridBounds,r));for(var o=n.x;o<=r.x;o++)for(var s=n.y;s<=r.y;s++){var a=this.cellAtPosition(o,s,!0);a.firstOrDefault(function(t){return t.hashCode==e.hashCode})||a.push(e)}},e.prototype.remove=function(t){for(var e=t.registeredPhysicsBounds,i=this.cellCoords(e.x,e.y),n=this.cellCoords(e.right,e.bottom),r=i.x;r<=n.x;r++)for(var o=i.y;o<=n.y;o++){var s=this.cellAtPosition(r,o);s?s.remove(t):console.log("从不存在碰撞器的单元格中移除碰撞器: ["+t+"]")}},e.prototype.removeWithBruteForce=function(t){this._cellDict.remove(t)},e.prototype.clear=function(){this._cellDict.clear()},e.prototype.debugDraw=function(t,e){void 0===e&&(e=1);for(var i=this.gridBounds.x;i<=this.gridBounds.right;i++)for(var n=this.gridBounds.y;n<=this.gridBounds.bottom;n++){var r=this.cellAtPosition(i,n);r&&r.length>0&&this.debugDrawCellDetails(i,n,r.length,t,e)}},e.prototype.aabbBroadphase=function(e,i,n){this._tempHashSet.length=0;for(var r=this.cellCoords(e.x,e.y),o=this.cellCoords(e.right,e.bottom),s=r.x;s<=o.x;s++)for(var a=r.y;a<=o.y;a++){var h=this.cellAtPosition(s,a);if(h)for(var c=function(r){var o=h[r];if(o==i||!t.Flags.isFlagSet(n,o.physicsLayer.value))return"continue";e.intersects(o.bounds)&&(u._tempHashSet.firstOrDefault(function(t){return t.hashCode==o.hashCode})||u._tempHashSet.push(o))},u=this,l=0;l=this.points.length?this.points[0]:this.points[n+1];var o=t.Vector2Ext.perpendicular(r,e);t.Vector2Ext.normalize(o),this._edgeNormals[n]=o}},i.buildSymmetricalPolygon=function(e,i){for(var n=new Array(e),r=0;rr&&(r=s,n=o)}return e[n]},i.getClosestPointOnPolygonToPoint=function(e,i,n,r){n.value=Number.MAX_VALUE,r.x=0,r.y=0;for(var o=new t.Vector2(0,0),s=0,a=0;at.y!=this.points[n].y>t.y&&t.x<(this.points[n].x-this.points[i].x)*(t.y-this.points[i].y)/(this.points[n].y-this.points[i].y)+this.points[i].x&&(e=!e);return e},i.prototype.pointCollidesWithShape=function(e,i){return t.ShapeCollisions.pointToPoly(e,this,i)},i}(t.Shape);t.Polygon=e}(es||(es={})),function(t){var e=function(e){function i(t,n){var r=e.call(this,i.buildBox(t,n),!0)||this;return r.width=t,r.height=n,r}return __extends(i,e),i.buildBox=function(e,i){var n=e/2,r=i/2,o=new Array(4);return o[0]=new t.Vector2(-n,-r),o[1]=new t.Vector2(n,-r),o[2]=new t.Vector2(n,r),o[3]=new t.Vector2(-n,r),o},i.prototype.updateBox=function(e,i){this.width=e,this.height=i;var n=e/2,r=i/2;this.points[0]=new t.Vector2(-n,-r),this.points[1]=new t.Vector2(n,-r),this.points[2]=new t.Vector2(n,r),this.points[3]=new t.Vector2(-n,r);for(var o=0;o1)return!1;var a,h=t.Vector2.add(s.start,t.Vector2.add(s.direction,new t.Vector2(r.value))),c=0;h.xi.bounds.right&&(c|=1),h.yi.bounds.bottom&&(c|=2);var u=a+c;return 3==u&&console.log("m == 3. corner "+t.Time.frameCount),!0},e}();t.RealtimeCollisions=e}(es||(es={})),function(t){var e=function(){function e(){}return e.polygonToPolygon=function(e,i,n){for(var r,o=!0,s=e.edgeNormals,a=i.edgeNormals,h=Number.POSITIVE_INFINITY,c=new t.Vector2,u=t.Vector2.subtract(e.position,i.position),l=0;l0&&(o=!1),!o)return!1;(g=Math.abs(g))r&&(r=o);return{min:n,max:r}},e.circleToPolygon=function(e,i,n){var r,o=t.Vector2.subtract(e.position,i.position),s=new t.Ref(0),a=t.Polygon.getClosestPointOnPolygonToPoint(i.points,o,s,n.normal),h=i.containsPoint(e.position);if(s.value>e.radius*e.radius&&!h)return!1;if(h)r=t.Vector2.multiply(n.normal,new t.Vector2(Math.sqrt(s.value)-e.radius));else if(0==s.value)r=t.Vector2.multiply(n.normal,new t.Vector2(e.radius));else{var c=Math.sqrt(s.value);r=t.Vector2.multiply(new t.Vector2(-t.Vector2.subtract(o,a)),new t.Vector2((e.radius-s.value)/c))}return n.minimumTranslationVector=r,n.point=t.Vector2.add(a,i.position),!0},e.circleToBox=function(e,i,n){var r=i.bounds.getClosestPointOnRectangleBorderToPoint(e.position,n.normal);if(i.containsPoint(e.position)){n.point=r;var o=t.Vector2.add(r,t.Vector2.multiply(n.normal,new t.Vector2(e.radius)));return n.minimumTranslationVector=t.Vector2.subtract(e.position,o),!0}var s=t.Vector2.distanceSquared(r,e.position);if(0==s)n.minimumTranslationVector=t.Vector2.multiply(n.normal,new t.Vector2(e.radius));else if(s<=e.radius*e.radius){n.normal=t.Vector2.subtract(e.position,r);var a=n.normal.length()-e.radius;return n.point=r,t.Vector2Ext.normalize(n.normal),n.minimumTranslationVector=t.Vector2.multiply(new t.Vector2(a),n.normal),!0}return!1},e.pointToCircle=function(e,i,n){var r=t.Vector2.distanceSquared(e,i.position),o=1+i.radius;if(r1)return!1;var l=(c.x*s.y-c.y*s.x)/h;return!(l<0||l>1)&&(o=o.add(e).add(t.Vector2.multiply(new t.Vector2(u),s)),!0)},e.lineToCircle=function(e,i,n,r){var o=t.Vector2.distance(e,i),s=t.Vector2.divide(t.Vector2.subtract(i,e),new t.Vector2(o)),a=t.Vector2.subtract(e,n.position),h=t.Vector2.dot(a,s),c=t.Vector2.dot(a,a)-n.radius*n.radius;if(c>0&&h>0)return!1;var u=h*h-c;return!(u<0)&&(r.fraction=-h-Math.sqrt(u),r.fraction<0&&(r.fraction=0),r.point=t.Vector2.add(e,t.Vector2.multiply(new t.Vector2(r.fraction),s)),r.distance=t.Vector2.distance(e,r.point),r.normal=t.Vector2.normalize(t.Vector2.subtract(r.point,n.position)),r.fraction=r.distance/o,!0)},e.boxToBoxCast=function(e,i,n,r){var o=this.minkowskiDifference(e,i);if(o.contains(0,0)){var s=o.getClosestPointOnBoundsToOrigin();return!s.equals(t.Vector2.zero)&&(r.normal=new t.Vector2(-s.x),r.normal.normalize(),r.distance=0,r.fraction=0,!0)}var a=new t.Ray2D(t.Vector2.zero,new t.Vector2(-n.x)),h=new t.Ref(0);return!!(o.rayIntersects(a,h)&&h.value<=1)&&(r.fraction=h.value,r.distance=n.length()*h.value,r.normal=new t.Vector2(-n.x,-n.y),r.normal.normalize(),r.centroid=t.Vector2.add(e.bounds.center,t.Vector2.multiply(n,new t.Vector2(h.value))),!0)},e}();t.ShapeCollisions=e}(es||(es={})),function(t){var e=function(){function e(){this.mass=1,this.radius=0,this.collidesWithColliders=!0}return e.prototype.applyForce=function(e){this.acceleration.add(t.Vector2.divide(e,new t.Vector2(this.mass)))},e}();t.Particle=e}(es||(es={})),function(t){var e=function(){function e(e){void 0===e&&(e=null),this.gravity=new t.Vector2(0,980),this.constraintIterations=3,this.maximumStepIterations=5,this.allowDragging=!0,this._composites=[],this._tempCircle=new t.Circle(1),this._leftOverTime=0,this._fixedDeltaTime=1/60,this._iterationSteps=0,this._fixedDeltaTimeSq=0,this.simulationBounds=e,this._fixedDeltaTimeSq=Math.pow(this._fixedDeltaTimeSq,2)}return e.prototype.update=function(){this.updateTiming(),this.allowDragging&&this.handleDragging();for(var t=1;t<=this._iterationSteps;t++)for(var e=this._composites.length-1;e>=0;e--){for(var i=this._composites[e],n=0;ni.height?e.y=i.height:e.yi.width&&(e.x=i.width)):(e.yi.height-t.radius&&(e.y=2*(i.height-t.radius)-e.y),e.x>i.width-t.radius&&(e.x=2*(i.width-t.radius)-e.x),e.x=0;t--)this._constraints[t].solve()},e.prototype.updateParticles=function(e,i){for(var n=0;n=0;t--)this._constraints[t].collidesWithColliders&&this._constraints[t].handleCollisions(this.collidesWithLayers)},e.prototype.debugRender=function(t){},e}();t.Composite=e}(es||(es={})),function(t){var e=function(){function t(){this.collidesWithColliders=!0}return t.prototype.handleCollisions=function(t){},t}();t.Constraint=e}(es||(es={}));var ArrayUtils=function(){function t(){}return t.bubbleSort=function(t){for(var e=!1,i=0;ii;n--)if(t[n]0&&t[r-1]>n;r--)t[r]=t[r-1];t[r]=n}},t.binarySearch=function(t,e){for(var i=0,n=t.length,r=i+n>>1;i=t[r]&&(i=r+1),r=i+n>>1;return t[i]==e?i:-1},t.findElementIndex=function(t,e){for(var i=t.length,n=0;nt[e]&&(e=n);return e},t.getMinElementIndex=function(t){for(var e=0,i=t.length,n=1;n=0;--r)i.unshift(e[r]);return i},t.getDifferAry=function(t,e){t=this.getUniqueAry(t),e=this.getUniqueAry(e);for(var i=t.concat(e),n={},r=[],o=i.length,s=0;s=0;e-=1)t.splice(e,1)},t.cloneList=function(t){return t?t.slice(0,t.length):null},t.equals=function(t,e){if(t==e)return!0;var i=t.length;if(i!=e.length)return!1;for(;i--;)if(t[i]!=e[i])return!1;return!0},t.insert=function(t,e,i){if(!t)return null;var n=t.length;if(e>n&&(e=n),e<0&&(e=0),e==n)t.push(i);else if(0==e)t.unshift(i);else{for(var r=n-1;r>=e;r-=1)t[r+1]=t[r];t[e]=i}return i},t}();!function(t){var e=function(){function t(){}return Object.defineProperty(t,"nativeBase64",{get:function(){return"function"==typeof window.atob},enumerable:!0,configurable:!0}),t.decode=function(t){if(t=t.replace(/[^A-Za-z0-9\+\/\=]/g,""),this.nativeBase64)return window.atob(t);for(var e,i,n,r,o,s,a=[],h=0;h>4,i=(15&r)<<4|(o=this._keyStr.indexOf(t.charAt(h++)))>>2,n=(3&o)<<6|(s=this._keyStr.indexOf(t.charAt(h++))),a.push(String.fromCharCode(e)),64!==o&&a.push(String.fromCharCode(i)),64!==s&&a.push(String.fromCharCode(n));return a=a.join("")},t.encode=function(t){if(t=t.replace(/\r\n/g,"\n"),!this.nativeBase64){for(var e,i,n,r,o,s,a,h=[],c=0;c>2,o=(3&e)<<4|(i=t.charCodeAt(c++))>>4,s=(15&i)<<2|(n=t.charCodeAt(c++))>>6,a=63&n,isNaN(i)?s=a=64:isNaN(n)&&(a=64),h.push(this._keyStr.charAt(r)),h.push(this._keyStr.charAt(o)),h.push(this._keyStr.charAt(s)),h.push(this._keyStr.charAt(a));return h=h.join("")}window.btoa(t)},t.decodeBase64AsArray=function(e,i){i=i||1;var n,r,o,s=t.decode(e),a=new Uint32Array(s.length/i);for(n=0,o=s.length/i;n=0;--r)a[n]+=s.charCodeAt(n*i+r)<<(r<<3);return a},t.decompress=function(t,e,i){throw new Error("GZIP/ZLIB compressed TMX Tile Map not supported!")},t.decodeCSV=function(t){for(var e=t.replace("\n","").trim().split(","),i=[],n=0;n>16},set:function(t){this._packedValue=4278255615&this._packedValue|t<<16},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"g",{get:function(){return this._packedValue>>8},set:function(t){this._packedValue=4294902015&this._packedValue|t<<8},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"r",{get:function(){return this._packedValue},set:function(t){this._packedValue=4294967040&this._packedValue|t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"a",{get:function(){return this._packedValue>>24},set:function(t){this._packedValue=16777215&this._packedValue|t<<24},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"packedValue",{get:function(){return this._packedValue},set:function(t){this._packedValue=t},enumerable:!0,configurable:!0}),e.prototype.equals=function(t){return this._packedValue==t._packedValue},e}();t.Color=e}(es||(es={})),function(t){var e=function(){function t(){this.loadedAssets=new Map}return t.prototype.loadRes=function(t,e){var i=this;return void 0===e&&(e=!0),new Promise(function(n,r){var o=i.loadedAssets.get(t);o?n(o):e?RES.getResAsync(t).then(function(e){i.loadedAssets.set(t,e),n(e)}).catch(function(e){console.error("资源加载错误:",t,e),r(e)}):RES.getResByUrl(t).then(function(e){i.loadedAssets.set(t,e),n(e)}).catch(function(e){console.error("资源加载错误:",t,e),r(e)})})},t.prototype.dispose=function(){this.loadedAssets.forEach(function(t){var e=t;RES.destroyRes(e)&&e.dispose()}),this.loadedAssets.clear()},t}();t.ContentManager=e}(es||(es={})),function(t){var e=function(){function t(){}return t.getColorMatrix=function(t){var e=[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0];return e[0]=Math.floor(t/256/256)/255,e[6]=Math.floor(t/256%256)/255,e[12]=t%256/255,new egret.ColorMatrixFilter(e)},t}();t.DrawUtils=e}(es||(es={})),function(t){var e=function(){function e(){}return e.oppositeEdge=function(e){switch(e){case t.Edge.bottom:return t.Edge.top;case t.Edge.top:return t.Edge.bottom;case t.Edge.left:return t.Edge.right;case t.Edge.right:return t.Edge.left}},e.isHorizontal=function(e){return e==t.Edge.right||e==t.Edge.left},e.isVertical=function(e){return e==t.Edge.top||e==t.Edge.bottom},e}();t.EdgeExt=e}(es||(es={})),function(t){var e=function(){return function(t,e){this.func=t,this.context=e}}();t.FuncPack=e;var i=function(){function t(){this._messageTable=new Map}return t.prototype.addObserver=function(t,i,n){var r=this._messageTable.get(t);r||(r=[],this._messageTable.set(t,r)),-1!=r.findIndex(function(t){return t.func==i})&&console.warn("您试图添加相同的观察者两次"),r.push(new e(i,n))},t.prototype.removeObserver=function(t,e){var i=this._messageTable.get(t),n=i.findIndex(function(t){return t.func==e});-1!=n&&i.removeAt(n)},t.prototype.emit=function(t,e){var i=this._messageTable.get(t);if(i)for(var n=i.length-1;n>=0;n--)i[n].func.call(i[n].context,e)},t}();t.Emitter=i}(es||(es={})),function(t){!function(t){t[t.top=0]="top",t[t.bottom=1]="bottom",t[t.left=2]="left",t[t.right=3]="right"}(t.Edge||(t.Edge={}))}(es||(es={})),function(t){var e=function(){function t(){}return t.repeat=function(t,e){for(var i=[];e--;)i.push(t);return i},t}();t.Enumerable=e}(es||(es={})),function(t){var e=function(){function t(){}return t.default=function(){return new t},t.prototype.equals=function(t,e){return"function"==typeof t.equals?t.equals(e):t===e},t}();t.EqualityComparer=e}(es||(es={})),function(t){var e=function(){function t(){}return Object.defineProperty(t.prototype,"enabled",{get:function(){return this._enabled},set:function(t){this.setEnabled(t)},enumerable:!0,configurable:!0}),t.prototype.setEnabled=function(t){this._enabled!=t&&(this._enabled=t,this._enabled?this.onEnabled():this.onDisabled())},t.prototype.onEnabled=function(){},t.prototype.onDisabled=function(){},t.prototype.update=function(){},t}();t.GlobalManager=e}(es||(es={})),function(t){var e=function(){function t(){}return t.warmCache=function(t){if((t-=this._objectQueue.length)>0)for(var e=0;ethis._objectQueue.length;)this._objectQueue.shift()},t.clearCache=function(){this._objectQueue.length=0},t.obtain=function(){return this._objectQueue.length>0?this._objectQueue.shift():[]},t.free=function(t){this._objectQueue.unshift(t),t.length=0},t._objectQueue=[],t}();t.ListPool=e}(es||(es={})),function(t){var e=function(){function t(){}return t.toNumber=function(t){return null==t?0:Number(t)},t}();t.NumberExtension=e}(es||(es={})),function(t){var e=function(){function t(t,e){this.first=t,this.second=e}return t.prototype.clear=function(){this.first=this.second=null},t.prototype.equals=function(t){return this.first==t.first&&this.second==t.second},t}();t.Pair=e}(es||(es={})),function(t){var e=function(){function t(){}return t.warmCache=function(t,e){if((e-=this._objectQueue.length)>0)for(var i=0;ithis._objectQueue.length;)this._objectQueue.shift()},t.clearCache=function(){this._objectQueue.length=0},t.obtain=function(t){return this._objectQueue.length>0?this._objectQueue.shift():new t},t.free=function(t){this._objectQueue.unshift(t),egret.is(t,"IPoolable")&&t.reset()},t._objectQueue=[],t}();t.Pool=e}(es||(es={}));var RandomUtils=function(){function t(){}return t.randrange=function(t,e,i){if(void 0===i&&(i=1),0==i)throw new Error("step 不能为 0");var n=e-t;if(0==n)throw new Error("没有可用的范围("+t+","+e+")");n<0&&(n=t-e);var r=Math.floor((n+i-1)/i);return Math.floor(this.random()*r)*i+Math.min(t,e)},t.randint=function(t,e){return(t=Math.floor(t))>(e=Math.floor(e))?t++:e++,this.randrange(t,e)},t.randnum=function(t,e){return this.random()*(e-t)+t},t.shuffle=function(t){return t.sort(this._randomCompare),t},t.choice=function(t){if(!t.hasOwnProperty("length"))throw new Error("无法对此对象执行此操作");var e=Math.floor(this.random()*t.length);return t instanceof String?String(t).charAt(e):t[e]},t.sample=function(t,e){var i=t.length;if(e<=0||i=0;)s=Math.floor(this.random()*i);n.push(t[s]),r.push(s)}return n},t.random=function(){return Math.random()},t.boolean=function(t){return void 0===t&&(t=.5),this.random().5?1:-1},t}();!function(t){var e=function(){function e(){}return e.getSide=function(e,i){switch(i){case t.Edge.top:return e.top;case t.Edge.bottom:return e.bottom;case t.Edge.left:return e.left;case t.Edge.right:return e.right}},e.union=function(e,i){var n=new t.Rectangle(i.x,i.y,0,0),r=new t.Rectangle;return r.x=Math.min(e.x,n.x),r.y=Math.min(e.y,n.y),r.width=Math.max(e.right,n.right)-r.x,r.height=Math.max(e.bottom,r.bottom)-r.y,r},e.getHalfRect=function(e,i){switch(i){case t.Edge.top:return new t.Rectangle(e.x,e.y,e.width,e.height/2);case t.Edge.bottom:return new t.Rectangle(e.x,e.y+e.height/2,e.width,e.height/2);case t.Edge.left:return new t.Rectangle(e.x,e.y,e.width/2,e.height);case t.Edge.right:return new t.Rectangle(e.x+e.width/2,e.y,e.width/2,e.height)}},e.getRectEdgePortion=function(e,i,n){switch(void 0===n&&(n=1),i){case t.Edge.top:return new t.Rectangle(e.x,e.y,e.width,n);case t.Edge.bottom:return new t.Rectangle(e.x,e.y+e.height-n,e.width,n);case t.Edge.left:return new t.Rectangle(e.x,e.y,n,e.height);case t.Edge.right:return new t.Rectangle(e.x+e.width-n,e.y,n,e.height)}},e.expandSide=function(e,i,n){switch(n=Math.abs(n),i){case t.Edge.top:e.y-=n,e.height+=n;break;case t.Edge.bottom:e.height+=n;break;case t.Edge.left:e.x-=n,e.width+=n;break;case t.Edge.right:e.width+=n}},e.contract=function(t,e,i){t.x+=e,t.y+=i,t.width-=2*e,t.height-=2*i},e}();t.RectangleExt=e}(es||(es={})),function(t){var e=function(){return function(t){this.value=t}}();t.Ref=e}(es||(es={})),function(t){var e=function(){function t(){}return t.prototype.update=function(t){this.remainder+=t;var e=Math.trunc(this.remainder);return this.remainder-=e,e},t.prototype.reset=function(){this.remainder=0},t}();t.SubpixelNumber=e}(es||(es={})),function(t){var e=function(){function e(){this.triangleIndices=[],this._triPrev=new Array(12),this._triNext=new Array(12)}return e.testPointTriangle=function(e,i,n,r){return!(t.Vector2Ext.cross(t.Vector2.subtract(e,i),t.Vector2.subtract(n,i))<0)&&(!(t.Vector2Ext.cross(t.Vector2.subtract(e,n),t.Vector2.subtract(r,n))<0)&&!(t.Vector2Ext.cross(t.Vector2.subtract(e,r),t.Vector2.subtract(i,r))<0))},e.prototype.triangulate=function(i,n){void 0===n&&(n=!0);var r=i.length;this.initialize(r);for(var o=0,s=0;r>3&&o<500;){o++;var a=!0,h=i[this._triPrev[s]],c=i[s],u=i[this._triNext[s]];if(t.Vector2Ext.isTriangleCCW(h,c,u)){var l=this._triNext[this._triNext[s]];do{if(e.testPointTriangle(i[l],h,c,u)){a=!1;break}l=this._triNext[l]}while(l!=this._triPrev[s])}else a=!1;a?(this.triangleIndices.push(this._triPrev[s]),this.triangleIndices.push(s),this.triangleIndices.push(this._triNext[s]),this._triNext[this._triPrev[s]]=this._triNext[s],this._triPrev[this._triNext[s]]=this._triPrev[s],r--,s=this._triPrev[s]):s=this._triNext[s]}this.triangleIndices.push(this._triPrev[s]),this.triangleIndices.push(s),this.triangleIndices.push(this._triNext[s]),n||this.triangleIndices.reverse()},e.prototype.initialize=function(t){this.triangleIndices.length=0,this._triNext.lengtht.MathHelper.Epsilon?e.divide(new t.Vector2(i)):e.x=e.y=0},e.transformA=function(t,e,i,n,r,o){for(var s=0;sthis.safeArea.right&&(s.x=this.safeArea.right-s.width),s.topthis.safeArea.bottom&&(s.y=this.safeArea.bottom-s.height),s},i}();t.Layout=i,function(t){t[t.none=0]="none",t[t.left=1]="left",t[t.right=2]="right",t[t.horizontalCenter=4]="horizontalCenter",t[t.top=8]="top",t[t.bottom=16]="bottom",t[t.verticalCenter=32]="verticalCenter",t[t.topLeft=9]="topLeft",t[t.topRight=10]="topRight",t[t.topCenter=12]="topCenter",t[t.bottomLeft=17]="bottomLeft",t[t.bottomRight=18]="bottomRight",t[t.bottomCenter=20]="bottomCenter",t[t.centerLeft=33]="centerLeft",t[t.centerRight=34]="centerRight",t[t.center=36]="center"}(e=t.Alignment||(t.Alignment={}))}(es||(es={})),function(t){var e,i=function(){function t(t){void 0===t&&(t=n),this.getSystemTime=t,this._stopDuration=0,this._completeSlices=[]}return t.prototype.getState=function(){return void 0===this._startSystemTime?e.IDLE:void 0===this._stopSystemTime?e.RUNNING:e.STOPPED},t.prototype.isIdle=function(){return this.getState()===e.IDLE},t.prototype.isRunning=function(){return this.getState()===e.RUNNING},t.prototype.isStopped=function(){return this.getState()===e.STOPPED},t.prototype.slice=function(){return this.recordPendingSlice()},t.prototype.getCompletedSlices=function(){return Array.from(this._completeSlices)},t.prototype.getCompletedAndPendingSlices=function(){return this._completeSlices.concat([this.getPendingSlice()])},t.prototype.getPendingSlice=function(){return this.calculatePendingSlice()},t.prototype.getTime=function(){return this.caculateStopwatchTime()},t.prototype.reset=function(){this._startSystemTime=this._pendingSliceStartStopwatchTime=this._stopSystemTime=void 0,this._stopDuration=0,this._completeSlices=[]},t.prototype.start=function(t){if(void 0===t&&(t=!1),t&&this.reset(),void 0!==this._stopSystemTime){var e=(i=this.getSystemTime())-this._stopSystemTime;this._stopDuration+=e,this._stopSystemTime=void 0}else if(void 0===this._startSystemTime){var i=this.getSystemTime();this._startSystemTime=i,this._pendingSliceStartStopwatchTime=0}},t.prototype.stop=function(t){if(void 0===t&&(t=!1),void 0===this._startSystemTime)return 0;var e=this.getSystemTimeOfCurrentStopwatchTime();return t&&this.recordPendingSlice(this.caculateStopwatchTime(e)),this._stopSystemTime=e,this.getTime()},t.prototype.calculatePendingSlice=function(t){return void 0===this._pendingSliceStartStopwatchTime?Object.freeze({startTime:0,endTime:0,duration:0}):(void 0===t&&(t=this.getTime()),Object.freeze({startTime:this._pendingSliceStartStopwatchTime,endTime:t,duration:t-this._pendingSliceStartStopwatchTime}))},t.prototype.caculateStopwatchTime=function(t){return void 0===this._startSystemTime?0:(void 0===t&&(t=this.getSystemTimeOfCurrentStopwatchTime()),t-this._startSystemTime-this._stopDuration)},t.prototype.getSystemTimeOfCurrentStopwatchTime=function(){return void 0===this._stopSystemTime?this.getSystemTime():this._stopSystemTime},t.prototype.recordPendingSlice=function(t){if(void 0!==this._pendingSliceStartStopwatchTime){void 0===t&&(t=this.getTime());var e=this.calculatePendingSlice(t);return this._pendingSliceStartStopwatchTime=e.endTime,this._completeSlices.push(e),e}return this.calculatePendingSlice()},t}();t.Stopwatch=i,function(t){t.IDLE="IDLE",t.RUNNING="RUNNING",t.STOPPED="STOPPED"}(e||(e={})),t.setDefaultSystemTimeGetter=function(t){void 0===t&&(t=Date.now),n=t};var n=Date.now}(stopwatch||(stopwatch={})),function(t){var e=function(){function e(){this.showLog=!1,this.markers=[],this.stopwacth=new stopwatch.Stopwatch,this._markerNameToIdMap=new Map,this._rectShape1=new egret.Shape,this._rectShape2=new egret.Shape,this._rectShape3=new egret.Shape,this._rectShape4=new egret.Shape,this._rectShape5=new egret.Shape,this._rectShape6=new egret.Shape,this.logs=new Array(2);for(var e=0;e=e.logSnapDuration&&(u.logs[n].snapMin=u.logs[n].min,u.logs[n].snapMax=u.logs[n].max,u.logs[n].snapAvg=u.logs[n].avg,u.logs[n].samples=0)):(u.logs[n].min=h,u.logs[n].max=h,u.logs[n].avg=h,u.logs[n].initialized=!0)}o.markCount=r.nestCount,o.nestCount=r.nestCount}this.stopwacth.reset(),this.stopwacth.start()}},e.prototype.beginMark=function(t,i,n){if(void 0===n&&(n=0),n<0||n>=e.maxBars)throw new Error("barIndex argument out of range");var r=this.curLog.bars[n];if(r.markCount>=e.maxSamples)throw new Error("超出采样次数,可以设置更大的数字为timeruler.maxsaple,或者降低采样次数");if(r.nestCount>=e.maxNestCall)throw new Error("超出采样次数,可以设置更大的数字为timeruler.maxsaple,或者降低采样次数");var s=this._markerNameToIdMap.get(t);isNaN(s)&&(s=this.markers.length,this._markerNameToIdMap.set(t,s),this.markers.push(new o(t))),r.markerNests[r.nestCount++]=r.markCount,r.markers[r.markCount].markerId=s,r.markers[r.markCount].color=i,r.markers[r.markCount].beginTime=this.stopwacth.getTime(),r.markers[r.markCount].endTime=-1,r.markCount++},e.prototype.endMark=function(t,i){if(void 0===i&&(i=0),i<0||i>=e.maxBars)throw new Error("barIndex参数超出范围");var n=this.curLog.bars[i];if(n.nestCount<=0)throw new Error("先调用beginMark方法,再调用endMark方法");var r=this._markerNameToIdMap.get(t);if(isNaN(r))throw new Error("标记 "+t+" 未注册。请确认您指定的名称与 beginMark 方法使用的名称相同");var o=n.markerNests[--n.nestCount];if(n.markers[o].markerId!=r)throw new Error("beginMark/endMark方法的调用顺序不正确,beginMark(A),beginMark(B),endMark(B),endMark(A),但你不能像beginMark(A),beginMark(B),endMark(A),endMark(B)这样调用。");n.markers[o].endTime=this.stopwacth.getTime()},e.prototype.getAverageTime=function(t,i){if(t<0||t>=e.maxBars)throw new Error("barIndex参数超出范围");var n=0,r=this._markerNameToIdMap.get(i);return r&&(n=this.markers[r].logs[t].avg),n},e.prototype.resetLog=function(){this.markers.forEach(function(t){for(var e=0;e0&&(r+=e.barHeight+2*e.barPadding,o=Math.max(o,t.markers[t.markCount-1].endTime))});var s=this.sampleFrames*(1/60*1e3);this._frameAdjust=o>s?Math.max(0,this._frameAdjust)+1:Math.min(0,this._frameAdjust)-1,Math.max(this._frameAdjust)>e.autoAdjustDelay&&(this.sampleFrames=Math.min(e.maxSampleFrames,this.sampleFrames),this.sampleFrames=Math.max(this.targetSampleFrames,Math.floor(o/(1/60*1e3))+1),this._frameAdjust=0);var a=n/s,h=i.y-(r-e.barHeight),c=h,u=new t.Rectangle(i.x,c,n,r);this._rectShape1.graphics.clear(),this._rectShape1.graphics.beginFill(0,128/255),this._rectShape1.graphics.drawRect(u.x,u.y,u.width,u.height),this._rectShape1.graphics.endFill(),u.height=e.barHeight,this._rectShape2.graphics.clear();for(var l=0,p=this.prevLog.bars;l0)for(var f=0;f0?(i.waitTimer-=i.useUnscaledDeltaTime?t.Time.unscaledDeltaTime:t.Time.deltaTime,this._shouldRunNextFrame.push(i)):this.tickCoroutine(i)&&this._shouldRunNextFrame.push(i)}}this._unblockedCoroutines.length=0,this._unblockedCoroutines.concat(this._shouldRunNextFrame),this._shouldRunNextFrame.length=0,this._isInUpdate=!1},n.prototype.tickCoroutine=function(i){var n=i.enumerator.next();return!n.value||n.done?(t.Pool.free(i),!1):!n.value||(n.value instanceof t.WaitForSeconds?(i.waitTimer=n.value.waitTime,!0):n.value instanceof Number?(console.warn("协同程序检查返回一个Number类型,请不要在生产环境使用"),i.waitTimer=Number(n),!0):!(n.value instanceof e)||(i.waitForCoroutine=n.value,!0))},n}(t.GlobalManager);t.CoroutineManager=i}(es||(es={})),function(t){var e=function(){function e(){this.x=0,this.y=0,this.touchPoint=-1,this.touchDown=!1}return Object.defineProperty(e.prototype,"position",{get:function(){return new t.Vector2(this.x,this.y)},enumerable:!0,configurable:!0}),e.prototype.reset=function(){this.x=0,this.y=0,this.touchDown=!1,this.touchPoint=-1},e}();t.TouchState=e;var i=function(){function i(){}return Object.defineProperty(i,"gameTouchs",{get:function(){return this._gameTouchs},enumerable:!0,configurable:!0}),Object.defineProperty(i,"resolutionScale",{get:function(){return this._resolutionScale},enumerable:!0,configurable:!0}),Object.defineProperty(i,"totalTouchCount",{get:function(){return this._totalTouchCount},enumerable:!0,configurable:!0}),Object.defineProperty(i,"touchPosition",{get:function(){return this._gameTouchs[0]?this._gameTouchs[0].position:t.Vector2.zero},enumerable:!0,configurable:!0}),Object.defineProperty(i,"maxSupportedTouch",{get:function(){return t.Core._instance.stage.maxTouches},set:function(e){t.Core._instance.stage.maxTouches=e,this.initTouchCache()},enumerable:!0,configurable:!0}),Object.defineProperty(i,"touchPositionDelta",{get:function(){var e=t.Vector2.subtract(this.touchPosition,this._previousTouchState.position);return e.length()>0&&this.setpreviousTouchState(this._gameTouchs[0]),e},enumerable:!0,configurable:!0}),i.initialize=function(){this._init||(this._init=!0,t.Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_BEGIN,this.touchBegin,this),t.Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_MOVE,this.touchMove,this),t.Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_END,this.touchEnd,this),t.Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_CANCEL,this.touchEnd,this),t.Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_RELEASE_OUTSIDE,this.touchEnd,this),this.initTouchCache())},i.update=function(){KeyboardUtils.update();for(var t=0;t0,this._willRepeat||(this.isRepeating=!1)},i.prototype.update=function(){this._bufferCounter-=t.Time.unscaledDeltaTime,this.isRepeating=!1;for(var e=!1,i=0;i0||this.isRepeating)return!0;for(var t=0,e=this.nodes;ta||i[c].height>a)throw new Error("一个纹理的大小比图集的大小大");h.push(new t.Rectangle(0,0,i[c].width,i[c].height))}for(;h.length>0;){var u=new egret.RenderTexture,l=new t.RectanglePacker(a,a,1);for(c=0;c0){for(var p=new t.IntegerRectangle,d=[],f=[],y=[],g=[],m=0;m0;)this.freeRectangle(this._insertedRectangles.pop());for(;this._freeAreas.length>0;)this.freeRectangle(this._freeAreas.pop());for(this._width=t,this._height=e,this._packedWidth=0,this._packedHeight=0,this._freeAreas.push(this.allocateRectangle(0,0,this._width,this._height));this._insertedRectangles.length>0;)this.freeSize(this._insertList.pop());this._padding=i},e.prototype.insertRectangle=function(t,e,i){var n=this.allocateSize(t,e,i);this._insertList.push(n)},e.prototype.packRectangles=function(t){for(void 0===t&&(t=!0),t&&this._insertList.sort(function(t,e){return t.width-e.width});this._insertList.length>0;){var e=this._insertList.pop(),i=e.width,n=e.height,r=this.getFreeAreaIndex(i,n);if(r>=0){var o=this._freeAreas[r],s=this.allocateRectangle(o.x,o.y,i,n);for(s.id=e.id,this.generateNewFreeAreas(s,this._freeAreas,this._newFreeAreas);this._newFreeAreas.length>0;)this._freeAreas.push(this._newFreeAreas.pop());this._insertedRectangles.push(s),s.right>this._packedWidth&&(this._packedWidth=s.right),s.bottom>this._packedHeight&&(this._packedHeight=s.bottom)}this.freeSize(e)}return this.rectangleCount},e.prototype.getRectangle=function(t,e){var i=this._insertedRectangles[t];return e.x=i.x,e.y=i.y,e.width=i.width,e.height=i.height,e},e.prototype.getRectangleId=function(t){return this._insertedRectangles[t].id},e.prototype.generateNewFreeAreas=function(t,e,i){var n=t.x,r=t.y,o=t.right+1+this._padding,s=t.bottom+1+this._padding,a=null;0==this._padding&&(a=t);for(var h=e.length-1;h>=0;h--){var c=e[h];if(!(n>=c.right||o<=c.x||r>=c.bottom||s<=c.y)){null==a&&(a=this.allocateRectangle(t.x,t.y,t.width+this._padding,t.height+this._padding)),this.generateDividedAreas(a,c,i);var u=e.pop();h=0;e--)for(var i=t[e],n=t.length-1;n>=0;n--)if(e!=n){var r=t[n];if(i.x>=r.x&&i.y>=r.y&&i.right<=r.right&&i.bottom<=r.bottom){this.freeRectangle(i);var o=t.pop();e0&&(i.push(this.allocateRectangle(t.right,e.y,r,e.height)),n++);var o=t.x-e.x;o>0&&(i.push(this.allocateRectangle(e.x,e.y,o,e.height)),n++);var s=e.bottom-t.bottom;s>0&&(i.push(this.allocateRectangle(e.x,t.bottom,e.width,s)),n++);var a=t.y-e.y;a>0&&(i.push(this.allocateRectangle(e.x,e.y,e.width,a)),n++),0==n&&(t.width=0;s--){var a=this._freeAreas[s];if(a.x0){var r=this._sortableSizeStack.pop();return r.width=e,r.height=i,r.id=n,r}return new t.SortableSize(e,i,n)},e.prototype.freeSize=function(t){this._sortableSizeStack.push(t)},e.prototype.allocateRectangle=function(e,i,n,r){if(this._rectangleStack.length>0){var o=this._rectangleStack.pop();return o.x=e,o.y=i,o.width=n,o.height=r,o.right=e+n,o.bottom=i+r,o}return new t.IntegerRectangle(e,i,n,r)},e.prototype.freeRectangle=function(t){this._rectangleStack.push(t)},e}();t.RectanglePacker=e}(es||(es={})),function(t){var e=function(){return function(t,e,i){this.width=t,this.height=e,this.id=i}}();t.SortableSize=e}(es||(es={})),function(t){var e=function(){return function(t){this.assets=t}}();t.TextureAssets=e;var i=function(){return function(){}}();t.TextureAsset=i}(es||(es={})),function(t){var e=function(){return function(t,e){this.texture=t,this.id=e}}();t.TextureToPack=e}(es||(es={})),function(t){var e=function(){function e(){this._timeInSeconds=0,this._repeats=!1,this._isDone=!1,this._elapsedTime=0}return e.prototype.getContext=function(){return this.context},e.prototype.reset=function(){this._elapsedTime=0},e.prototype.stop=function(){this._isDone=!0},e.prototype.tick=function(){return!this._isDone&&this._elapsedTime>this._timeInSeconds&&(this._elapsedTime-=this._timeInSeconds,this._onTime(this),this._isDone||this._repeats||(this._isDone=!0)),this._elapsedTime+=t.Time.deltaTime,this._isDone},e.prototype.initialize=function(t,e,i,n){this._timeInSeconds=t,this._repeats=e,this.context=i,this._onTime=n},e.prototype.unload=function(){this.context=null,this._onTime=null},e}();t.Timer=e}(es||(es={})),function(t){var e=function(e){function i(){var t=null!==e&&e.apply(this,arguments)||this;return t._timers=[],t}return __extends(i,e),i.prototype.update=function(){for(var t=this._timers.length-1;t>=0;t--)this._timers[t].tick()&&(this._timers[t].unload(),this._timers.removeAt(t))},i.prototype.schedule=function(e,i,n,r){var o=new t.Timer;return o.initialize(e,i,n,r),this._timers.push(o),o},i}(t.GlobalManager);t.TimerManager=e}(es||(es={})); \ No newline at end of file +window.es={},window.__extends=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])};return function(e,n){function i(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(i.prototype=n.prototype,new i)}}();var transform,__awaiter=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))(function(r,o){function s(t){try{c(i.next(t))}catch(t){o(t)}}function a(t){try{c(i.throw(t))}catch(t){o(t)}}function c(t){t.done?r(t.value):new n(function(e){e(t.value)}).then(s,a)}c((i=i.apply(t,e||[])).next())})},__generator=this&&this.__generator||function(t,e){var n,i,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,i&&(r=2&o[0]?i.return:o[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,o[1])).done)return r;switch(i=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,i=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(r=(r=s.trys).length>0&&r[r.length-1])&&(6===o[0]||2===o[0])){s=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]-1}(this,t)},Array.prototype.firstOrDefault=function(t){return function(t,e){var n=t.findIndex(e);return-1==n?null:t[n]}(this,t)},Array.prototype.find=function(t){return function(t,e){return t.firstOrDefault(e)}(this,t)},Array.prototype.where=function(t){return function(t,e){if("function"==typeof t.reduce)return t.reduce(function(n,i,r){return e.call(arguments[2],i,r,t)&&n.push(i),n},[]);for(var n=[],i=0,r=t.length;i=0&&t.splice(n,1)}while(n>=0)}(this,t)},Array.prototype.remove=function(t){return function(t,e){var n=t.findIndex(function(t){return t===e});return n>=0&&(t.splice(n,1),!0)}(this,t)},Array.prototype.removeAt=function(t){return function(t,e){t.splice(e,1)}(this,t)},Array.prototype.removeRange=function(t,e){return function(t,e,n){t.splice(e,n)}(this,t,e)},Array.prototype.select=function(t){return function(t,e){if("function"==typeof t.reduce)return t.reduce(function(n,i,r){return n.push(e.call(arguments[2],i,r,t)),n},[]);for(var n=[],i=0,r=t.length;io?1:-1}),t}(this,t,e)},Array.prototype.orderByDescending=function(t,e){return function(t,e,n){return t.sort(function(t,i){var r=e(t),o=e(i);return n?-n(r,o):r0;){if("break"===u())break}return s?this.recontructPath(a,i,r):null},e.recontructPath=function(t,e,n){var i=[],r=n;for(i.push(n);r!=e;)r=this.getKey(t,r),i.push(r);return i.reverse(),i},e.hasKey=function(e,n){for(var i,r=e.keys();!(i=r.next()).done;){if(i.value instanceof t.Vector2&&n instanceof t.Vector2&&i.value.equals(n))return!0;if(i.value==n)return!0}return!1},e.getKey=function(e,n){for(var i,r,o=e.keys(),s=e.values();i=o.next(),r=s.next(),!i.done;){if(i.value instanceof t.Vector2&&n instanceof t.Vector2&&i.value.equals(n))return r.value;if(i.value==n)return r.value}return null},e}();t.AStarPathfinder=e;var n=function(t){function e(e){var n=t.call(this)||this;return n.data=e,n}return __extends(e,t),e}(t.PriorityQueueNode)}(es||(es={})),function(t){var e=function(){function e(e,n){this.dirs=[new t.Vector2(1,0),new t.Vector2(0,-1),new t.Vector2(-1,0),new t.Vector2(0,1)],this.walls=[],this.weightedNodes=[],this.defaultWeight=1,this.weightedNodeWeight=5,this._neighbors=new Array(4),this._width=e,this._height=n}return e.prototype.isNodeInBounds=function(t){return 0<=t.x&&t.x=this._nodes.length?(console.error("node.QueueIndex has been corrupted. Did you change it manually? Or add this node to another queue?"),!1):this._nodes[t.queueIndex]==t:(console.error("node cannot be null"),!1)},t.prototype.enqueue=function(t,e){t.priority=e,this._numNodes++,this._nodes[this._numNodes]=t,t.queueIndex=this._numNodes,t.insertionIndex=this._numNodesEverEnqueued++,this.cascadeUp(this._nodes[this._numNodes])},t.prototype.dequeue=function(){var t=this._nodes[1];return this.remove(t),t},t.prototype.remove=function(t){if(t.queueIndex==this._numNodes)return this._nodes[this._numNodes]=null,void this._numNodes--;var e=this._nodes[this._numNodes];this.swap(t,e),delete this._nodes[this._numNodes],this._numNodes--,this.onNodeUpdated(e)},t.prototype.isValidQueue=function(){for(var t=1;t0&&this.hasHigherPriority(t,n)?this.cascadeUp(t):this.cascadeDown(t)},t.prototype.cascadeDown=function(t){for(var e,n=t.queueIndex;;){e=t;var i=2*n;if(i>this._numNodes){t.queueIndex=n,this._nodes[n]=t;break}var r=this._nodes[i];this.hasHigherPriority(r,e)&&(e=r);var o=i+1;if(o<=this._numNodes){var s=this._nodes[o];this.hasHigherPriority(s,e)&&(e=s)}if(e==t){t.queueIndex=n,this._nodes[n]=t;break}this._nodes[n]=e;var a=e.queueIndex;e.queueIndex=n,n=a}},t.prototype.cascadeUp=function(t){for(var e=Math.floor(t.queueIndex/2);e>=1;){var n=this._nodes[e];if(this.hasHigherPriority(n,t))break;this.swap(t,n),e=Math.floor(t.queueIndex/2)}},t.prototype.swap=function(t,e){this._nodes[t.queueIndex]=e,this._nodes[e.queueIndex]=t;var n=t.queueIndex;t.queueIndex=e.queueIndex,e.queueIndex=n},t.prototype.hasHigherPriority=function(t,e){return t.priority0;){if("break"===c())break}return o?t.AStarPathfinder.recontructPath(a,n,i):null},e.hasKey=function(t,e){for(var n,i=t.keys();!(n=i.next()).done;)if(JSON.stringify(n.value)==JSON.stringify(e))return!0;return!1},e}();t.BreadthFirstPathfinder=e}(es||(es={})),function(t){var e=function(){function t(){this.edges=new Map}return t.prototype.addEdgesForNode=function(t,e){return this.edges.set(t,e),this},t.prototype.getNeighbors=function(t){return this.edges.get(t)},t}();t.UnweightedGraph=e}(es||(es={})),function(t){var e=function(){function e(t,e){this.x=0,this.y=0,this.x=t||0,this.y=null!=e?e:this.x}return Object.defineProperty(e,"zero",{get:function(){return new e(0,0)},enumerable:!0,configurable:!0}),Object.defineProperty(e,"one",{get:function(){return new e(1,1)},enumerable:!0,configurable:!0}),Object.defineProperty(e,"unitX",{get:function(){return new e(1,0)},enumerable:!0,configurable:!0}),Object.defineProperty(e,"unitY",{get:function(){return new e(0,1)},enumerable:!0,configurable:!0}),e.add=function(t,n){var i=new e(0,0);return i.x=t.x+n.x,i.y=t.y+n.y,i},e.divide=function(t,n){var i=new e(0,0);return i.x=t.x/n.x,i.y=t.y/n.y,i},e.multiply=function(t,n){var i=new e(0,0);return i.x=t.x*n.x,i.y=t.y*n.y,i},e.subtract=function(t,n){var i=new e(0,0);return i.x=t.x-n.x,i.y=t.y-n.y,i},e.normalize=function(t){var n=new e(t.x,t.y),i=1/Math.sqrt(n.x*n.x+n.y*n.y);return n.x*=i,n.y*=i,n},e.dot=function(t,e){return t.x*e.x+t.y*e.y},e.distanceSquared=function(t,e){var n=t.x-e.x,i=t.y-e.y;return n*n+i*i},e.clamp=function(n,i,r){return new e(t.MathHelper.clamp(n.x,i.x,r.x),t.MathHelper.clamp(n.y,i.y,r.y))},e.lerp=function(n,i,r){return new e(t.MathHelper.lerp(n.x,i.x,r),t.MathHelper.lerp(n.y,i.y,r))},e.transform=function(t,n){return new e(t.x*n.m11+t.y*n.m21+n.m31,t.x*n.m12+t.y*n.m22+n.m32)},e.distance=function(t,e){var n=t.x-e.x,i=t.y-e.y;return Math.sqrt(n*n+i*i)},e.angle=function(n,i){return n=e.normalize(n),i=e.normalize(i),Math.acos(t.MathHelper.clamp(e.dot(n,i),-1,1))*t.MathHelper.Rad2Deg},e.negate=function(t){return t.x=-t.x,t.y=-t.y,t},e.prototype.add=function(t){return this.x+=t.x,this.y+=t.y,this},e.prototype.divide=function(t){return this.x/=t.x,this.y/=t.y,this},e.prototype.multiply=function(t){return this.x*=t.x,this.y*=t.y,this},e.prototype.subtract=function(t){return this.x-=t.x,this.y-=t.y,this},e.prototype.normalize=function(){var t=1/Math.sqrt(this.x*this.x+this.y*this.y);this.x*=t,this.y*=t},e.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y)},e.prototype.lengthSquared=function(){return this.x*this.x+this.y*this.y},e.prototype.round=function(){return new e(Math.round(this.x),Math.round(this.y))},e.prototype.equals=function(t){return t instanceof e&&(t.x==this.x&&t.y==this.y)},e}();t.Vector2=e}(es||(es={})),function(t){var e=function(){function e(t,n,i){void 0===i&&(i=!1),this.walls=[],this._neighbors=new Array(4),this._width=t,this._hegiht=n,this._dirs=i?e.COMPASS_DIRS:e.CARDINAL_DIRS}return e.prototype.isNodeInBounds=function(t){return 0<=t.x&&t.x0;){if("break"===u())break}return s?this.recontructPath(a,i,r):null},n.recontructPath=function(t,e,n){var i=[],r=n;for(i.push(n);r!=e;)r=this.getKey(t,r),i.push(r);return i.reverse(),i},n.hasKey=function(t,e){for(var n,i=t.keys();!(n=i.next()).done;)if(JSON.stringify(n.value)==JSON.stringify(e))return!0;return!1},n.getKey=function(t,e){for(var n,i,r=t.keys(),o=t.values();n=r.next(),i=o.next(),!n.done;)if(JSON.stringify(n.value)==JSON.stringify(e))return i.value;return null},n}();t.WeightedPathfinder=n}(es||(es={})),function(t){var e=function(){function e(){this._opened=new Array(e.MAX_NODES),this._closed=new Array(e.MAX_NODES)}return e.prototype.clear=function(){for(var e=0;e0},e.prototype.removeOpened=function(t){this._numOpened>0&&(this._opened[this._lastFoundOpened]=this._opened[this._numOpened-1]),this._numOpened--},e.prototype.removeClosed=function(t){this._numClosed>0&&(this._closed[this._lastFoundClosed]=this._closed[this._numClosed-1]),this._numClosed--},e.prototype.isOpen=function(t){return this._opened.indexOf(t)>-1},e.prototype.isClosed=function(t){return this._closed.indexOf(t)>-1},e.prototype.addToOpenList=function(t){this._opened[this._numOpened++]=t},e.prototype.addToClosedList=function(t){this._closed[this._numClosed++]=t},e.prototype.removeCheapestOpenNode=function(){var t=Number.MAX_VALUE;this._lastFoundOpened=-1;for(var e=0;e-1?e:(this._actions.push(t),this._actions.length-1)},e.MAX_CONDITIONS=64,e}();t.ActionPlanner=e}(es||(es={})),function(t){var e=function(){function e(){this._planner=new t.ActionPlanner}return e.prototype.plan=function(e){void 0===e&&(e=!1);var n=null;if(e&&(n=[]),this.actions=this._planner.plan(this.getWorldState(),this.getGoalState(),n),null!=n&&n.length>0){console.log("---- ActionPlanner plan ----"),console.log("plan cost = "+n[n.length-1].costSoFar),console.log(" start\t"+this.getWorldState().describe(this._planner));for(var i=0;i0},e}();t.Agent=e}(es||(es={})),function(t){var e=function(){function e(t,e,n){this.planner=t,this.values=e,this.dontCare=n}return e.create=function(t){return new e(t,0,-1)},e.prototype.set=function(t,e){return"string"==typeof t?this.set(this.planner.findConditionNameIndex(t),e):(this.values=e?this.values|1<0&&(n+=", "),n+=o?r.toUpperCase():r}return n},e}();t.WorldState=e}(es||(es={})),function(t){var e=function(){function t(){}return t.verletParticle=14431326,t.verletConstraintEdge=4406838,t}();t.DebugDefaults=e}(es||(es={})),function(t){var e=function(){function t(){this.updateInterval=1,this._enabled=!0,this._updateOrder=0}return Object.defineProperty(t.prototype,"transform",{get:function(){return this.entity.transform},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"enabled",{get:function(){return this.entity?this.entity.enabled&&this._enabled:this._enabled},set:function(t){this.setEnabled(t)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"updateOrder",{get:function(){return this._updateOrder},set:function(t){this.setUpdateOrder(t)},enumerable:!0,configurable:!0}),t.prototype.initialize=function(){},t.prototype.onAddedToEntity=function(){},t.prototype.onRemovedFromEntity=function(){},t.prototype.onEntityTransformChanged=function(t){},t.prototype.debugRender=function(t){},t.prototype.onEnabled=function(){},t.prototype.onDisabled=function(){},t.prototype.setEnabled=function(t){return this._enabled!=t&&(this._enabled=t,this._enabled?this.onEnabled():this.onDisabled()),this},t.prototype.setUpdateOrder=function(t){return this._updateOrder!=t&&(this._updateOrder=t),this},t}();t.Component=e}(es||(es={})),function(t){var e=function(){function e(n,i){this._globalManagers=[],this._timerManager=new t.TimerManager,this._frameCounterElapsedTime=0,this._frameCounter=0,this.width=n,this.height=i,e._instance=this,e.emitter=new t.Emitter,e.registerGlobalManager(this._timerManager),this.initialize()}return Object.defineProperty(e,"Instance",{get:function(){return this._instance},enumerable:!0,configurable:!0}),Object.defineProperty(e,"scene",{get:function(){return this._instance?this._instance._scene:null},set:function(t){t?null==this._instance._scene?(this._instance._scene=t,this._instance._scene.begin(),e.Instance.onSceneChanged()):this._instance._nextScene=t:console.error("场景不能为空")},enumerable:!0,configurable:!0}),e.startSceneTransition=function(t){if(!this._instance._sceneTransition)return this._instance._sceneTransition=t,t;console.warn("在前一个场景完成之前,不能开始一个新的场景转换。")},e.registerGlobalManager=function(t){this._instance._globalManagers.push(t),t.enabled=!0},e.unregisterGlobalManager=function(t){this._instance._globalManagers.remove(t),t.enabled=!1},e.getGlobalManager=function(t){for(var e=0;e=0;t--)this._globalManagers[t].enabled&&this._globalManagers[t].update();return this._sceneTransition&&(!this._sceneTransition||this._sceneTransition.loadsNewScene&&!this._sceneTransition.isNewSceneLoaded)||this._scene.update(),this._nextScene?(this._scene.end(),this._scene=this._nextScene,this._nextScene=null,this.onSceneChanged(),[4,this._scene.begin()]):[3,2];case 1:e.sent(),e.label=2;case 2:return[4,this.draw()];case 3:return e.sent(),[2]}})})},e.debugRenderEndabled=!1,e}();t.Core=e}(es||(es={})),function(t){!function(t){t[t.GraphicsDeviceReset=0]="GraphicsDeviceReset",t[t.SceneChanged=1]="SceneChanged",t[t.OrientationChanged=2]="OrientationChanged"}(t.CoreEvents||(t.CoreEvents={}))}(es||(es={})),function(t){var e=function(){function e(n){this.updateInterval=1,this._tag=0,this._enabled=!0,this._updateOrder=0,this.components=new t.ComponentList(this),this.transform=new t.Transform(this),this.name=n,this.id=e._idGenerator++,this.componentBits=new t.BitSet}return Object.defineProperty(e.prototype,"isDestroyed",{get:function(){return this._isDestroyed},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"tag",{get:function(){return this._tag},set:function(t){this.setTag(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"enabled",{get:function(){return this._enabled},set:function(t){this.setEnabled(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"updateOrder",{get:function(){return this._updateOrder},set:function(t){this.setUpdateOrder(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"parent",{get:function(){return this.transform.parent},set:function(t){this.transform.setParent(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"childCount",{get:function(){return this.transform.childCount},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"position",{get:function(){return this.transform.position},set:function(t){this.transform.setPosition(t.x,t.y)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"localPosition",{get:function(){return this.transform.localPosition},set:function(t){this.transform.setLocalPosition(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rotation",{get:function(){return this.transform.rotation},set:function(t){this.transform.setRotation(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rotationDegrees",{get:function(){return this.transform.rotationDegrees},set:function(t){this.transform.setRotationDegrees(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"localRotation",{get:function(){return this.transform.localRotation},set:function(t){this.transform.setLocalRotation(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"localRotationDegrees",{get:function(){return this.transform.localRotationDegrees},set:function(t){this.transform.setLocalRotationDegrees(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"scale",{get:function(){return this.transform.scale},set:function(t){this.transform.setScale(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"localScale",{get:function(){return this.transform.localScale},set:function(t){this.transform.setLocalScale(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"worldInverseTransform",{get:function(){return this.transform.worldInverseTransform},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"localToWorldTransform",{get:function(){return this.transform.localToWorldTransform},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"worldToLocalTransform",{get:function(){return this.transform.worldToLocalTransform},enumerable:!0,configurable:!0}),e.prototype.onTransformChanged=function(t){this.components.onEntityTransformChanged(t)},e.prototype.setTag=function(t){return this._tag!=t&&(this.scene&&this.scene.entities.removeFromTagList(this),this._tag=t,this.scene&&this.scene.entities.addToTagList(this)),this},e.prototype.setEnabled=function(t){return this._enabled!=t&&(this._enabled=t,this._enabled?this.components.onEntityEnabled():this.components.onEntityDisabled()),this},e.prototype.setUpdateOrder=function(t){if(this._updateOrder!=t)return this._updateOrder=t,this.scene&&(this.scene.entities.markEntityListUnsorted(),this.scene.entities.markTagUnsorted(this.tag)),this},e.prototype.destroy=function(){this._isDestroyed=!0,this.scene.entities.remove(this),this.transform.parent=null;for(var t=this.transform.childCount-1;t>=0;t--){this.transform.getChild(t).entity.destroy()}},e.prototype.detachFromScene=function(){this.scene.entities.remove(this),this.components.deregisterAllComponents();for(var t=0;t=0;t--)this._sceneComponents[t].enabled&&this._sceneComponents[t].update();this.entityProcessors&&this.entityProcessors.update(),this.entities.update(),this.entityProcessors&&this.entityProcessors.lateUpdate(),this.renderableComponents.updateList()},e.prototype.render=function(){if(0!=this._renderers.length)for(var t=0;te.x?-1:1,i=t.Vector2.normalize(t.Vector2.subtract(this.position,e));this.rotation=n*Math.acos(t.Vector2.dot(i,t.Vector2.unitY))},n.prototype.setLocalRotation=function(t){return this._localRotation=t,this._localDirty=this._positionDirty=this._localPositionDirty=this._localRotationDirty=this._localScaleDirty=!0,this.setDirty(e.rotationDirty),this},n.prototype.setLocalRotationDegrees=function(e){return this.setLocalRotation(t.MathHelper.toRadians(e))},n.prototype.setScale=function(e){return this._scale=e,this.parent?this.localScale=t.Vector2.divide(e,this.parent._scale):this.localScale=e,this},n.prototype.setLocalScale=function(t){return this._localScale=t,this._localDirty=this._positionDirty=this._localScaleDirty=!0,this.setDirty(e.scaleDirty),this},n.prototype.roundPosition=function(){this.position=this._position.round()},n.prototype.updateTransform=function(){this.hierarchyDirty!=e.clean&&(this.parent&&this.parent.updateTransform(),this._localDirty&&(this._localPositionDirty&&(this._translationMatrix=t.Matrix2D.createTranslation(this._localPosition.x,this._localPosition.y),this._localPositionDirty=!1),this._localRotationDirty&&(this._rotationMatrix=t.Matrix2D.createRotation(this._localRotation),this._localRotationDirty=!1),this._localScaleDirty&&(this._scaleMatrix=t.Matrix2D.createScale(this._localScale.x,this._localScale.y),this._localScaleDirty=!1),this._localTransform=this._scaleMatrix.multiply(this._rotationMatrix),this._localTransform=this._localTransform.multiply(this._translationMatrix),this.parent||(this._worldTransform=this._localTransform,this._rotation=this._localRotation,this._scale=this._localScale,this._worldInverseDirty=!0),this._localDirty=!1),this.parent&&(this._worldTransform=this._localTransform.multiply(this.parent._worldTransform),this._rotation=this._localRotation+this.parent._rotation,this._scale=t.Vector2.multiply(this.parent._scale,this._localScale),this._worldInverseDirty=!0),this._worldToLocalDirty=!0,this._positionDirty=!0,this.hierarchyDirty=e.clean)},n.prototype.setDirty=function(e){if(0==(this.hierarchyDirty&e)){switch(this.hierarchyDirty|=e,e){case t.DirtyType.positionDirty:this.entity.onTransformChanged(transform.Component.position);break;case t.DirtyType.rotationDirty:this.entity.onTransformChanged(transform.Component.rotation);break;case t.DirtyType.scaleDirty:this.entity.onTransformChanged(transform.Component.scale)}this._children||(this._children=[]);for(var n=0;n0?this._cache.shift():new this._type}catch(t){throw new Error(this._type+t)}},t.prototype.free=function(t){t.reset(),this._cache.push(t)},t}();t.ComponentPool=e}(es||(es={})),function(t){var e=function(){function t(){}return t.prototype.compare=function(t,e){return t.updateOrder-e.updateOrder},t}();t.IUpdatableComparer=e,t.isIUpdatable=function(t){return void 0!==t.js}}(es||(es={})),function(t){var e=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e}(t.Component);t.PooledComponent=e}(es||(es={})),function(t){var e=function(){function e(){this.updateOrder=0,this._enabled=!0}return Object.defineProperty(e.prototype,"enabled",{get:function(){return this._enabled},set:function(t){this.setEnabled(t)},enumerable:!0,configurable:!0}),e.prototype.onEnabled=function(){},e.prototype.onDisabled=function(){},e.prototype.onRemovedFromScene=function(){},e.prototype.update=function(){},e.prototype.setEnabled=function(t){return this._enabled!=t&&(this._enabled=t,this._enabled),this},e.prototype.setUpdateOrder=function(e){return this.updateOrder!=e&&(this.updateOrder=e,t.Core.scene._sceneComponents.sort(this.compareTo)),this},e.prototype.compareTo=function(t){return this.updateOrder-t.updateOrder},e}();t.SceneComponent=e}(es||(es={})),function(t){var e=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return __extends(n,e),n.prototype.onAddedToEntity=function(){this._triggerHelper=new t.ColliderTriggerHelper(this.entity)},n.prototype.calculateMovement=function(e,n){if(!this.entity.getComponent(t.Collider)||!this._triggerHelper)return!1;for(var i=this.entity.getComponents(t.Collider),r=0;r>6;0!=(e&t.LONG_MASK)&&n++,this._bits=new Array(n)}return t.prototype.and=function(t){for(var e,n=Math.min(this._bits.length,t._bits.length),i=0;i=0;)this._bits[e]&=~t._bits[e]},t.prototype.cardinality=function(){for(var t=0,e=this._bits.length-1;e>=0;e--){var n=this._bits[e];if(0!=n)if(-1!=n){var i=((n=((n=(n>>1&0x5555555555555400)+(0x5555555555555400&n))>>2&0x3333333333333400)+(0x3333333333333400&n))>>32)+n;t+=((i=((i=(i>>4&252645135)+(252645135&i))>>8&16711935)+(16711935&i))>>16&65535)+(65535&i)}else t+=64}return t},t.prototype.clear=function(t){if(null!=t){var e=t>>6;this.ensure(e),this._bits[e]&=~(1<>6;return!(e>=this._bits.length)&&0!=(this._bits[e]&1<=0;)if(0!=(this._bits[e]&t._bits[e]))return!0;return!1},t.prototype.isEmpty=function(){for(var t=this._bits.length-1;t>=0;t--)if(this._bits[t])return!1;return!0},t.prototype.nextSetBit=function(t){for(var e=t>>6,n=1<>6;this.ensure(n),this._bits[n]|=1<=this._bits.length){var e=new Number[t+1];e=this._bits.copyWithin(0,0,this._bits.length),this._bits=e}},t.LONG_MASK=63,t}();t.BitSet=e}(es||(es={})),function(t){var e=function(){function e(e){this._components=new t.FastList,this._updatableComponents=new t.FastList,this._componentsToAdd=[],this._componentsToRemove=[],this._tempBufferList=[],this._entity=e}return Object.defineProperty(e.prototype,"count",{get:function(){return this._components.length},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"buffer",{get:function(){return this._components.buffer},enumerable:!0,configurable:!0}),e.prototype.markEntityListUnsorted=function(){this._isComponentListUnsorted=!0},e.prototype.add=function(t){this._componentsToAdd.push(t)},e.prototype.remove=function(t){this._componentsToRemove.contains(t)&&console.warn("您正在尝试删除一个您已经删除的组件("+t+")"),this._componentsToAdd.contains(t)?this._componentsToAdd.remove(t):this._componentsToRemove.push(t)},e.prototype.removeAllComponents=function(){for(var t=0;t0){for(var n=0;n0){n=0;for(var i=this._componentsToAdd.length;n0){for(var e=0,n=this._entitiesToRemove;e0;){(i=this._addToSceneEntityList.shift()).onAddedToScene()}if(this._entitiesToAdded.length>0)if(this.frameAllocate&&this._entitiesToAdded.length>this.maxAllocate){for(var r=0;r0;)this.perEntityAddToScene();this._isEntityListUnsorted=!0}this._isEntityListUnsorted&&(this._entities.sort(function(t,e){return t.compareTo(e)}),this._isEntityListUnsorted=!1),0==this._addToSceneEntityList.length&&this._unsortedTags.size>0&&(this._unsortedTags.forEach(function(e){t._entityDict.get(e).sort(function(t,e){return t.compareTo(e)})}),this._unsortedTags.clear())},e.prototype.perEntityAddToScene=function(){var t=this._entitiesToAdded.shift();this._addToSceneEntityList.push(t),-1==this._entities.findIndex(function(e){return e.id==t.id})&&(this._entities.push(t),t.scene=this.scene,this.addToTagList(t),this.scene.entityProcessors.onEntityAdded(t))},e.prototype.findEntity=function(t){for(var e=0;ethis._buckets.length){this._buckets=new Array(t.HashHelpers.expandPrime(this._collisions)),this._collisions=0;for(var l=0;l=e?t%e:t},e}();t.FasterDictionary=e;var n=function(){return function(t,e,n){void 0===n&&(n=-1),this.key=t,this.hashcode=e,this.previous=n,this.next=-1}}();t.FastNode=n}(es||(es={})),function(t){var e=function(){function e(t){void 0===t&&(t=5),this.length=0,this.buffer=new Array(t)}return e.prototype.clear=function(){this.buffer.length=0,this.length=0},e.prototype.reset=function(){this.length=0},e.prototype.add=function(t){this.length==this.buffer.length&&(this.buffer.length=Math.max(this.buffer.length<<1,10)),this.buffer[this.length++]=t},e.prototype.remove=function(e){for(var n=t.EqualityComparer.default(),i=0;i=this.length)throw new Error("index超出范围!");this.length--,this.buffer.removeAt(t)},e.prototype.contains=function(e){for(var n=t.EqualityComparer.default(),i=0;i=this.buffer.length&&(this.buffer.length=Math.max(this.buffer.length<<1,this.length+t))},e.prototype.addRange=function(t){for(var e=0,n=t;e=t)return n}for(e=1|t;ethis.maxPrimeArrayLength&&this.maxPrimeArrayLength>t?this.maxPrimeArrayLength:this.getPrime(e)},t.getHashCode=function(t){var e,n=0;if(0==(e="object"==typeof t?JSON.stringify(t):t.toString()).length)return n;for(var i=0;i=0;e=this.allSet.nextSetBit(e+1))if(!t.componentBits.get(e))return!1;return!(!this.exclusionSet.isEmpty()&&this.exclusionSet.intersects(t.componentBits))&&!(!this.oneSet.isEmpty()&&!this.oneSet.intersects(t.componentBits))},e.prototype.all=function(){for(var e=this,n=[],i=0;i0){for(var t=0,n=this._unsortedRenderLayers.length;t=e)return t;var i=!1;"-"==t.substr(0,1)&&(i=!0,t=t.substr(1));for(var r=e-n,o=0;o1?this.reverse(t.substring(1))+t.substring(0,1):t},t.cutOff=function(t,e,n,i){void 0===i&&(i=!0),e=Math.floor(e),n=Math.floor(n);var r=t.length;e>r&&(e=r);var o,s=e,a=e+n;return i?o=t.substring(0,s)+t.substr(a,r):(a=(s=r-1-e-n)+n,o=t.substring(0,s+1)+t.substr(a+1,r)),o},t.strReplace=function(t,e){for(var n=0,i=e.length;n",">",'"',""","'","'","®","®","©","©","™","™"],t}();!function(t){var e=function(){function t(){}return t.update=function(t){var e=(t-this._lastTime)/1e3;this.deltaTime=e*this.timeScale,this.unscaledDeltaTime=e,this._timeSinceSceneLoad+=e,this.frameCount++,this._lastTime=t},t.sceneChanged=function(){this._timeSinceSceneLoad=0},t.checkEvery=function(t){return Math.floor(this._timeSinceSceneLoad/t)>Math.floor((this._timeSinceSceneLoad-this.deltaTime)/t)},t.deltaTime=0,t.timeScale=1,t.frameCount=0,t._lastTime=0,t}();t.Time=e}(es||(es={}));var TimeUtils=function(){function t(){}return t.monthId=function(t){void 0===t&&(t=null);var e=(t=t||new Date).getFullYear(),n=t.getMonth()+1;return parseInt(e+(n<10?"0":"")+n)},t.dateId=function(t){void 0===t&&(t=null);var e=(t=t||new Date).getMonth()+1,n=e<10?"0":"",i=t.getDate(),r=i<10?"0":"";return parseInt(t.getFullYear()+n+e+r+i)},t.weekId=function(t,e){void 0===t&&(t=null),void 0===e&&(e=!0),t=t||new Date;var n=new Date;n.setTime(t.getTime()),n.setDate(1),n.setMonth(0);var i=n.getFullYear(),r=n.getDay();0==r&&(r=7);var o=!1;r<=4?(o=r>1,n.setDate(n.getDate()-(r-1))):n.setDate(n.getDate()+7-r+1);var s=this.diffDay(t,n,!1);if(s<0)return n.setDate(1),n.setMonth(0),n.setDate(n.getDate()-1),this.weekId(n,!1);var a=s/7,c=Math.floor(a)+1;if(53==c){n.setTime(t.getTime()),n.setDate(n.getDate()-1);var h=n.getDay();if(0==h&&(h=7),e&&(!o||h<4))return n.setFullYear(n.getFullYear()+1),n.setDate(1),n.setMonth(0),this.weekId(n,!1)}return parseInt(i+"00"+(c>9?"":"0")+c)},t.diffDay=function(t,e,n){void 0===n&&(n=!1);var i=(t.getTime()-e.getTime())/864e5;return n?Math.ceil(i):Math.floor(i)},t.getFirstDayOfWeek=function(t){var e=(t=t||new Date).getDay()||7;return new Date(t.getFullYear(),t.getMonth(),t.getDate()+1-e,0,0,0,0)},t.getFirstOfDay=function(t){return(t=t||new Date).setHours(0,0,0,0),t},t.getNextFirstOfDay=function(t){return new Date(this.getFirstOfDay(t).getTime()+864e5)},t.formatDate=function(t){var e=t.getFullYear(),n=t.getMonth()+1;n=n<10?"0"+n:n;var i=t.getDate();return e+"-"+n+"-"+(i=i<10?"0"+i:i)},t.formatDateTime=function(t){var e=t.getFullYear(),n=t.getMonth()+1;n=n<10?"0"+n:n;var i=t.getDate();i=i<10?"0"+i:i;var r=t.getHours(),o=t.getMinutes();o=o<10?"0"+o:o;var s=t.getSeconds();return e+"-"+n+"-"+i+" "+r+":"+o+":"+(s=s<10?"0"+s:s)},t.parseDate=function(t){var e=Date.parse(t);return isNaN(e)?new Date:new Date(Date.parse(t.replace(/-/g,"/")))},t.secondToTime=function(t,e,n){void 0===t&&(t=0),void 0===e&&(e=":"),void 0===n&&(n=!0);var i=Math.floor(t/3600),r=Math.floor(t%3600/60),o=Math.floor(t%3600%60),s=i.toString(),a=r.toString(),c=o.toString();return i<10&&(s="0"+s),r<10&&(a="0"+a),o<10&&(c="0"+c),n?s+e+a+e+c:a+e+c},t.timeToMillisecond=function(t,e){void 0===e&&(e=":");for(var n=t.split(e),i=0,r=n.length,o=0;on?n:t},e.pointOnCirlce=function(n,i,r){var o=e.toRadians(r);return new t.Vector2(Math.cos(o)*o+n.x,Math.sin(o)*o+n.y)},e.isEven=function(t){return t%2==0},e.clamp01=function(t){return t<0?0:t>1?1:t},e.angleBetweenVectors=function(t,e){return Math.atan2(e.y-t.y,e.x-t.x)},e.incrementWithWrap=function(t,e){return++t==e?0:t},e.approach=function(t,e,n){return ti&&(i=s.x),s.yr&&(r=s.y)}return this.fromMinMax(e,n,i,r)},e.prototype.getSide=function(e){switch(e){case t.Edge.top:return this.top;case t.Edge.bottom:return this.bottom;case t.Edge.left:return this.left;case t.Edge.right:return this.right;default:throw new Error("Argument Out Of Range")}},e.prototype.contains=function(t,e){return this.x<=t&&tthis.x+this.width)return!1}else{var i=1/t.direction.x,r=(this.x-t.start.x)*i,o=(this.x+this.width-t.start.x)*i;if(r>o){var s=r;r=o,o=s}if(e.value=Math.max(r,e.value),n=Math.min(o,n),e.value>n)return!1}if(Math.abs(t.direction.y)<1e-6){if(t.start.ythis.y+this.height)return!1}else{var a=1/t.direction.y,c=(this.y-t.start.y)*a,h=(this.y+this.height-t.start.y)*a;if(c>h){var u=c;c=h,h=u}if(e.value=Math.max(c,e.value),n=Math.max(h,n),e.value>n)return!1}return!0},e.prototype.containsRect=function(t){return this.x<=t.x&&t.x0?this.x:this.x+t,i.y=n>0?this.y:this.y+n,i.width=t>0?t+this.width:this.width-t,i.height=n>0?n+this.height:this.height-n,i},e.prototype.collisionCheck=function(t,e,n){e.value=n.value=0;var i=t.x-(this.x+this.width),r=t.x+t.width-this.x,o=t.y-(this.y+this.height),s=t.y+t.height-this.y;return!(i>0||r<0||o>0||s<0)&&(e.value=Math.abs(i)=l||Math.abs(u)>=p)return t.Vector2.zero;var f=h>0?l-h:-l-h,d=u>0?p-u:-p-u;return new t.Vector2(f,d)},e.prototype.equals=function(t){return this===t},e.prototype.getHashCode=function(){return this.x^this.y^this.width^this.height},e.emptyRectangle=new e,e}();t.Rectangle=e}(es||(es={})),function(t){var e=function(){function t(){this.remainder=0}return t.prototype.update=function(t){this.remainder+=t;var e=Math.floor(Math.trunc(this.remainder));return this.remainder-=e,t=e},t.prototype.reset=function(){this.remainder=0},t}();t.SubpixelFloat=e}(es||(es={})),function(t){var e=function(){function e(){this._x=new t.SubpixelFloat,this._y=new t.SubpixelFloat}return e.prototype.update=function(t){t.x=this._x.update(t.x),t.y=this._y.update(t.y)},e.prototype.reset=function(){this._x.reset(),this._y.reset()},e}();t.SubpixelVector2=e}(es||(es={})),function(t){var e=function(){return function(t,e,n){this.x=t,this.y=e,this.z=n}}();t.Vector3=e}(es||(es={})),function(t){var e=function(){function e(t){this._activeTriggerIntersections=[],this._previousTriggerIntersections=[],this._tempTriggerList=[],this._entity=t}return e.prototype.update=function(){for(var e=this._entity.getComponents(t.Collider),n=0;n1)return!1;var u=(c.x*o.y-c.y*o.x)/a;return!(u<0||u>1)},n.lineToLineIntersection=function(e,n,i,r){var o=new t.Vector2(0,0),s=t.Vector2.subtract(n,e),a=t.Vector2.subtract(r,i),c=s.x*a.y-s.y*a.x;if(0==c)return o;var h=t.Vector2.subtract(i,e),u=(h.x*a.y-h.y*a.x)/c;if(u<0||u>1)return o;var l=(h.x*s.y-h.y*s.x)/c;return l<0||l>1?o:o=t.Vector2.add(e,new t.Vector2(u*s.x,u*s.y))},n.closestPointOnLine=function(e,n,i){var r=t.Vector2.subtract(n,e),o=t.Vector2.subtract(i,e),s=t.Vector2.dot(o,r)/t.Vector2.dot(r,r);return s=t.MathHelper.clamp(s,0,1),t.Vector2.add(e,new t.Vector2(r.x*s,r.y*s))},n.circleToCircle=function(e,n,i,r){return t.Vector2.distanceSquared(e,i)<(n+r)*(n+r)},n.circleToLine=function(e,n,i,r){return t.Vector2.distanceSquared(e,this.closestPointOnLine(i,r,e))=t&&r.y>=e&&r.x=t+i&&(s|=e.right),o.y=n+r&&(s|=e.bottom),s},n}();t.Collisions=n}(es||(es={})),function(t){var e=function(){function e(e,n,i,r,o){this.fraction=0,this.distance=0,this.point=t.Vector2.zero,this.normal=t.Vector2.zero,this.collider=e,this.fraction=n,this.distance=i,this.point=r,this.centroid=t.Vector2.zero}return e.prototype.setValues=function(t,e,n,i){this.collider=t,this.fraction=e,this.distance=n,this.point=i},e.prototype.setValuesNonCollider=function(t,e,n,i){this.fraction=t,this.distance=e,this.point=n,this.normal=i},e.prototype.reset=function(){this.collider=null,this.fraction=this.distance=0},e.prototype.toString=function(){return"[RaycastHit] fraction: "+this.fraction+", distance: "+this.distance+", normal: "+this.normal+", centroid: "+this.centroid+", point: "+this.point},e}();t.RaycastHit=e}(es||(es={})),function(t){var e=function(){function e(){}return e.reset=function(){this._spatialHash=new t.SpatialHash(this.spatialHashCellSize)},e.clear=function(){this._spatialHash.clear()},e.overlapCircleAll=function(t,e,n,i){if(void 0===i&&(i=-1),0!=n.length)return this._spatialHash.overlapCircle(t,e,n,i);console.error("An empty results array was passed in. No results will ever be returned.")},e.boxcastBroadphase=function(t,e){return void 0===e&&(e=this.allLayers),this._spatialHash.aabbBroadphase(t,null,e)},e.boxcastBroadphaseExcludingSelf=function(t,e,n){return void 0===n&&(n=this.allLayers),this._spatialHash.aabbBroadphase(e,t,n)},e.addCollider=function(t){e._spatialHash.register(t)},e.removeCollider=function(t){e._spatialHash.remove(t)},e.updateCollider=function(t){this._spatialHash.remove(t),this._spatialHash.register(t)},e.linecast=function(t,n,i){return void 0===i&&(i=e.allLayers),this._hitArray[0].reset(),this.linecastAll(t,n,this._hitArray,i),this._hitArray[0]},e.linecastAll=function(t,n,i,r){return void 0===r&&(r=e.allLayers),0==i.length?(console.warn("传入了一个空的hits数组。没有点击会被返回"),0):this._spatialHash.linecast(t,n,i,r)},e.debugDraw=function(t){this._spatialHash.debugDraw(t,2)},e.spatialHashCellSize=100,e.allLayers=-1,e.raycastsHitTriggers=!1,e.raycastsStartInColliders=!1,e._hitArray=[new t.RaycastHit],e}();t.Physics=e}(es||(es={})),function(t){var e=function(){return function(e,n){this.start=e,this.end=n,this.direction=t.Vector2.subtract(this.end,this.start)}}();t.Ray2D=e}(es||(es={})),function(t){var e=function(){function e(e){void 0===e&&(e=100),this.gridBounds=new t.Rectangle,this._overlapTestCircle=new t.Circle(0),this._cellDict=new n,this._tempHashSet=[],this._cellSize=e,this._inverseCellSize=1/this._cellSize,this._raycastParser=new i}return e.prototype.register=function(e){var n=e.bounds;e.registeredPhysicsBounds=n;var i=this.cellCoords(n.x,n.y),r=this.cellCoords(n.right,n.bottom);this.gridBounds.contains(i.x,i.y)||(this.gridBounds=t.RectangleExt.union(this.gridBounds,i)),this.gridBounds.contains(r.x,r.y)||(this.gridBounds=t.RectangleExt.union(this.gridBounds,r));for(var o=i.x;o<=r.x;o++)for(var s=i.y;s<=r.y;s++){var a=this.cellAtPosition(o,s,!0);a.firstOrDefault(function(t){return t==e})||a.push(e)}},e.prototype.remove=function(t){for(var e=t.registeredPhysicsBounds,n=this.cellCoords(e.x,e.y),i=this.cellCoords(e.right,e.bottom),r=n.x;r<=i.x;r++)for(var o=n.y;o<=i.y;o++){var s=this.cellAtPosition(r,o);s?s.remove(t):console.log("从不存在碰撞器的单元格中移除碰撞器: ["+t+"]")}},e.prototype.removeWithBruteForce=function(t){this._cellDict.remove(t)},e.prototype.clear=function(){this._cellDict.clear()},e.prototype.debugDraw=function(t,e){void 0===e&&(e=1);for(var n=this.gridBounds.x;n<=this.gridBounds.right;n++)for(var i=this.gridBounds.y;i<=this.gridBounds.bottom;i++){var r=this.cellAtPosition(n,i);r&&r.length>0&&this.debugDrawCellDetails(n,i,r.length,t,e)}},e.prototype.aabbBroadphase=function(e,n,i){this._tempHashSet.length=0;for(var r=this.cellCoords(e.x,e.y),o=this.cellCoords(e.right,e.bottom),s=r.x;s<=o.x;s++)for(var a=r.y;a<=o.y;a++){var c=this.cellAtPosition(s,a);if(c)for(var h=function(r){var o=c[r];if(o==n||!t.Flags.isFlagSet(i,o.physicsLayer.value))return"continue";e.intersects(o.bounds)&&(u._tempHashSet.firstOrDefault(function(t){return t==o})||u._tempHashSet.push(o))},u=this,l=0;l=this.points.length?this.points[0]:this.points[i+1];var o=t.Vector2Ext.perpendicular(r,e);t.Vector2Ext.normalize(o),this._edgeNormals[i]=o}},n.buildSymmetricalPolygon=function(e,n){for(var i=new Array(e),r=0;rr&&(r=s,i=o)}return e[i]},n.getClosestPointOnPolygonToPoint=function(e,n,i,r){i.value=Number.MAX_VALUE,r.x=0,r.y=0;for(var o=new t.Vector2(0,0),s=0,a=0;at.y!=this.points[i].y>t.y&&t.x<(this.points[i].x-this.points[n].x)*(t.y-this.points[n].y)/(this.points[i].y-this.points[n].y)+this.points[n].x&&(e=!e);return e},n.prototype.pointCollidesWithShape=function(e,n){return t.ShapeCollisions.pointToPoly(e,this,n)},n}(t.Shape);t.Polygon=e}(es||(es={})),function(t){var e=function(e){function n(t,i){var r=e.call(this,n.buildBox(t,i),!0)||this;return r.width=t,r.height=i,r}return __extends(n,e),n.buildBox=function(e,n){var i=e/2,r=n/2,o=new Array(4);return o[0]=new t.Vector2(-i,-r),o[1]=new t.Vector2(i,-r),o[2]=new t.Vector2(i,r),o[3]=new t.Vector2(-i,r),o},n.prototype.updateBox=function(e,n){this.width=e,this.height=n;var i=e/2,r=n/2;this.points[0]=new t.Vector2(-i,-r),this.points[1]=new t.Vector2(i,-r),this.points[2]=new t.Vector2(i,r),this.points[3]=new t.Vector2(-i,r);for(var o=0;o1)return!1;var a,c=t.Vector2.add(s.start,t.Vector2.add(s.direction,new t.Vector2(r.value))),h=0;c.xn.bounds.right&&(h|=1),c.yn.bounds.bottom&&(h|=2);var u=a+h;return 3==u&&console.log("m == 3. corner "+t.Time.frameCount),!0},e}();t.RealtimeCollisions=e}(es||(es={})),function(t){var e=function(){function e(){}return e.polygonToPolygon=function(e,n,i){for(var r,o=!0,s=e.edgeNormals,a=n.edgeNormals,c=Number.POSITIVE_INFINITY,h=new t.Vector2,u=t.Vector2.subtract(e.position,n.position),l=0;l0&&(o=!1),!o)return!1;(m=Math.abs(m))r&&(r=o);return{min:i,max:r}},e.circleToPolygon=function(e,n,i){var r,o=t.Vector2.subtract(e.position,n.position),s=new t.Ref(0),a=t.Polygon.getClosestPointOnPolygonToPoint(n.points,o,s,i.normal),c=n.containsPoint(e.position);if(s.value>e.radius*e.radius&&!c)return!1;if(c)r=t.Vector2.multiply(i.normal,new t.Vector2(Math.sqrt(s.value)-e.radius));else if(0==s.value)r=t.Vector2.multiply(i.normal,new t.Vector2(e.radius));else{var h=Math.sqrt(s.value);r=t.Vector2.multiply(new t.Vector2(-t.Vector2.subtract(o,a)),new t.Vector2((e.radius-s.value)/h))}return i.minimumTranslationVector=r,i.point=t.Vector2.add(a,n.position),!0},e.circleToBox=function(e,n,i){var r=n.bounds.getClosestPointOnRectangleBorderToPoint(e.position,i.normal);if(n.containsPoint(e.position)){i.point=r;var o=t.Vector2.add(r,t.Vector2.multiply(i.normal,new t.Vector2(e.radius)));return i.minimumTranslationVector=t.Vector2.subtract(e.position,o),!0}var s=t.Vector2.distanceSquared(r,e.position);if(0==s)i.minimumTranslationVector=t.Vector2.multiply(i.normal,new t.Vector2(e.radius));else if(s<=e.radius*e.radius){i.normal=t.Vector2.subtract(e.position,r);var a=i.normal.length()-e.radius;return i.point=r,t.Vector2Ext.normalize(i.normal),i.minimumTranslationVector=t.Vector2.multiply(new t.Vector2(a),i.normal),!0}return!1},e.pointToCircle=function(e,n,i){var r=t.Vector2.distanceSquared(e,n.position),o=1+n.radius;if(r1)return!1;var l=(h.x*s.y-h.y*s.x)/c;return!(l<0||l>1)&&(o=o.add(e).add(t.Vector2.multiply(new t.Vector2(u),s)),!0)},e.lineToCircle=function(e,n,i,r){var o=t.Vector2.distance(e,n),s=t.Vector2.divide(t.Vector2.subtract(n,e),new t.Vector2(o)),a=t.Vector2.subtract(e,i.position),c=t.Vector2.dot(a,s),h=t.Vector2.dot(a,a)-i.radius*i.radius;if(h>0&&c>0)return!1;var u=c*c-h;return!(u<0)&&(r.fraction=-c-Math.sqrt(u),r.fraction<0&&(r.fraction=0),r.point=t.Vector2.add(e,t.Vector2.multiply(new t.Vector2(r.fraction),s)),r.distance=t.Vector2.distance(e,r.point),r.normal=t.Vector2.normalize(t.Vector2.subtract(r.point,i.position)),r.fraction=r.distance/o,!0)},e.boxToBoxCast=function(e,n,i,r){var o=this.minkowskiDifference(e,n);if(o.contains(0,0)){var s=o.getClosestPointOnBoundsToOrigin();return!s.equals(t.Vector2.zero)&&(r.normal=new t.Vector2(-s.x),r.normal.normalize(),r.distance=0,r.fraction=0,!0)}var a=new t.Ray2D(t.Vector2.zero,new t.Vector2(-i.x)),c=new t.Ref(0);return!!(o.rayIntersects(a,c)&&c.value<=1)&&(r.fraction=c.value,r.distance=i.length()*c.value,r.normal=new t.Vector2(-i.x,-i.y),r.normal.normalize(),r.centroid=t.Vector2.add(e.bounds.center,t.Vector2.multiply(i,new t.Vector2(c.value))),!0)},e}();t.ShapeCollisions=e}(es||(es={})),function(t){var e=function(){function e(){this.mass=1,this.radius=0,this.collidesWithColliders=!0}return e.prototype.applyForce=function(e){this.acceleration.add(t.Vector2.divide(e,new t.Vector2(this.mass)))},e}();t.Particle=e}(es||(es={})),function(t){var e=function(){function e(e){void 0===e&&(e=null),this.gravity=new t.Vector2(0,980),this.constraintIterations=3,this.maximumStepIterations=5,this.allowDragging=!0,this._composites=[],this._tempCircle=new t.Circle(1),this._leftOverTime=0,this._fixedDeltaTime=1/60,this._iterationSteps=0,this._fixedDeltaTimeSq=0,this.simulationBounds=e,this._fixedDeltaTimeSq=Math.pow(this._fixedDeltaTimeSq,2)}return e.prototype.update=function(){this.updateTiming(),this.allowDragging&&this.handleDragging();for(var t=1;t<=this._iterationSteps;t++)for(var e=this._composites.length-1;e>=0;e--){for(var n=this._composites[e],i=0;in.height?e.y=n.height:e.yn.width&&(e.x=n.width)):(e.yn.height-t.radius&&(e.y=2*(n.height-t.radius)-e.y),e.x>n.width-t.radius&&(e.x=2*(n.width-t.radius)-e.x),e.x=0;t--)this._constraints[t].solve()},e.prototype.updateParticles=function(e,n){for(var i=0;i=0;t--)this._constraints[t].collidesWithColliders&&this._constraints[t].handleCollisions(this.collidesWithLayers)},e.prototype.debugRender=function(t){},e}();t.Composite=e}(es||(es={})),function(t){var e=function(){function t(){this.collidesWithColliders=!0}return t.prototype.handleCollisions=function(t){},t}();t.Constraint=e}(es||(es={}));var ArrayUtils=function(){function t(){}return t.bubbleSort=function(t){for(var e=!1,n=0;nn;i--)if(t[i]0&&t[r-1]>i;r--)t[r]=t[r-1];t[r]=i}},t.binarySearch=function(t,e){for(var n=0,i=t.length,r=n+i>>1;n=t[r]&&(n=r+1),r=n+i>>1;return t[n]==e?n:-1},t.findElementIndex=function(t,e){for(var n=t.length,i=0;it[e]&&(e=i);return e},t.getMinElementIndex=function(t){for(var e=0,n=t.length,i=1;i=0;--r)n.unshift(e[r]);return n},t.getDifferAry=function(t,e){t=this.getUniqueAry(t),e=this.getUniqueAry(e);for(var n=t.concat(e),i={},r=[],o=n.length,s=0;s=0;e-=1)t.splice(e,1)},t.cloneList=function(t){return t?t.slice(0,t.length):null},t.equals=function(t,e){if(t==e)return!0;var n=t.length;if(n!=e.length)return!1;for(;n--;)if(t[n]!=e[n])return!1;return!0},t.insert=function(t,e,n){if(!t)return null;var i=t.length;if(e>i&&(e=i),e<0&&(e=0),e==i)t.push(n);else if(0==e)t.unshift(n);else{for(var r=i-1;r>=e;r-=1)t[r+1]=t[r];t[e]=n}return n},t}();!function(t){var e=function(){function t(){}return Object.defineProperty(t,"nativeBase64",{get:function(){return"function"==typeof window.atob},enumerable:!0,configurable:!0}),t.decode=function(t){if(t=t.replace(/[^A-Za-z0-9\+\/\=]/g,""),this.nativeBase64)return window.atob(t);for(var e,n,i,r,o,s,a=[],c=0;c>4,n=(15&r)<<4|(o=this._keyStr.indexOf(t.charAt(c++)))>>2,i=(3&o)<<6|(s=this._keyStr.indexOf(t.charAt(c++))),a.push(String.fromCharCode(e)),64!==o&&a.push(String.fromCharCode(n)),64!==s&&a.push(String.fromCharCode(i));return a=a.join("")},t.encode=function(t){if(t=t.replace(/\r\n/g,"\n"),!this.nativeBase64){for(var e,n,i,r,o,s,a,c=[],h=0;h>2,o=(3&e)<<4|(n=t.charCodeAt(h++))>>4,s=(15&n)<<2|(i=t.charCodeAt(h++))>>6,a=63&i,isNaN(n)?s=a=64:isNaN(i)&&(a=64),c.push(this._keyStr.charAt(r)),c.push(this._keyStr.charAt(o)),c.push(this._keyStr.charAt(s)),c.push(this._keyStr.charAt(a));return c=c.join("")}window.btoa(t)},t.decodeBase64AsArray=function(e,n){n=n||1;var i,r,o,s=t.decode(e),a=new Uint32Array(s.length/n);for(i=0,o=s.length/n;i=0;--r)a[i]+=s.charCodeAt(i*n+r)<<(r<<3);return a},t.decompress=function(t,e,n){throw new Error("GZIP/ZLIB compressed TMX Tile Map not supported!")},t.decodeCSV=function(t){for(var e=t.replace("\n","").trim().split(","),n=[],i=0;i>16},set:function(t){this._packedValue=4278255615&this._packedValue|t<<16},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"g",{get:function(){return this._packedValue>>8},set:function(t){this._packedValue=4294902015&this._packedValue|t<<8},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"r",{get:function(){return this._packedValue},set:function(t){this._packedValue=4294967040&this._packedValue|t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"a",{get:function(){return this._packedValue>>24},set:function(t){this._packedValue=16777215&this._packedValue|t<<24},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"packedValue",{get:function(){return this._packedValue},set:function(t){this._packedValue=t},enumerable:!0,configurable:!0}),e.prototype.equals=function(t){return this._packedValue==t._packedValue},e}();t.Color=e}(es||(es={})),function(t){var e=function(){function e(){}return e.oppositeEdge=function(e){switch(e){case t.Edge.bottom:return t.Edge.top;case t.Edge.top:return t.Edge.bottom;case t.Edge.left:return t.Edge.right;case t.Edge.right:return t.Edge.left}},e.isHorizontal=function(e){return e==t.Edge.right||e==t.Edge.left},e.isVertical=function(e){return e==t.Edge.top||e==t.Edge.bottom},e}();t.EdgeExt=e}(es||(es={})),function(t){var e=function(){return function(t,e){this.func=t,this.context=e}}();t.FuncPack=e;var n=function(){function t(){this._messageTable=new Map}return t.prototype.addObserver=function(t,n,i){var r=this._messageTable.get(t);r||(r=[],this._messageTable.set(t,r)),-1!=r.findIndex(function(t){return t.func==n})&&console.warn("您试图添加相同的观察者两次"),r.push(new e(n,i))},t.prototype.removeObserver=function(t,e){var n=this._messageTable.get(t),i=n.findIndex(function(t){return t.func==e});-1!=i&&n.removeAt(i)},t.prototype.emit=function(t,e){var n=this._messageTable.get(t);if(n)for(var i=n.length-1;i>=0;i--)n[i].func.call(n[i].context,e)},t}();t.Emitter=n}(es||(es={})),function(t){!function(t){t[t.top=0]="top",t[t.bottom=1]="bottom",t[t.left=2]="left",t[t.right=3]="right"}(t.Edge||(t.Edge={}))}(es||(es={})),function(t){var e=function(){function t(){}return t.repeat=function(t,e){for(var n=[];e--;)n.push(t);return n},t}();t.Enumerable=e}(es||(es={})),function(t){var e=function(){function t(){}return t.default=function(){return new t},t.prototype.equals=function(t,e){return"function"==typeof t.equals?t.equals(e):t===e},t}();t.EqualityComparer=e}(es||(es={})),function(t){var e=function(){function t(){}return Object.defineProperty(t.prototype,"enabled",{get:function(){return this._enabled},set:function(t){this.setEnabled(t)},enumerable:!0,configurable:!0}),t.prototype.setEnabled=function(t){this._enabled!=t&&(this._enabled=t,this._enabled?this.onEnabled():this.onDisabled())},t.prototype.onEnabled=function(){},t.prototype.onDisabled=function(){},t.prototype.update=function(){},t}();t.GlobalManager=e}(es||(es={})),function(t){var e=function(){function t(){}return t.warmCache=function(t){if((t-=this._objectQueue.length)>0)for(var e=0;ethis._objectQueue.length;)this._objectQueue.shift()},t.clearCache=function(){this._objectQueue.length=0},t.obtain=function(){return this._objectQueue.length>0?this._objectQueue.shift():[]},t.free=function(t){this._objectQueue.unshift(t),t.length=0},t._objectQueue=[],t}();t.ListPool=e}(es||(es={})),function(t){var e=function(){function t(){}return t.toNumber=function(t){return null==t?0:Number(t)},t}();t.NumberExtension=e}(es||(es={})),function(t){var e=function(){function t(t,e){this.first=t,this.second=e}return t.prototype.clear=function(){this.first=this.second=null},t.prototype.equals=function(t){return this.first==t.first&&this.second==t.second},t}();t.Pair=e}(es||(es={})),function(t){var e=function(){function e(){}return e.warmCache=function(t,e){if((e-=this._objectQueue.length)>0)for(var n=0;nthis._objectQueue.length;)this._objectQueue.shift()},e.clearCache=function(){this._objectQueue.length=0},e.obtain=function(t){return this._objectQueue.length>0?this._objectQueue.shift():new t},e.free=function(e){this._objectQueue.unshift(e),t.isIPoolable(e)&&e.reset()},e._objectQueue=[],e}();t.Pool=e,t.isIPoolable=function(t){return void 0!==t.js}}(es||(es={}));var RandomUtils=function(){function t(){}return t.randrange=function(t,e,n){if(void 0===n&&(n=1),0==n)throw new Error("step 不能为 0");var i=e-t;if(0==i)throw new Error("没有可用的范围("+t+","+e+")");i<0&&(i=t-e);var r=Math.floor((i+n-1)/n);return Math.floor(this.random()*r)*n+Math.min(t,e)},t.randint=function(t,e){return(t=Math.floor(t))>(e=Math.floor(e))?t++:e++,this.randrange(t,e)},t.randnum=function(t,e){return this.random()*(e-t)+t},t.shuffle=function(t){return t.sort(this._randomCompare),t},t.choice=function(t){if(!t.hasOwnProperty("length"))throw new Error("无法对此对象执行此操作");var e=Math.floor(this.random()*t.length);return t instanceof String?String(t).charAt(e):t[e]},t.sample=function(t,e){var n=t.length;if(e<=0||n=0;)s=Math.floor(this.random()*n);i.push(t[s]),r.push(s)}return i},t.random=function(){return Math.random()},t.boolean=function(t){return void 0===t&&(t=.5),this.random().5?1:-1},t}();!function(t){var e=function(){function e(){}return e.getSide=function(e,n){switch(n){case t.Edge.top:return e.top;case t.Edge.bottom:return e.bottom;case t.Edge.left:return e.left;case t.Edge.right:return e.right}},e.union=function(e,n){var i=new t.Rectangle(n.x,n.y,0,0),r=new t.Rectangle;return r.x=Math.min(e.x,i.x),r.y=Math.min(e.y,i.y),r.width=Math.max(e.right,i.right)-r.x,r.height=Math.max(e.bottom,r.bottom)-r.y,r},e.getHalfRect=function(e,n){switch(n){case t.Edge.top:return new t.Rectangle(e.x,e.y,e.width,e.height/2);case t.Edge.bottom:return new t.Rectangle(e.x,e.y+e.height/2,e.width,e.height/2);case t.Edge.left:return new t.Rectangle(e.x,e.y,e.width/2,e.height);case t.Edge.right:return new t.Rectangle(e.x+e.width/2,e.y,e.width/2,e.height)}},e.getRectEdgePortion=function(e,n,i){switch(void 0===i&&(i=1),n){case t.Edge.top:return new t.Rectangle(e.x,e.y,e.width,i);case t.Edge.bottom:return new t.Rectangle(e.x,e.y+e.height-i,e.width,i);case t.Edge.left:return new t.Rectangle(e.x,e.y,i,e.height);case t.Edge.right:return new t.Rectangle(e.x+e.width-i,e.y,i,e.height)}},e.expandSide=function(e,n,i){switch(i=Math.abs(i),n){case t.Edge.top:e.y-=i,e.height+=i;break;case t.Edge.bottom:e.height+=i;break;case t.Edge.left:e.x-=i,e.width+=i;break;case t.Edge.right:e.width+=i}},e.contract=function(t,e,n){t.x+=e,t.y+=n,t.width-=2*e,t.height-=2*n},e}();t.RectangleExt=e}(es||(es={})),function(t){var e=function(){return function(t){this.value=t}}();t.Ref=e}(es||(es={})),function(t){var e=function(){function t(){}return t.prototype.update=function(t){this.remainder+=t;var e=Math.trunc(this.remainder);return this.remainder-=e,e},t.prototype.reset=function(){this.remainder=0},t}();t.SubpixelNumber=e}(es||(es={})),function(t){var e=function(){function e(){this.triangleIndices=[],this._triPrev=new Array(12),this._triNext=new Array(12)}return e.testPointTriangle=function(e,n,i,r){return!(t.Vector2Ext.cross(t.Vector2.subtract(e,n),t.Vector2.subtract(i,n))<0)&&(!(t.Vector2Ext.cross(t.Vector2.subtract(e,i),t.Vector2.subtract(r,i))<0)&&!(t.Vector2Ext.cross(t.Vector2.subtract(e,r),t.Vector2.subtract(n,r))<0))},e.prototype.triangulate=function(n,i){void 0===i&&(i=!0);var r=n.length;this.initialize(r);for(var o=0,s=0;r>3&&o<500;){o++;var a=!0,c=n[this._triPrev[s]],h=n[s],u=n[this._triNext[s]];if(t.Vector2Ext.isTriangleCCW(c,h,u)){var l=this._triNext[this._triNext[s]];do{if(e.testPointTriangle(n[l],c,h,u)){a=!1;break}l=this._triNext[l]}while(l!=this._triPrev[s])}else a=!1;a?(this.triangleIndices.push(this._triPrev[s]),this.triangleIndices.push(s),this.triangleIndices.push(this._triNext[s]),this._triNext[this._triPrev[s]]=this._triNext[s],this._triPrev[this._triNext[s]]=this._triPrev[s],r--,s=this._triPrev[s]):s=this._triNext[s]}this.triangleIndices.push(this._triPrev[s]),this.triangleIndices.push(s),this.triangleIndices.push(this._triNext[s]),i||this.triangleIndices.reverse()},e.prototype.initialize=function(t){this.triangleIndices.length=0,this._triNext.lengtht.MathHelper.Epsilon?e.divide(new t.Vector2(n)):e.x=e.y=0},e.transformA=function(t,e,n,i,r,o){for(var s=0;sthis._timeInSeconds&&(this._elapsedTime-=this._timeInSeconds,this._onTime(this),this._isDone||this._repeats||(this._isDone=!0)),this._elapsedTime+=t.Time.deltaTime,this._isDone},e.prototype.initialize=function(t,e,n,i){this._timeInSeconds=t,this._repeats=e,this.context=n,this._onTime=i},e.prototype.unload=function(){this.context=null,this._onTime=null},e}();t.Timer=e}(es||(es={})),function(t){var e=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t._timers=[],t}return __extends(n,e),n.prototype.update=function(){for(var t=this._timers.length-1;t>=0;t--)this._timers[t].tick()&&(this._timers[t].unload(),this._timers.removeAt(t))},n.prototype.schedule=function(e,n,i,r){var o=new t.Timer;return o.initialize(e,n,i,r),this._timers.push(o),o},n}(t.GlobalManager);t.TimerManager=e}(es||(es={})); \ No newline at end of file diff --git a/source/lib/assetsmanager.d.ts b/source/lib/assetsmanager.d.ts deleted file mode 100644 index 97a9ee1d..00000000 --- a/source/lib/assetsmanager.d.ts +++ /dev/null @@ -1,1522 +0,0 @@ -declare namespace RES { - /** - * Version control loading interface - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/version/VersionControl.ts - * @language en_US - */ - /** - * 版本控制加载的接口 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/version/VersionControl.ts - * @language zh_CN - */ - interface IVersionController { - /** - * Get the version information data.
- * Before calling this method requires the application of any resource load, we recommend starting at the application entry class (Main) The first call processing. This method is only responsible for acquiring version information, is not responsible for downloaded resources. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 获取版本信息数据。
- * 这个方法的调用需要在应用程序进行任何资源加载之前,建议在应用程序的入口类(Main)的开始最先进行调用处理。此方法只负责获取版本信息,不负责资源的下载。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - init(): Promise; - /** - * Get the actual URL of the resource file.
- * Because this method needs to be called to control the actual version of the URL have the original resource files were changed, so would like to get the specified resource file the actual URL.
- * In the development and debugging phase, this method will directly return value passed. - * @param url Url used in the game - * @returns Actual loaded url - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 获取资源文件实际的URL地址。
- * 由于版本控制实际已经对原来的资源文件的URL进行了改变,因此想获取指定资源文件实际的URL时需要调用此方法。
- * 在开发调试阶段,这个方法会直接返回传入的参数值。 - * @param url 游戏中使用的url - * @returns 实际加载的url - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - getVirtualUrl(url: string): string; - } - /** - * Manage version control class - * @version Egret 2.4 - * @platform Web,Native - * @event egret.Event.COMPLETE Version control loading is complete when thrown - * @event egret.IOErrorEvent.IO_ERROR Version control failed to load when thrown - * @includeExample extension/version/VersionControl.ts - * @language en_US - */ - /** - * 管理版本控制的类 - * @version Egret 2.4 - * @platform Web,Native - * @event egret.Event.COMPLETE 版本控制加载完成时抛出 - * @event egret.IOErrorEvent.IO_ERROR 版本控制加载失败时抛出 - * @includeExample extension/version/VersionControl.ts - * @language zh_CN - */ - interface VersionController extends IVersionController { - } - /** - * @version Egret 2.4 - * @platform Web,Native - */ - let VersionController: { - /** - * Constructor initialization - * @language en_US - */ - /** - * 初始化构造函数 - * @language zh_CN - */ - new (): VersionController; - }; -} -declare type ResourceRootSelector = () => T; -declare type ResourceNameSelector = (file: string) => string; -declare type ResourceMergerSelector = (file: string) => { - path: string; - alias: string; -}; -declare module RES { - /** - * Get resource information through file path - * @param path file path - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 通过文件路径获取资源信息 - * @param path 文件路径 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function getResourceInfo(path: string): File | null; - /** - * @private - */ - interface ResourceInfo { - url: string; - type: string; - root: string; - crc32?: string; - size?: number; - extra?: 1 | undefined; - name: string; - soundType?: string; - scale9grid?: string; - groupNames?: string[]; - promise?: Promise; - } - /** - * @private - */ - interface Data { - resourceRoot: string; - mergeSelector: ResourceMergerSelector | null; - fileSystem: FileSystem; - groups: { - [groupName: string]: string[]; - }; - alias: { - [aliasName: string]: string; - }; - loadGroup: string[]; - } - /** - * @class RES.ResourceConfig - * @classdesc - * @private - */ - class ResourceConfig { - config: Data; - constructor(); - init(): Promise; - /** - * 根据组名获取组加载项列表 - * @method RES.ResourceConfig#getGroupByName - * @param name {string} 组名 - * @returns {Array} - */ - getGroupByName(name: string): ResourceInfo[]; - __temp__get__type__via__url(url_or_alias: string): string; - getResourceWithSubkey(key: string): { - r: ResourceInfo; - key: string; - subkey: string; - } | null; - getKeyByAlias(aliasName: string): string; - getResource(path_or_alias: string): ResourceInfo | null; - /** - * 创建自定义的加载资源组,注意:此方法仅在资源配置文件加载完成后执行才有效。 - * 可以监听ResourceEvent.CONFIG_COMPLETE事件来确认配置加载完成。 - * @method RES.ResourceConfig#createGroup - * @param name {string} 要创建的加载资源组的组名 - * @param keys {egret.Array} 要包含的键名列表,key对应配置文件里的name属性或sbuKeys属性的一项或一个资源组名。 - * @param override {boolean} 是否覆盖已经存在的同名资源组,默认false。 - * @returns {boolean} - */ - createGroup(name: string, keys: Array, override?: boolean): boolean; - /** - * 添加一个二级键名到配置列表。 - * @method RES.ResourceConfig#addSubkey - * @param subkey {string} 要添加的二级键名 - * @param name {string} 二级键名所属的资源name属性 - */ - addSubkey(subkey: string, name: string): void; - addAlias(alias: any, key: any): void; - addResourceData(data: { - name: string; - type: string; - url: string; - root?: string; - extra?: 1 | undefined; - }): void; - removeResourceData(data: { - name: string; - type?: string; - url: string; - root?: string; - extra?: 1 | undefined; - }): void; - } -} -declare module RES { - /** - * @class RES.ResourceLoader - * @classdesc - * @private - */ - class ResourceLoader { - /** - * 当前组加载的项总个数,key为groupName - */ - private groupTotalDic; - /** - * 已经加载的项个数,key为groupName - */ - private numLoadedDic; - /** - * 加载失败的组,key为groupName - */ - private groupErrorDic; - private retryTimesDic; - maxRetryTimes: number; - private reporterDic; - private dispatcherDic; - private failedList; - private loadItemErrorDic; - private errorDic; - /** - * 资源优先级队列,key为资源,value为优先级 - */ - private itemListPriorityDic; - /** - * 资源是否在加载 - */ - private itemLoadDic; - private promiseHash; - /** - * 延迟加载队列,getResByUrl ,getResAsync等方法存储队列 - */ - private lazyLoadList; - pushResItem(resInfo: ResourceInfo): Promise; - /** - * 加载队列,存储组的队列 - */ - pushResGroup(list: ResourceInfo[], groupName: string, priority: number, reporter?: PromiseTaskReporter): Promise; - /** - * 更新组的优先级顺序 - * @param list 存储数据的队列 - * @param priority 优先级 - */ - private updatelistPriority(list, priority); - /** - * 搜索单项资源的优先级 - * @param item 单项资源 - */ - private findPriorityInDic(item); - private loadingCount; - /** - * 最大线程数目 - */ - thread: number; - /** - * 加载下一项资源,线程控制 - */ - private loadNextResource(); - /** - * 加载单向资源 - */ - private loadSingleResource(); - /** - * 获取下一个待加载项 - */ - private getOneResourceInfoInGroup(); - /** - * 设置组的加载进度,同时返回当前组是否加载完成 - * @param groupName 组名 - * @param r 加载完成的资源 - */ - private setGroupProgress(groupName, r); - /** - * 加载组的最后一项,同时派发事件 - * @param groupName 组名 - * @param lastError 最后一项是否成功,此项为错误信息 - */ - private loadGroupEnd(groupName, lastError?); - /** - * 删除事件派发器,Promise的缓存,返回事件派发器 - * @param groupName 组名或是root+name - */ - private deleteDispatcher(groupName); - /** - * 加载资源 - * @param r 资源信息 - * @param p 加载处理器 - */ - private loadResource(r, p?); - /** - * 释放资源 - * @param r 资源信息 - */ - unloadResource(r: ResourceInfo): boolean; - } -} -declare module RES { -} -declare module RES { - type GetResAsyncCallback = (value?: any, key?: string) => any; - /** - * Convert the file name of the resource to the Key value used in the project. - * @param url Resource Name. - * @returns The key value used in the project - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 将资源的文件名称转换为项目中所使用的Key值。 - * 在加载合并图集的时候使用,例如图集加载A_json,需要加载对应A_png,这里就是转换的机制 - * 一般项目中无需更改,只有没有使用默认的key和文件对应的需要修改 - * @param url 资源名称。 - * @returns 项目中所用的key值 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function nameSelector(url: any): string; - /** - * Get the read type of the file. - * When using getResByUrl does not specify the type of the read file, it will find the corresponding type according to this method. - * File types not found are loaded by default in binary format - * @param path file path. - * @returns Processor type used to read the file - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 获取文件的读取类型 - * 在使用getResByUrl没有指定读取文件的类型,会根据这个方法寻找对应的类型 - * 没有查找到的文件类型以二进制格式默认加载 - * @param path 文件路径 - * @returns 读取文件所用的Processor类型 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function typeSelector(path: string): string; - /** - * Conduct mapping injection with class definition as the value, Deprecated. - * @deprecated - * @see RES.processor.map - * @language en_US - */ - /** - * 以类定义为值进行映射注入,已废弃。 - * @deprecated - * @see RES.processor.map - * @language zh_CN - */ - function registerAnalyzer(type: string, analyzerClass: any): void; - /** - * Set whether it is compatible mode - * When the value is true, the assetsManager will output the design of Res. When it is false, all the loaded resources will be returned as promises. - * The default is false, run in strict assetsManager mode - * @version Egret 5.2.9 - * @platform Web,Native - * @language en_US - */ - /** - * 设置是否为兼容模式 - * 当值为true时,assetsManager会以Res的设计输出,当为false时候,所有的加载资源都会以promise的方式返回 - * 默认是false,以严格assetsManager方式运行 - * @version Egret 5.2.9 - * @platform Web,Native - * @language zh_CN - */ - function setIsCompatible(value: boolean): void; - /** - * Load configuration file and parse. - * @param url The url address of the resource config - * @param resourceRoot The root address of the resource config - * @returns Promise - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 加载配置文件并解析。 - * @param url 资源配置的url地址 - * @param resourceRoot 资源配置的根地址 - * @returns Promise - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function loadConfig(url: string, resourceRoot: string): Promise; - /** - * Load a set of resources according to the group name. - * @param name Group name to load the resource group. - * @param priority Load priority can be negative, the default value is 0. - *
A low priority group must wait for the high priority group to complete the end of the load to start, and the same priority group will be loaded at the same time. - * @param reporter Resource group loading progress prompt - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 根据组名加载一组资源。 - * @param name 要加载资源组的组名。 - * @param priority 加载优先级,可以为负数,默认值为 0。 - *
低优先级的组必须等待高优先级组完全加载结束才能开始,同一优先级的组会同时加载。 - * @param reporter 资源组的加载进度提示 - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function loadGroup(name: string, priority?: number, reporter?: PromiseTaskReporter): Promise; - /** - * Check whether a resource group has been loaded. - * @param name Group name。 - * @returns Is loading or not. - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 检查某个资源组是否已经加载完成。 - * @param name 组名。 - * @returns 是否正在加载。 - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function isGroupLoaded(name: string): boolean; - /** - * A list of groups of loading is obtained according to the group name. - * @param name Group name. - * @returns The resource item array of group. - * @see RES.ResourceItem - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 根据组名获取组加载项列表。 - * @param name 组名。 - * @returns 加载项列表。 - * @see RES.ResourceItem - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function getGroupByName(name: string): Array; - /** - * Create a custom load resource group, note that this method is valid only after the resource configuration file is loaded. - *
You can monitor the ResourceEvent.CONFIG_COMPLETE event to verify that the configuration is complete. - * @param name Group name to create the load resource group. - * @param keys To be included in the list of key keys, the corresponding configuration file in the name or sbuKeys property one or a resource group name. - * @param override Is the default false for the same name resource group already exists. - * @returns Create success or fail. - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 创建自定义的加载资源组,注意:此方法仅在资源配置文件加载完成后执行才有效。 - *
可以监听 ResourceEvent.CONFIG_COMPLETE 事件来确认配置加载完成。 - * @param name 要创建的加载资源组的组名。 - * @param keys 要包含的键名列表,key 对应配置文件里的 name 属性或 sbuKeys 属性的一项或一个资源组名。 - * @param override 是否覆盖已经存在的同名资源组,默认 false。 - * @returns 是否创建成功。 - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function createGroup(name: string, keys: Array, override?: boolean): boolean; - /** - * Check whether the configuration file contains the specified resources. - * @param key A sbuKeys attribute or name property in a configuration file. - * @returns Whether you have the specified resource - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 检查配置文件里是否含有指定的资源。 - * @param key 对应配置文件里的 name 属性或 sbuKeys 属性的一项。 - * @returns 是否拥有指定资源 - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function hasRes(key: string): boolean; - /** - * The synchronization method for obtaining the cache has been loaded with the success of the resource. - *
The type of resource and the corresponding return value types are as follows: - *
RES.ResourceItem.TYPE_BIN : ArrayBuffer JavaScript primary object - *
RES.ResourceItem.TYPE_IMAGE : img Html Object,or egret.BitmapData interface。 - *
RES.ResourceItem.TYPE_JSON : Object - *
RES.ResourceItem.TYPE_SHEET : Object - *
1. If the incoming parameter is the name of the entire SpriteSheet is returned is {image1: Texture, "image2": Texture}. - *
2. If the incoming is "sheet.image1", the return is a single resource. - *
3. If the incoming is the name of the "image1" single resource, the return is a single resource. - * But if there are two SpriteSheet in a single picture of the same name, the return of the image after the load. - *
RES.ResourceItem.TYPE_SOUND : HtmlSound Html Object - *
RES.ResourceItem.TYPE_TEXT : string - * @param key A subKeys attribute or name property in a configuration file. - * @see RES.ResourceItem - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 同步方式获取缓存的已经加载成功的资源。 - *
资源类型和对应的返回值类型关系如下: - *
RES.ResourceItem.TYPE_BIN : ArrayBuffer JavaScript 原生对象 - *
RES.ResourceItem.TYPE_IMAGE : img Html 对象,或者 egret.BitmapData 接口。 - *
RES.ResourceItem.TYPE_JSON : Object - *
RES.ResourceItem.TYPE_SHEET : Object - *
1. 如果传入的参数是整个 SpriteSheet 的名称返回的是 {"image1":Texture,"image2":Texture} 这样的格式。 - *
2. 如果传入的是 "sheet.image1",返回的是单个资源。 - *
3. 如果传入的是 "image1" 单个资源的名称,返回的是单个资源。但是如果有两张 SpriteSheet 中有单个图片资源名称相同,返回的是后加载的那个图片资源。 - *
RES.ResourceItem.TYPE_SOUND : HtmlSound Html 对象 - *
RES.ResourceItem.TYPE_TEXT : string - * @param key 对应配置文件里的 name 属性或 subKeys 属性的一项。 - * @see RES.ResourceItem - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function getRes(key: string): any; - /** - * Asynchronous mode to get the resources in the configuration. As long as the resources exist in the configuration file, you can get it in an asynchronous way. - * @param key A sbuKeys attribute or name property in a configuration file. - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 异步方式获取配置里的资源。只要是配置文件里存在的资源,都可以通过异步方式获取。 - * @param key 对应配置文件里的 name 属性或 sbuKeys 属性的一项。 - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function getResAsync(key: string): Promise; - /** - * Asynchronous mode to get the resources in the configuration. As long as the resources exist in the configuration file, you can get it in an asynchronous way. - * @param key A sbuKeys attribute or name property in a configuration file. - * @param compFunc Call back function. Example:compFunc(data,key):void. - * @param thisObject This pointer of call back function. - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 异步方式获取配置里的资源。只要是配置文件里存在的资源,都可以通过异步方式获取。 - * @param key 对应配置文件里的 name 属性或 sbuKeys 属性的一项。 - * @param compFunc 回调函数。示例:compFunc(data,key):void。 - * @param thisObject 回调函数的 this 引用。 - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function getResAsync(key: string, compFunc: GetResAsyncCallback, thisObject: any): Promise | void; - /** - * Access to external resources through the full URL. - * @param url The external path to load the file. - * @param compFunc Call back function. Example:compFunc(data,url):void。 - * @param thisObject This pointer of call back function. - * @param type File type (optional). Use the static constants defined in the ResourceItem class. If you do not set the file name extension. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 通过完整URL方式获取外部资源。 - * @param url 要加载文件的外部路径。 - * @param compFunc 回调函数。示例:compFunc(data,url):void。 - * @param thisObject 回调函数的 this 引用。 - * @param type 文件类型(可选)。请使用 ResourceItem 类中定义的静态常量。若不设置将根据文件扩展名生成。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function getResByUrl(url: string, compFunc?: Function, thisObject?: any, type?: string): Promise; - /** - * Destroy a single resource file or a set of resources to the cache data, to return whether to delete success. - * @param name Name attribute or resource group name of the load item in the configuration file. - * @param force Destruction of a resource group when the other resources groups have the same resource situation whether the resources will be deleted, the default value true. - * @returns Are successful destruction. - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 销毁单个资源文件或一组资源的缓存数据,返回是否删除成功。 - * @param name 配置文件中加载项的name属性或资源组名。 - * @param force 销毁一个资源组时其他资源组有同样资源情况资源是否会被删除,默认值 true。 - * @see #setMaxRetryTimes - * @returns 是否销毁成功。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function destroyRes(name: string, force?: boolean): boolean; - /** - * Sets the maximum number of concurrent load threads, the default value is 4. - * @param thread The number of concurrent loads to be set. - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 设置最大并发加载线程数量,默认值是 4。 - * @param thread 要设置的并发加载数。 - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function setMaxLoadingThread(thread: number): void; - /** - * Sets the number of retry times when the resource failed to load, and the default value is 3. - * @param retry To set the retry count. - * @includeExample extension/resource/Resource.ts - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 设置资源加载失败时的重试次数,默认值是 3。 - * @param retry 要设置的重试次数。 - * @includeExample extension/resource/Resource.ts - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function setMaxRetryTimes(retry: number): void; - /** - * Add event listeners, reference ResourceEvent defined constants. - * @param type Event name。 - * @param listener Listener functions for handling events. This function must accept the Event object as its only parameter, and can't return any results, - * As shown in the following example: function (evt:Event):void can have any name. - * @param thisObject The this object that is bound to a function. - * @param useCapture Determine the listener is running on the capture or running on the target and the bubbling phase. Set useCapture to true, - * then the listener in the capture phase processing events, but not in the target or the bubbling phase processing events. - * If useCapture is false, then the listener only in the target or the bubbling phase processing events. - * To listen for events in all three stages, please call addEventListener two times: once the useCapture is set to true, once the useCapture is set to false. - * @param priority Event listener priority. Priority is specified by a 32 - bit integer with a symbol. The higher the number, the higher the priority. - * All listeners with a priority for n will be processed before the -1 n listener. - * If two or more listeners share the same priority, they are processed in accordance with the order of their added. The default priority is 0. - * @see RES.ResourceEvent - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 添加事件侦听器,参考 ResourceEvent 定义的常量。 - * @param type 事件的类型。 - * @param listener 处理事件的侦听器函数。此函数必须接受 Event 对象作为其唯一的参数,并且不能返回任何结果, - * 如下面的示例所示: function(evt:Event):void 函数可以有任何名称。 - * @param thisObject 侦听函数绑定的 this 对象。 - * @param useCapture 确定侦听器是运行于捕获阶段还是运行于目标和冒泡阶段。如果将 useCapture 设置为 true, - * 则侦听器只在捕获阶段处理事件,而不在目标或冒泡阶段处理事件。如果 useCapture 为 false,则侦听器只在目标或冒泡阶段处理事件。 - * 要在所有三个阶段都侦听事件,请调用 addEventListener 两次:一次将 useCapture 设置为 true,一次将 useCapture 设置为 false。 - * @param priority 事件侦听器的优先级。优先级由一个带符号的 32 位整数指定。数字越大,优先级越高。优先级为 n 的所有侦听器会在 - * 优先级为 n -1 的侦听器之前得到处理。如果两个或更多个侦听器共享相同的优先级,则按照它们的添加顺序进行处理。默认优先级为 0。 - * @see RES.ResourceEvent - * @see #setMaxRetryTimes - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function addEventListener(type: string, listener: (event: egret.Event) => void, thisObject: any, useCapture?: boolean, priority?: number): void; - /** - * Remove event listeners, reference ResourceEvent defined constants. - * @param type Event name。 - * @param listener Listening function。 - * @param thisObject The this object that is bound to a function. - * @param useCapture Is used to capture, and this property is only valid in the display list. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 移除事件侦听器,参考ResourceEvent定义的常量。 - * @param type 事件名。 - * @param listener 侦听函数。 - * @param thisObject 侦听函数绑定的this对象。 - * @param useCapture 是否使用捕获,这个属性只在显示列表中生效。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function removeEventListener(type: string, listener: (event: egret.Event) => void, thisObject: any, useCapture?: boolean): void; - /** - * Adding a custom resource configuration. - * @param data To add configuration. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 自定义添加一项资源配置。 - * @param data 要添加的配置。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function $addResourceData(data: { - name: string; - type: string; - url: string; - }): void; - /** - * Returns the VersionController - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 获得版本控制器. - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function getVersionController(): VersionController; - /** - * Register the VersionController - * @param vcs The VersionController to register. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 注册版本控制器,通过RES模块加载资源时会从版本控制器获取真实url - * @param vcs 注入的版本控制器。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function registerVersionController(vcs: VersionController): void; - /** - * Convert the address of the loaded resource (via version controller conversion) - * @param url path to the original resource - * @returns converted address - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 转换加载资源的地址(经过版本控制器的转换) - * @param url 原始资源的路径 - * @returns 转换后的地址 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function getVirtualUrl(url: any): any; - /** - * @private - */ - class Resource extends egret.EventDispatcher { - vcs: VersionController; - isVcsInit: boolean; - constructor(); - registerVersionController(vcs: VersionController): void; - /** - * 开始加载配置 - * @method RES.loadConfig - */ - loadConfig(): Promise; - /** - * @private - * 版本控制器加载后的加载配置 - */ - private normalLoadConfig; - /** - * 检查某个资源组是否已经加载完成 - * @method RES.isGroupLoaded - * @param name {string} - */ - isGroupLoaded(name: string): boolean; - /** - * 根据组名获取组加载项列表 - * @method RES.getGroupByName - * @param name {string} - */ - getGroupByName(name: string): Array; - /** - * 根据组名加载一组资源 - * @method RES.loadGroup - * @param name {string} - * @param priority {number} - */ - loadGroup(name: string, priority?: number, reporter?: PromiseTaskReporter): Promise; - private _loadGroup(name, priority?, reporter?); - /** - * 创建自定义的加载资源组,注意:此方法仅在资源配置文件加载完成后执行才有效。 - * 可以监听ResourceEvent.CONFIG_COMPLETE事件来确认配置加载完成。 - * @method RES.ResourceConfig#createGroup - * @param name {string} 要创建的加载资源组的组名 - * @param keys {egret.Array} 要包含的键名列表,key对应配置文件里的name属性或一个资源组名。 - * @param override {boolean} 是否覆盖已经存在的同名资源组,默认false。 - * @returns {boolean} - */ - createGroup(name: string, keys: Array, override?: boolean): boolean; - /** - * 检查配置文件里是否含有指定的资源 - * @method RES.hasRes - * @param key {string} 对应配置文件里的name属性或subKeys属性的一项。 - * @returns {boolean} - */ - hasRes(key: string): boolean; - /** - * 通过key同步获取资源 - * @method RES.getRes - * @param key {string} - * @returns {any} - */ - getRes(resKey: string): any; - /** - * 通过key异步获取资源 - * @method RES.getResAsync - * @param key {string} - * @param compFunc {Function} 回调函数。示例:compFunc(data,url):void。 - * @param thisObject {any} - */ - getResAsync(key: string): Promise; - getResAsync(key: string, compFunc: GetResAsyncCallback, thisObject: any): Promise; - /** - * 通过url获取资源 - * @method RES.getResByUrl - * @param url {string} - * @param compFunc {Function} - * @param thisObject {any} - * @param type {string} - */ - getResByUrl(url: string, compFunc?: Function, thisObject?: any, type?: string): Promise; - /** - * 销毁单个资源文件或一组资源的缓存数据,返回是否删除成功。 - * @method RES.destroyRes - * @param name {string} 配置文件中加载项的name属性或资源组名 - * @param force {boolean} 销毁一个资源组时其他资源组有同样资源情况资源是否会被删除,默认值true - * @returns {boolean} - */ - destroyRes(name: string, force?: boolean): boolean; - /** - * 设置最大并发加载线程数量,默认值是4. - * @method RES.setMaxLoadingThread - * @param thread {number} 要设置的并发加载数。 - */ - setMaxLoadingThread(thread: number): void; - /** - * 设置资源加载失败时的重试次数。 - * @param retry 要设置的重试次数。 - */ - setMaxRetryTimes(retry: number): void; - addResourceData(data: { - name: string; - type: string; - url: string; - }): void; - } -} -declare namespace RES { - /** - * Print the memory occupied by the picture. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 对文件路径的一些操作,针对的是 C:/A/B/C/D/example.ts这种格式 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - namespace path { - /** - * Format the file path,"C:/A/B//C//D//example.ts"=>"C:/A/B/C/D/example.ts" - * @param filename Incoming file path - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 格式化文件路径,"C:/A/B//C//D//example.ts"=>"C:/A/B/C/D/example.ts" - * @param filename 传入的文件路径 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function normalize(filename: string): string; - /** - * Get the file name according to the file path, "C:/A/B/example.ts"=>"example.ts" - * @param filename Incoming file path - * @return File name - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 根据文件路径得到文件名字,"C:/A/B/example.ts"=>"example.ts" - * @param filename 传入的文件路径 - * @return 文件的名字 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function basename(filename: string): string; - /** - * The path to the folder where the file is located,"C:/A/B/example.ts"=>"C:/A/B" - * @param filename Incoming file path - * @return The address of the folder where the file is located - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 文件所在文件夹路径,"C:/A/B/example.ts"=>"C:/A/B" - * @param filename 传入的文件路径 - * @return 文件所在文件夹的地址 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function dirname(path: string): string; - } -} -declare namespace RES { - /** - * @private - */ - class NativeVersionController implements IVersionController { - private versionInfo; - init(): Promise; - getVirtualUrl(url: string): string; - private getLocalData(filePath); - } -} -declare module RES.processor { - interface Processor { - /** - * Start loading a single resource - * @param host Load the processor, you can use the processor to load resources, directly use http to get the resources back - * @param resource Resource information - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 开始加载单项资源 - * @param host 加载处理器,可以不使用这个处理器加载资源,直接用http获取资源返回即可 - * @param resource 资源的信息 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - onLoadStart(host: ProcessHost, resource: ResourceInfo): Promise; - /** - * Remove a single resource, usually call host.unload (resource); - * @param host Load the processor - * @param resource Resource information - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 移除单项资源,一般调用host.unload(resource); - * @param host 加载处理器 - * @param resource 资源的信息 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - onRemoveStart(host: ProcessHost, resource: ResourceInfo): void; - /** - * Get the submap of the merged atlas - * @param host Load the processor - * @param resource Resource information - * @param key The key value of the resource - * @param subkey Collection of subset names - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 获取合并图集的子图 - * @param host 加载处理器 - * @param resource 资源的信息 - * @param key 资源的key值 - * @param subkey 子集名称的集合 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - getData?(host: ProcessHost, resource: ResourceInfo, key: string, subkey: string): any; - } - /** - * Register the processor that loads the resource - * @param type Load resource type - * @param processor Loaded processor, an instance that implements the Processor interface - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 注册加载资源的处理器 - * @param type 加载资源类型 - * @param processor 加载的处理器,一个实现Processor接口的实例 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function map(type: string, processor: Processor): void; - /** - * @private - * @param url - * @param file - */ - function getRelativePath(url: string, file: string): string; - var ImageProcessor: Processor; - const KTXTextureProcessor: RES.processor.Processor; - /** - * - */ - function makeEtc1SeperatedAlphaResourceInfo(resource: ResourceInfo): ResourceInfo; - /** - * - */ - const ETC1KTXProcessor: Processor; - var BinaryProcessor: Processor; - var TextProcessor: Processor; - var JsonProcessor: Processor; - var SoundProcessor: Processor; -} -declare module RES { - /** - * The events of resource loading. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 资源加载事件。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - class ResourceEvent extends egret.Event { - /** - * Failure event for a load item. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 一个加载项加载失败事件。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - static ITEM_LOAD_ERROR: string; - /** - * Configure file to load and parse the completion event. Note: if a configuration file is loaded, it will not be thrown out, and if you want to handle the configuration loading failure, monitor the CONFIG_LOAD_ERROR event. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 配置文件加载并解析完成事件。注意:若有配置文件加载失败,将不会抛出此事件,若要处理配置加载失败,请同时监听 CONFIG_LOAD_ERROR 事件。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - static CONFIG_COMPLETE: string; - /** - * Configuration file failed to load. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 配置文件加载失败事件。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - static CONFIG_LOAD_ERROR: string; - /** - * Delay load group resource loading progress event. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 延迟加载组资源加载进度事件。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - static GROUP_PROGRESS: string; - /** - * Delay load group resource to complete event. Note: if you have a resource item loading failure, the event will not be thrown, if you want to handle the group load failure, please listen to the GROUP_LOAD_ERROR event. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 延迟加载组资源加载完成事件。注意:若组内有资源项加载失败,将不会抛出此事件,若要处理组加载失败,请同时监听 GROUP_LOAD_ERROR 事件。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - static GROUP_COMPLETE: string; - /** - * Delayed load group resource failed event. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 延迟加载组资源加载失败事件。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - static GROUP_LOAD_ERROR: string; - /** - * Creates an Event object to pass as a parameter to event listeners. - * @param type The type of the event, accessible as Event.type. - * @param bubbles Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false. - * @param cancelable Determines whether the Event object can be canceled. The default values is false. - * @version Egret 5.2 - * @platform Web,Native - * @private - * @language en_US - */ - /** - * 创建一个作为参数传递给事件侦听器的 Event 对象。 - * @param type 事件的类型,可以作为 Event.type 访问。 - * @param bubbles 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。 - * @param cancelable 确定是否可以取消 Event 对象。默认值为 false。 - * @version Egret 5.2 - * @platform Web,Native - * @private - * @language zh_CN - */ - constructor(type: string, bubbles?: boolean, cancelable?: boolean); - /** - * File number that has been loaded. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 已经加载的文件数。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - itemsLoaded: number; - /** - * Total file number to load. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 要加载的总文件数。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - itemsTotal: number; - /** - * Resource group name. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 资源组名。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - groupName: string; - /** - * An item of information that is finished by the end of a load. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 一次加载项加载结束的项信息对象。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - resItem: ResourceItem; - } -} -declare module RES { - /** - * Resource term. One of the resources arrays in resource.json. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 资源项。对应 resource.json 中 resources 数组中的一项。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - namespace ResourceItem { - /** - * XML file. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * XML 文件。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - const TYPE_XML: string; - /** - * Picture file. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 图片文件。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - const TYPE_IMAGE: string; - /** - * Binary file. - * @version Egret 5.2 - * @platform Web - * @language en_US - */ - /** - * 二进制文件。 - * @version Egret 5.2 - * @platform Web - * @language zh_CN - */ - const TYPE_BIN: string; - /** - * Text file. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 文本文件。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - const TYPE_TEXT: string; - /** - * JSON file. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * JSON 文件。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - const TYPE_JSON: string; - /** - * SpriteSheet file. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * SpriteSheet 文件。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - const TYPE_SHEET: string; - /** - * BitmapTextSpriteSheet file. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * BitmapTextSpriteSheet 文件。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - const TYPE_FONT: string; - /** - * Sound file. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 声音文件。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - const TYPE_SOUND: string; - function convertToResItem(r: ResourceInfo): ResourceItem; - } - interface ResourceItem extends ResourceInfo { - /** - * Name of resource term. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 加载项名称。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - name: string; - /** - * URL of resource term. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 要加载的文件地址。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - url: string; - /** - * Type of resource term. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 加载项文件类型。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - type: string; - /** - * The raw data object to be referenced. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 被引用的原始数据对象。 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - data: ResourceInfo; - crc32?: string; - size?: number; - soundType?: string; - } -} -declare module RES { - /** - * assetsManager underlying storage resource information - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * assetsManager底层存储资源信息 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - interface File { - url: string; - type: string; - name: string; - root: string; - } - /** - * @private - */ - interface FileSystem { - addFile(data: { - name: string; - type: string; - url: string; - root?: string; - extra?: 1 | undefined; - }): any; - getFile(filename: string): File | null; - profile(): void; - removeFile(filename: string): any; - } -} -declare module RES { - /** - * Print the memory occupied by the picture. - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 打印图片所占内存 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - function profile(): void; - /** - * @private - */ - interface ProcessHost { - state: { - [index: string]: number; - }; - resourceConfig: ResourceConfig; - load: (resource: ResourceInfo, processor?: string | processor.Processor) => Promise; - unload: (resource: ResourceInfo) => void; - save: (rexource: ResourceInfo, data: any) => void; - get: (resource: ResourceInfo) => any; - remove: (resource: ResourceInfo) => void; - } - /** - * @private - */ - class ResourceManagerError extends Error { - static errorMessage: { - 1001: string; - 1002: string; - 2001: string; - 2002: string; - 2003: string; - 2004: string; - 2005: string; - 2006: string; - }; - /** - * why instanceof e != ResourceManagerError ??? - * see link : https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes#extending-built-ins-like-error-array-and-map-may-no-longer-work - */ - private __resource_manager_error__; - constructor(code: number, replacer?: Object, replacer2?: Object); - } -} -declare namespace RES { - /** - * Resource group loading progress prompt - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 资源组的加载进度提示 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - interface PromiseTaskReporter { - /** - * Progress callback, asynchronous execution, load number and order have nothing to do - * @param current The number of currently loaded - * @param total Total resources required in the current resource bundle - * @param resItem currently loading resource information - * @version Egret 5.2 - * @platform Web,Native - * @language en_US - */ - /** - * 进度回调,异步执行,加载数目和顺序无关 - * @param current 当前已经加载数目 - * @param total 当前资源包内需要资源总数 - * @param resItem 当前加载资源信息 - * @version Egret 5.2 - * @platform Web,Native - * @language zh_CN - */ - onProgress?(current: number, total: number, resItem: ResourceInfo | undefined): void; - } -} diff --git a/source/lib/egret.d.ts b/source/lib/egret.d.ts deleted file mode 100644 index 3905f0f6..00000000 --- a/source/lib/egret.d.ts +++ /dev/null @@ -1,15371 +0,0 @@ -declare var global: any; -declare var __global: any; -declare let __define: any; -declare namespace egret { - type Nullable = T | null; - /** - * The HashObject class is the base class for all objects in the Egret framework.The HashObject - * class includes a hashCode property, which is a unique identification number of the instance. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * Egret顶级对象。框架内所有对象的基类,为对象实例提供唯一的hashCode值。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - interface IHashObject { - /** - * a unique identification number assigned to this instance. - * @version Egret 2.4 - * @platform Web,Native - * @readOnly - * @language en_US - */ - /** - * 返回此对象唯一的哈希值,用于唯一确定一个对象。hashCode为大于等于1的整数。 - * @version Egret 2.4 - * @platform Web,Native - * @readOnly - * @language zh_CN - */ - hashCode: number; - } - /** - * @private - * 哈希计数 - */ - let $hashCount: number; - /** - * The HashObject class is the base class for all objects in the Egret framework.The HashObject - * class includes a hashCode property, which is a unique identification number of the instance. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * Egret顶级对象。框架内所有对象的基类,为对象实例提供唯一的hashCode值。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - class HashObject implements IHashObject { - /** - * Initializes a HashObject - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 HashObject 对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(); - /** - * @private - */ - $hashCode: number; - /** - * a unique identification number assigned to this instance. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 返回此对象唯一的哈希值,用于唯一确定一个对象。hashCode为大于等于1的整数。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly hashCode: number; - } -} -declare namespace egret { - /** - * The EventDispatcher class is the base class for all classes that dispatchEvent events. The EventDispatcher class implements - * the IEventDispatcher interface and is the base class for the DisplayObject class. The EventDispatcher class allows - * any object on the display list to be an event target and as such, to use the methods of the IEventDispatcher interface. - * Event targets are an important part of the Egret event model. The event target serves as the focal point for how events - * flow through the display list hierarchy. When an event such as a touch tap, Egret dispatches an event object into the - * event flow from the root of the display list. The event object then makes its way through the display list until it - * reaches the event target, at which point it begins its return trip through the display list. This round-trip journey - * to the event target is conceptually divided into three phases:
- * the capture phase comprises the journey from the root to the last node before the event target's node, the target - * phase comprises only the event target node, and the bubbling phase comprises any subsequent nodes encountered on - * the return trip to the root of the display list. In general, the easiest way for a user-defined class to gain event - * dispatching capabilities is to extend EventDispatcher. If this is impossible (that is, if the class is already extending - * another class), you can instead implement the IEventDispatcher interface, create an EventDispatcher member, and write simple - * hooks to route calls into the aggregated EventDispatcher. - * @see egret.IEventDispatcher - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/EventDispatcher.ts - * @language en_US - */ - /** - * EventDispatcher 是 Egret 的事件派发器类,负责进行事件的发送和侦听。 - * 事件目标是事件如何通过显示列表层次结构这一问题的焦点。当发生鼠标单击、触摸或按键等事件时, - * 框架会将事件对象调度到从显示列表根开始的事件流中。然后该事件对象在显示列表中前进,直到到达事件目标, - * 然后从这一点开始其在显示列表中的回程。在概念上,到事件目标的此往返行程被划分为三个阶段: - * 捕获阶段包括从根到事件目标节点之前的最后一个节点的行程,目标阶段仅包括事件目标节点,冒泡阶段包括回程上遇到的任何后续节点到显示列表的根。 - * 通常,使用户定义的类能够调度事件的最简单方法是扩展 EventDispatcher。如果无法扩展(即,如果该类已经扩展了另一个类),则可以实现 - * IEventDispatcher 接口,创建 EventDispatcher 成员,并编写一些简单的映射,将调用连接到聚合的 EventDispatcher 中。 - * @see egret.IEventDispatcher - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/EventDispatcher.ts - * @language zh_CN - */ - class EventDispatcher extends HashObject implements IEventDispatcher { - /** - * create an instance of the EventDispatcher class. - * @param target The target object for events dispatched to the EventDispatcher object. This parameter is used when - * the EventDispatcher instance is aggregated by a class that implements IEventDispatcher; it is necessary so that the - * containing object can be the target for events. Do not use this parameter in simple cases in which a class extends EventDispatcher. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 EventDispatcher 类的实例 - * @param target 此 EventDispatcher 所抛出事件对象的 target 指向。此参数主要用于一个实现了 IEventDispatcher 接口的自定义类, - * 以便抛出的事件对象的 target 属性可以指向自定义类自身。请勿在直接继承 EventDispatcher 的情况下使用此参数。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(target?: IEventDispatcher); - /** - * @private - */ - $EventDispatcher: Object; - /** - * @private - * - * @param useCapture - */ - $getEventMap(useCapture?: boolean): any; - /** - * @inheritDoc - * @version Egret 2.4 - * @platform Web,Native - */ - addEventListener(type: string, listener: Function, thisObject: any, useCapture?: boolean, priority?: number): void; - /** - * @inheritDoc - * @version Egret 2.4 - * @platform Web,Native - */ - once(type: string, listener: Function, thisObject: any, useCapture?: boolean, priority?: number): void; - /** - * @private - */ - $addListener(type: string, listener: Function, thisObject: any, useCapture?: boolean, priority?: number, dispatchOnce?: boolean): void; - $insertEventBin(list: any[], type: string, listener: Function, thisObject: any, useCapture?: boolean, priority?: number, dispatchOnce?: boolean): boolean; - /** - * @inheritDoc - * @version Egret 2.4 - * @platform Web,Native - */ - removeEventListener(type: string, listener: Function, thisObject: any, useCapture?: boolean): void; - $removeEventBin(list: any[], listener: Function, thisObject: any): boolean; - /** - * @inheritDoc - * @version Egret 2.4 - * @platform Web,Native - */ - hasEventListener(type: string): boolean; - /** - * @inheritDoc - * @version Egret 2.4 - * @platform Web,Native - */ - willTrigger(type: string): boolean; - /** - * @inheritDoc - * @version Egret 2.4 - * @platform Web,Native - */ - dispatchEvent(event: Event): boolean; - /** - * @private - */ - $notifyListener(event: Event, capturePhase: boolean): boolean; - /** - * Distribute a specified event parameters. - * @param type The type of the event. Event listeners can access this information through the inherited type property. - * @param bubbles Determines whether the Event object bubbles. Event listeners can access this information through - * the inherited bubbles property. - * @param data {any} data - * @param cancelable Determines whether the Event object can be canceled. The default values is false. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 派发一个指定参数的事件。 - * @param type {string} 事件类型 - * @param bubbles {boolean} 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。 - * @param data {any} 事件data - * @param cancelable {boolean} 确定是否可以取消 Event 对象。默认值为 false。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - dispatchEventWith(type: string, bubbles?: boolean, data?: any, cancelable?: boolean): boolean; - } -} -declare namespace egret.sys { - /** - * @private - * 事件信息对象 - */ - interface EventBin { - type: string; - /** - * @private - */ - listener: Function; - /** - * @private - */ - thisObject: any; - /** - * @private - */ - priority: number; - /** - * @private - */ - target: IEventDispatcher; - /** - * @private - */ - useCapture: boolean; - /** - * @private - */ - dispatchOnce: boolean; - } -} -declare namespace egret { - /** - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - class Filter extends HashObject { - /** - * @version Egret 2.4 - * @platform Web,Native - */ - type: string; - /** - * @private - */ - $id: number; - /** - * @private - */ - $uniforms: any; - /** - * @private - */ - protected paddingTop: number; - /** - * @private - */ - protected paddingBottom: number; - /** - * @private - */ - protected paddingLeft: number; - /** - * @private - */ - protected paddingRight: number; - /** - * @private - * @native Render - */ - $obj: any; - constructor(); - /** - * @private - */ - $toJson(): string; - protected updatePadding(): void; - onPropertyChange(): void; - } -} -declare namespace egret { - /** - * @private - */ - const enum RenderMode { - NONE = 1, - FILTER = 2, - CLIP = 3, - SCROLLRECT = 4, - } - /** - * The DisplayObject class is the base class for all objects that can be placed on the display list. The display list - * manages all objects displayed in the runtime. Use the DisplayObjectContainer class to arrange the display - * objects in the display list. DisplayObjectContainer objects can have child display objects, while other display objects, - * such as Shape and TextField objects, are "leaf" nodes that have only parents and siblings, no children. - * The DisplayObject class supports basic functionality like the x and y position of an object, as well as more advanced - * properties of the object such as its transformation matrix.
- * The DisplayObject class contains several broadcast events.Normally, the target of any particular event is a specific - * DisplayObject instance. For example, the target of an added event is the specific DisplayObject instance that was added - * to the display list. Having a single target restricts the placement of event listeners to that target and in some cases - * the target's ancestors on the display list. With broadcast events, however, the target is not a specific DisplayObject - * instance, but rather all DisplayObject instances, including those that are not on the display list. This means that you - * can add a listener to any DisplayObject instance to listen for broadcast events. - * - * @event egret.Event.ADDED Dispatched when a display object is added to the display list. - * @event egret.Event.ADDED_TO_STAGE Dispatched when a display object is added to the on stage display list, either directly or through the addition of a sub tree in which the display object is contained. - * @event egret.Event.REMOVED Dispatched when a display object is about to be removed from the display list. - * @event egret.Event.REMOVED_FROM_STAGE Dispatched when a display object is about to be removed from the display list, either directly or through the removal of a sub tree in which the display object is contained. - * @event egret.Event.ENTER_FRAME [broadcast event] Dispatched when the playhead is entering a new frame. - * @event egret.Event.RENDER [broadcast event] Dispatched when the display list is about to be updated and rendered. - * @event egret.TouchEvent.TOUCH_MOVE Dispatched when the user touches the device, and is continuously dispatched until the point of contact is removed. - * @event egret.TouchEvent.TOUCH_BEGIN Dispatched when the user first contacts a touch-enabled device (such as touches a finger to a mobile phone or tablet with a touch screen). - * @event egret.TouchEvent.TOUCH_END Dispatched when the user removes contact with a touch-enabled device (such as lifts a finger off a mobile phone or tablet with a touch screen). - * @event egret.TouchEvent.TOUCH_TAP Dispatched when the user lifts the point of contact over the same DisplayObject instance on which the contact was initiated on a touch-enabled device (such as presses and releases a finger from a single point over a display object on a mobile phone or tablet with a touch screen). - * @event egret.TouchEvent.TOUCH_RELEASE_OUTSIDE Dispatched when the user lifts the point of contact over the different DisplayObject instance on which the contact was initiated on a touch-enabled device (such as presses and releases a finger from a single point over a display object on a mobile phone or tablet with a touch screen). - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/DisplayObject.ts - * @language en_US - */ - /** - * DisplayObject 类是可放在显示列表中的所有对象的基类。该显示列表管理运行时中显示的所有对象。使用 DisplayObjectContainer 类排列 - * 显示列表中的显示对象。DisplayObjectContainer 对象可以有子显示对象,而其他显示对象(如 Shape 和 TextField 对象)是“叶”节点,没有子项,只有父级和 - * 同级。DisplayObject 类有一些基本的属性(如确定坐标位置的 x 和 y 属性),也有一些高级的对象属性(如 Matrix 矩阵变换)。
- * DisplayObject 类包含若干广播事件。通常,任何特定事件的目标均为一个特定的 DisplayObject 实例。例如,added 事件的目标是已添加到显示列表 - * 的目标 DisplayObject 实例。若只有一个目标,则会将事件侦听器限制为只能监听在该目标上(在某些情况下,可监听在显示列表中该目标的祖代上)。 - * 但是对于广播事件,目标不是特定的 DisplayObject 实例,而是所有 DisplayObject 实例(包括那些不在显示列表中的实例)。这意味着您可以向任何 - * DisplayObject 实例添加侦听器来侦听广播事件。 - * - * @event egret.Event.ADDED 将显示对象添加到显示列表中时调度。 - * @event egret.Event.ADDED_TO_STAGE 在将显示对象直接添加到舞台显示列表或将包含显示对象的子树添加至舞台显示列表中时调度。 - * @event egret.Event.REMOVED 将要从显示列表中删除显示对象时调度。 - * @event egret.Event.REMOVED_FROM_STAGE 在从显示列表中直接删除显示对象或删除包含显示对象的子树时调度。 - * @event egret.Event.ENTER_FRAME [广播事件] 播放头进入新帧时调度。 - * @event egret.Event.RENDER [广播事件] 将要更新和呈现显示列表时调度。 - * @event egret.TouchEvent.TOUCH_MOVE 当用户触碰设备时进行调度,而且会连续调度,直到接触点被删除。 - * @event egret.TouchEvent.TOUCH_BEGIN 当用户第一次触摸启用触摸的设备时(例如,用手指触摸手机屏幕)调度。 - * @event egret.TouchEvent.TOUCH_END 当用户移除与启用触摸的设备的接触时(例如,将手指从屏幕上抬起)调度。 - * @event egret.TouchEvent.TOUCH_TAP 当用户在启用触摸设备上的已启动接触的同一 DisplayObject 实例上抬起接触点时(例如,手机点击屏幕后抬起)调度。 - * @event egret.TouchEvent.TOUCH_RELEASE_OUTSIDE 当用户在启用触摸设备上的已启动接触的不同 DisplayObject 实例上抬起接触点时(例如,按住屏幕上的某个对象,然后从它上面挪开后再松开手指)调度。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/DisplayObject.ts - * @language zh_CN - */ - class DisplayObject extends EventDispatcher { - /** - * Initializes a DisplayObject object - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个显示对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(); - $nativeDisplayObject: egret_native.NativeDisplayObject; - protected createNativeDisplayObject(): void; - /** - * @private - * 是否添加到舞台上,防止重复发送 removed_from_stage 消息 - */ - $hasAddToStage: boolean; - /** - * @private - * 能够含有子项的类将子项列表存储在这个属性里。 - */ - $children: DisplayObject[]; - private $name; - /** - * Indicates the instance name of the DisplayObject. The object can be identified in the child list of its parent - * display object container by calling the getChildByName() method of the display object container. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示 DisplayObject 的实例名称。 - * 通过调用父显示对象容器的 getChildByName() 方法,可以在父显示对象容器的子列表中标识该对象。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - name: string; - /** - * @private - */ - $parent: DisplayObjectContainer; - /** - * Indicates the DisplayObjectContainer object that contains this display object. Use the parent property to specify - * a relative path to display objects that are above the current display object in the display list hierarchy. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示包含此显示对象的 DisplayObjectContainer 对象。 - * 使用 parent 属性可以指定高于显示列表层次结构中当前显示对象的显示对象的相对路径。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly parent: DisplayObjectContainer; - /** - * @private - * 设置父级显示对象 - */ - $setParent(parent: DisplayObjectContainer): void; - /** - * @private - * 显示对象添加到舞台 - */ - $onAddToStage(stage: Stage, nestLevel: number): void; - /** - * @private - * 显示对象从舞台移除 - */ - $onRemoveFromStage(): void; - /** - * @private - */ - $stage: Stage; - /** - * @private - * 这个对象在显示列表中的嵌套深度,舞台为1,它的子项为2,子项的子项为3,以此类推。当对象不在显示列表中时此属性值为0. - */ - $nestLevel: number; - $useTranslate: boolean; - protected $updateUseTransform(): void; - /** - * The Stage of the display object. you can create and load multiple display objects into the display list, and - * the stage property of each display object refers to the same Stage object.
- * If a display object is not added to the display list, its stage property is set to null. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 显示对象的舞台。 - * 例如,您可以创建多个显示对象并加载到显示列表中,每个显示对象的 stage 属性是指向相同的 Stage 对象。
- * 如果显示对象未添加到显示列表,则其 stage 属性会设置为 null。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly stage: Stage; - /** - * A Matrix object containing values that alter the scaling, rotation, and translation of the display object.
- * Note: to change the value of a display object's matrix, you must make a copy of the entire matrix object, then copy - * the new object into the matrix property of the display object. - * @example the following code increases the tx value of a display object's matrix - *
-         *     let myMatrix:Matrix = myDisplayObject.matrix;
-         *     myMatrix.tx += 10;
-         *     myDisplayObject.matrix = myMatrix;
-         * 
- * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 一个 Matrix 对象,其中包含更改显示对象的缩放、旋转和平移的值。
- * 注意:要改变一个显示对象矩阵的值,您必引用整个矩阵对象,然后将它重新赋值给显示对象的 matrix 属性。 - * @example 以下代码改变了显示对象矩阵的tx属性值: - *
-         *     let myMatrix:Matrix = myDisplayObject.matrix;
-         *     myMatrix.tx += 10;
-         *     myDisplayObject.matrix = myMatrix;
-         * 
- * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - matrix: Matrix; - private $matrix; - private $matrixDirty; - /** - * @private - * 获取矩阵 - */ - $getMatrix(): Matrix; - /** - * @private - * 设置矩阵 - */ - $setMatrix(matrix: Matrix, needUpdateProperties?: boolean): void; - private $concatenatedMatrix; - /** - * @private - * 获得这个显示对象以及它所有父级对象的连接矩阵。 - */ - $getConcatenatedMatrix(): Matrix; - private $invertedConcatenatedMatrix; - /** - * @private - * 获取链接矩阵 - */ - $getInvertedConcatenatedMatrix(): Matrix; - $x: number; - /** - * Indicates the x coordinate of the DisplayObject instance relative to the local coordinates of the parent - * DisplayObjectContainer.
- * If the object is inside a DisplayObjectContainer that has transformations, it is in - * the local coordinate system of the enclosing DisplayObjectContainer. Thus, for a DisplayObjectContainer - * rotated 90° counterclockwise, the DisplayObjectContainer's children inherit a coordinate system that is - * rotated 90° counterclockwise. The object's coordinates refer to the registration point position. - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示 DisplayObject 实例相对于父级 DisplayObjectContainer 本地坐标的 x 坐标。
- * 如果该对象位于具有变形的 DisplayObjectContainer 内,则它也位于包含 DisplayObjectContainer 的本地坐标系中。 - * 因此,对于逆时针旋转 90 度的 DisplayObjectContainer,该 DisplayObjectContainer 的子级将继承逆时针旋转 90 度的坐标系。 - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - x: number; - /** - * @private - * 获取x坐标 - */ - $getX(): number; - /** - * @private - * 设置x坐标 - */ - $setX(value: number): boolean; - $y: number; - /** - * Indicates the y coordinate of the DisplayObject instance relative to the local coordinates of the parent - * DisplayObjectContainer.
- * If the object is inside a DisplayObjectContainer that has transformations, it is in - * the local coordinate system of the enclosing DisplayObjectContainer. Thus, for a DisplayObjectContainer rotated - * 90° counterclockwise, the DisplayObjectContainer's children inherit a coordinate system that is rotated 90° - * counterclockwise. The object's coordinates refer to the registration point position. - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示 DisplayObject 实例相对于父级 DisplayObjectContainer 本地坐标的 y 坐标。
- * 如果该对象位于具有变形的 DisplayObjectContainer 内,则它也位于包含 DisplayObjectContainer 的本地坐标系中。 - * 因此,对于逆时针旋转 90 度的 DisplayObjectContainer,该 DisplayObjectContainer 的子级将继承逆时针旋转 90 度的坐标系。 - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - y: number; - /** - * @private - * 获取y坐标 - */ - $getY(): number; - /** - * @private - * 设置y坐标 - */ - $setY(value: number): boolean; - private $scaleX; - /** - * Indicates the horizontal scale (percentage) of the object as applied from the registration point.
- * The default 1.0 equals 100% scale. - * @default 1 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示从注册点开始应用的对象的水平缩放比例(百分比)。
- * 1.0 等于 100% 缩放。 - * @default 1 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - scaleX: number; - /** - * @private - * - * @returns - */ - $getScaleX(): number; - /** - * @private - * 设置水平缩放值 - */ - $setScaleX(value: number): void; - private $scaleY; - /** - * Indicates the vertical scale (percentage) of an object as applied from the registration point of the object. - * 1.0 is 100% scale. - * @default 1 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示从对象注册点开始应用的对象的垂直缩放比例(百分比)。1.0 是 100% 缩放。 - * @default 1 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - scaleY: number; - /** - * @private - * - * @returns - */ - $getScaleY(): number; - /** - * @private - * 设置垂直缩放值 - */ - $setScaleY(value: number): void; - private $rotation; - /** - * Indicates the rotation of the DisplayObject instance, in degrees, from its original orientation. Values from - * 0 to 180 represent clockwise rotation; values from 0 to -180 represent counterclockwise rotation. Values outside - * this range are added to or subtracted from 360 to obtain a value within the range. For example, the statement - * myDisplayObject.rotation = 450 is the same as myDisplayObject.rotation = 90. - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示 DisplayObject 实例距其原始方向的旋转程度,以度为单位。 - * 从 0 到 180 的值表示顺时针方向旋转;从 0 到 -180 的值表示逆时针方向旋转。对于此范围之外的值,可以通过加上或 - * 减去 360 获得该范围内的值。例如,myDisplayObject.rotation = 450语句与 myDisplayObject.rotation = 90 是相同的。 - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - rotation: number; - /** - * @private - */ - $getRotation(): number; - $setRotation(value: number): void; - private $skewX; - private $skewXdeg; - /** - * 表示DisplayObject的x方向斜切 - * @member {number} egret.DisplayObject#skewX - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - */ - skewX: number; - /** - * @private - * - * @param value - */ - $setSkewX(value: number): void; - private $skewY; - private $skewYdeg; - /** - * 表示DisplayObject的y方向斜切 - * @member {number} egret.DisplayObject#skewY - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - */ - skewY: number; - /** - * @private - * - * @param value - */ - $setSkewY(value: number): void; - /** - * Indicates the width of the display object, in pixels. The width is calculated based on the bounds of the content - * of the display object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示显示对象的宽度,以像素为单位。宽度是根据显示对象内容的范围来计算的。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - width: number; - /** - * @private - * 获取显示宽度 - */ - $getWidth(): number; - $explicitWidth: number; - /** - * @private - * 设置显示宽度 - */ - $setWidth(value: number): void; - /** - * Indicates the height of the display object, in pixels. The height is calculated based on the bounds of the - * content of the display object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示显示对象的高度,以像素为单位。高度是根据显示对象内容的范围来计算的。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - height: number; - $explicitHeight: number; - /** - * @private - * 获取显示高度 - */ - $getHeight(): number; - /** - * @private - * 设置显示高度 - */ - $setHeight(value: number): void; - /** - * 测量宽度 - * @returns {number} - * @member {egret.Rectangle} egret.DisplayObject#measuredWidth - * @version Egret 2.4 - * @platform Web,Native - */ - readonly measuredWidth: number; - /** - * 测量高度 - * @returns {number} - * @member {egret.Rectangle} egret.DisplayObject#measuredWidth - * @version Egret 2.4 - * @platform Web,Native - */ - readonly measuredHeight: number; - $anchorOffsetX: number; - /** - * X represents the object of which is the anchor. - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示从对象绝对锚点X。 - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - anchorOffsetX: number; - /** - * @private - * - * @param value - * @returns - */ - $setAnchorOffsetX(value: number): void; - $anchorOffsetY: number; - /** - * Y represents the object of which is the anchor. - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示从对象绝对锚点Y。 - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - anchorOffsetY: number; - /** - * @private - * - * @param value - * @returns - */ - $setAnchorOffsetY(value: number): void; - /** - * @private - */ - $visible: boolean; - /** - * Whether or not the display object is visible. Display objects that are not visible are disabled. For example, - * if visible=false for an DisplayObject instance, it cannot receive touch or other user input. - * @default true - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 显示对象是否可见。不可见的显示对象将被禁用。例如,如果实例的 visible 为 false,则无法接受触摸或用户交互操作。 - * @default true - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - visible: boolean; - $setVisible(value: boolean): void; - /** - * @private - * cacheAsBitmap创建的缓存位图节点。 - */ - $displayList: egret.sys.DisplayList; - private $cacheAsBitmap; - /** - * If set to true, Egret runtime caches an internal bitmap representation of the display object. This caching can - * increase performance for display objects that contain complex vector content. After you set the cacheAsBitmap - * property to true, the rendering does not change, however the display object performs pixel snapping automatically. - * The execution speed can be significantly faster depending on the complexity of the content.The cacheAsBitmap - * property is best used with display objects that have mostly static content and that do not scale and rotate frequently.
- * Note: The display object will not create the bitmap caching when the memory exceeds the upper limit,even if you set it to true. - * @default false - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 如果设置为 true,则 Egret 运行时将缓存显示对象的内部位图表示形式。此缓存可以提高包含复杂矢量内容的显示对象的性能。 - * 将 cacheAsBitmap 属性设置为 true 后,呈现并不更改,但是,显示对象将自动执行像素贴紧。执行速度可能会大大加快, - * 具体取决于显示对象内容的复杂性。最好将 cacheAsBitmap 属性与主要具有静态内容且不频繁缩放或旋转的显示对象一起使用。
- * 注意:在内存超过上限的情况下,即使将 cacheAsBitmap 属性设置为 true,显示对象也不使用位图缓存。 - * @default false - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - cacheAsBitmap: boolean; - $setHasDisplayList(value: boolean): void; - $cacheDirty: boolean; - $cacheDirtyUp(): void; - /** - * @private - */ - $alpha: number; - /** - * Indicates the alpha transparency value of the object specified. Valid values are 0 (fully transparent) to 1 (fully opaque). - * The default value is 1. Display objects with alpha set to 0 are active, even though they are invisible. - * @default 1 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示指定对象的 Alpha 透明度值。 - * 有效值为 0(完全透明)到 1(完全不透明)。alpha 设置为 0 的显示对象是可触摸的,即使它们不可见。 - * @default 1 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - alpha: number; - /** - * @private - * - * @param value - */ - $setAlpha(value: number): void; - /** - * @private - * The default touchEnabled property of DisplayObject - * @default false - * @version Egret 2.5 - * @platform Web,Native - * @language en_US - */ - /** - * @private - * 显示对象默认的 touchEnabled 属性 - * @default false - * @version Egret 2.5 - * @platform Web,Native - * @language zh_CN - */ - static defaultTouchEnabled: boolean; - $touchEnabled: boolean; - /** - * Specifies whether this object receives touch or other user input. The default value is false, which means that - * by default any DisplayObject instance that is on the display list cannot receive touch events. If touchEnabled is - * set to false, the instance does not receive any touch events (or other user input events). Any children of - * this instance on the display list are not affected. To change the touchEnabled behavior for all children of - * an object on the display list, use DisplayObjectContainer.touchChildren. - * @see egret.DisplayObjectContainer#touchChildren - * @default false - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 指定此对象是否接收触摸或其他用户输入。默认值为 false,这表示默认情况下,显示列表上的任何 DisplayObject 实例都不会接收触摸事件或 - * 其他用户输入事件。如果将 touchEnabled 设置为 false,则实例将不接收任何触摸事件(或其他用户输入事件)。显示列表上的该实例的任 - * 何子级都不会受到影响。要更改显示列表上对象的所有子级的 touchEnabled 行为,请使用 DisplayObjectContainer.touchChildren。 - * @see egret.DisplayObjectContainer#touchChildren - * @default false - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - touchEnabled: boolean; - /** - * @private - */ - $getTouchEnabled(): boolean; - /** - * @private - */ - $setTouchEnabled(value: boolean): void; - /** - * @private - */ - $scrollRect: Rectangle; - /** - * The scroll rectangle bounds of the display object. The display object is cropped to the size defined by the rectangle, - * and it scrolls within the rectangle when you change the x and y properties of the scrollRect object. A scrolled display - * object always scrolls in whole pixel increments.You can scroll an object left and right by setting the x property of - * the scrollRect Rectangle object. You can scroll an object up and down by setting the y property of the scrollRect - * Rectangle object. If the display object is rotated 90° and you scroll it left and right, the display object actually - * scrolls up and down.
- * - * Note: to change the value of a display object's scrollRect, you must make a copy of the entire scrollRect object, then copy - * the new object into the scrollRect property of the display object. - * @example the following code increases the x value of a display object's scrollRect - *
-         *     let myRectangle:Rectangle = myDisplayObject.scrollRect;
-         *     myRectangle.x += 10;
-         *     myDisplayObject.scrollRect = myRectangle;
-         * 
- * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 显示对象的滚动矩形范围。显示对象被裁切为矩形定义的大小,当您更改 scrollRect 对象的 x 和 y 属性时,它会在矩形内滚动。 - * 滚动的显示对象始终以整像素为增量进行滚动。您可以通过设置 scrollRect Rectangle 对象的 x 属性来左右滚动对象, 还可以通过设置 - * scrollRect 对象的 y 属性来上下滚动对象。如果显示对象旋转了 90 度,并且您左右滚动它,则实际上显示对象会上下滚动。
- * - * 注意:要改变一个显示对象 scrollRect 属性的值,您必引用整个 scrollRect 对象,然后将它重新赋值给显示对象的 scrollRect 属性。 - * @example 以下代码改变了显示对象 scrollRect 的 x 属性值: - *
-         *     let myRectangle:Rectangle = myDisplayObject.scrollRect;
-         *     myRectangle.x += 10;
-         *     myDisplayObject.scrollRect = myRectangle;//设置完scrollRect的x、y、width、height值之后,一定要对myDisplayObject重新赋值scrollRect,不然会出问题。
-         * 
- * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - scrollRect: Rectangle; - /** - * @private - * - * @param value - */ - private $setScrollRect(value); - /** - * @private - */ - $blendMode: number; - /** - * A value from the BlendMode class that specifies which blend mode to use. Determine how a source image (new one) - * is drawn on the target image (old one).
- * If you attempt to set this property to an invalid value, Egret runtime set the value to BlendMode.NORMAL. - * @default egret.BlendMode.NORMAL - * @see egret.BlendMode - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * BlendMode 枚举中的一个值,用于指定要使用的混合模式,确定如何将一个源(新的)图像绘制到目标(已有)的图像上
- * 如果尝试将此属性设置为无效值,则运行时会将此值设置为 BlendMode.NORMAL。 - * @default egret.BlendMode.NORMAL - * @see egret.BlendMode - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - blendMode: string; - /** - * @private - * 被遮罩的对象 - */ - $maskedObject: DisplayObject; - /** - * @private - */ - $mask: DisplayObject; - /** - * @private - */ - $maskRect: Rectangle; - /** - * The calling display object is masked by the specified mask object. To ensure that masking works when the Stage - * is scaled, the mask display object must be in an active part of the display list. The mask object itself is not drawn. - * Set mask to null to remove the mask. To be able to scale a mask object, it must be on the display list. To be - * able to drag a mask object , it must be on the display list.
- * Note: A single mask object cannot be used to mask more than one calling display object. When the mask is assigned - * to a second display object, it is removed as the mask of the first object, and that object's mask property becomes null. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 调用显示对象被指定的 mask 对象遮罩。要确保当舞台缩放时蒙版仍然有效,mask 显示对象必须处于显示列表的活动部分。 - * 但不绘制 mask 对象本身。将 mask 设置为 null 可删除蒙版。要能够缩放遮罩对象,它必须在显示列表中。要能够拖动蒙版 - * 对象,它必须在显示列表中。
- * 注意:单个 mask 对象不能用于遮罩多个执行调用的显示对象。在将 mask 分配给第二个显示对象时,会撤消其作为第一个对象的遮罩, - * 该对象的 mask 属性将变为 null。 - * - * 下面例子为 mask 为 Rectangle 类型对象,这种情况下,修改 mask 的值后,一定要对 myDisplayObject 重新赋值 mask,不然会出问题。 - * @example 以下代码改变了显示对象 mask 的 x 属性值: - *
-         *     let myMask:Rectangle = myDisplayObject.mask;
-         *     myMask.x += 10;
-         *     myDisplayObject.mask = myMask;//设置完 mask 的x、y、width、height值之后,一定要对myDisplayObject重新赋值 mask,不然会出问题。
-         * 
- * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - mask: DisplayObject | Rectangle; - private $setMaskRect(value); - $filters: Array; - /** - * An indexed array that contains each filter object currently associated with the display object. - * @version Egret 3.1.0 - * @platform Web - * @language en_US - */ - /** - * 包含当前与显示对象关联的每个滤镜对象的索引数组。 - * @version Egret 3.1.0 - * @platform Web - * @language zh_CN - */ - filters: Array; - /** - * Returns a rectangle that defines the area of the display object relative to the coordinate system of the targetCoordinateSpace object. - * @param targetCoordinateSpace The display object that defines the coordinate system to use. - * @param resultRect A reusable instance of Rectangle for saving the results. Passing this parameter can reduce the number of reallocate objects - *, which allows you to get better code execution performance.. - * @returns The rectangle that defines the area of the display object relative to the targetCoordinateSpace object's coordinate system. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 返回一个矩形,该矩形定义相对于 targetCoordinateSpace 对象坐标系的显示对象区域。 - * @param targetCoordinateSpace 定义要使用的坐标系的显示对象。 - * @param resultRect 一个用于存储结果的可复用Rectangle实例,传入此参数能够减少内部创建对象的次数,从而获得更高的运行性能。 - * @returns 定义与 targetCoordinateSpace 对象坐标系统相关的显示对象面积的矩形。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - getTransformedBounds(targetCoordinateSpace: DisplayObject, resultRect?: Rectangle): Rectangle; - /** - * Obtain measurement boundary of display object - * @param resultRect {Rectangle} Optional. It is used to import Rectangle object for saving results, preventing duplicate object creation. - * @param calculateAnchor {boolean} Optional. It is used to determine whether to calculate anchor point. - * @returns {Rectangle} - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 获取显示对象的测量边界 - * @param resultRect {Rectangle} 可选参数,传入用于保存结果的Rectangle对象,避免重复创建对象。 - * @param calculateAnchor {boolean} 可选参数,是否会计算锚点。 - * @returns {Rectangle} - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - getBounds(resultRect?: Rectangle, calculateAnchor?: boolean): egret.Rectangle; - /** - * @private - */ - $getTransformedBounds(targetCoordinateSpace: DisplayObject, resultRect?: Rectangle): Rectangle; - /** - * Converts the point object from the Stage (global) coordinates to the display object's (local) coordinates. - * @param stageX the x value in the global coordinates - * @param stageY the y value in the global coordinates - * @param resultPoint A reusable instance of Point for saving the results. Passing this parameter can reduce the - * number of reallocate objects, which allows you to get better code execution performance. - * @returns A Point object with coordinates relative to the display object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将从舞台(全局)坐标转换为显示对象的(本地)坐标。 - * @param stageX 舞台坐标x - * @param stageY 舞台坐标y - * @param resultPoint 一个用于存储结果的可复用 Point 实例,传入此参数能够减少内部创建对象的次数,从而获得更高的运行性能。 - * @returns 具有相对于显示对象的坐标的 Point 对象。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - globalToLocal(stageX?: number, stageY?: number, resultPoint?: Point): Point; - /** - * Converts the point object from the display object's (local) coordinates to the Stage (global) coordinates. - * @param localX the x value in the local coordinates - * @param localY the x value in the local coordinates - * @param resultPoint A reusable instance of Point for saving the results. Passing this parameter can reduce the - * number of reallocate objects, which allows you to get better code execution performance. - * @returns A Point object with coordinates relative to the Stage. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将显示对象的(本地)坐标转换为舞台(全局)坐标。 - * @param localX 本地坐标 x - * @param localY 本地坐标 y - * @param resultPoint 一个用于存储结果的可复用 Point 实例,传入此参数能够减少内部创建对象的次数,从而获得更高的运行性能。 - * @returns 一个具有相对于舞台坐标的 Point 对象。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - localToGlobal(localX?: number, localY?: number, resultPoint?: Point): Point; - /** - * @private - * 获取显示对象占用的矩形区域集合,通常包括自身绘制的测量区域,如果是容器,还包括所有子项占据的区域。 - */ - $getOriginalBounds(): Rectangle; - /** - * @private - * 测量子项占用的矩形区域 - * @param bounds 测量结果存储在这个矩形对象内 - */ - $measureChildBounds(bounds: Rectangle): void; - /** - * @private - */ - $getContentBounds(): Rectangle; - /** - * @private - * 测量自身占用的矩形区域,注意:此测量结果并不包括子项占据的区域。 - * @param bounds 测量结果存储在这个矩形对象内 - */ - $measureContentBounds(bounds: Rectangle): void; - /** - * @private - */ - $parentDisplayList: egret.sys.DisplayList; - /** - * @private - * 渲染节点,不为空表示自身有绘制到屏幕的内容 - */ - $renderNode: sys.RenderNode; - $renderDirty: boolean; - /** - * @private - * 获取渲染节点 - */ - $getRenderNode(): sys.RenderNode; - $updateRenderMode(): void; - $renderMode: RenderMode; - /** - * @private - */ - private $measureFiltersOffset(fromParent); - /** - * @private - * 获取相对于指定根节点的连接矩阵。 - * @param root 根节点显示对象 - * @param matrix 目标显示对象相对于舞台的完整连接矩阵。 - */ - $getConcatenatedMatrixAt(root: DisplayObject, matrix: Matrix): void; - /** - * @private - * 更新renderNode - */ - $updateRenderNode(): void; - /** - * @private - */ - $hitTest(stageX: number, stageY: number): DisplayObject; - /** - * Calculate the display object to determine whether it overlaps or crosses with the points specified by the x and y parameters. The x and y parameters specify the points in the coordinates of the stage, rather than the points in the display object container that contains display objects (except the situation where the display object container is a stage). - * Note: Don't use accurate pixel collision detection on a large number of objects. Otherwise, this will cause serious performance deterioration. - * @param x {number} x coordinate of the object to be tested. - * @param y {number} y coordinate of the object to be tested. - * @param shapeFlag {boolean} Whether to check the actual pixel of object (true) or check that of border (false).Write realized. - * @returns {boolean} If display object overlaps or crosses with the specified point, it is true; otherwise, it is false. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 计算显示对象,以确定它是否与 x 和 y 参数指定的点重叠或相交。x 和 y 参数指定舞台的坐标空间中的点,而不是包含显示对象的显示对象容器中的点(除非显示对象容器是舞台)。 - * 注意,不要在大量物体中使用精确碰撞像素检测,这回带来巨大的性能开销 - * @param x {number} 要测试的此对象的 x 坐标。 - * @param y {number} 要测试的此对象的 y 坐标。 - * @param shapeFlag {boolean} 是检查对象 (true) 的实际像素,还是检查边框 (false) 的实际像素。 - * @returns {boolean} 如果显示对象与指定的点重叠或相交,则为 true;否则为 false。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - hitTestPoint(x: number, y: number, shapeFlag?: boolean): boolean; - /** - * @private - */ - static $enterFrameCallBackList: DisplayObject[]; - /** - * @private - */ - static $renderCallBackList: DisplayObject[]; - /** - * @private - */ - $addListener(type: string, listener: Function, thisObject: any, useCapture?: boolean, priority?: number, dispatchOnce?: boolean): void; - /** - * @inheritDoc - * @version Egret 2.4 - * @platform Web,Native - */ - removeEventListener(type: string, listener: Function, thisObject: any, useCapture?: boolean): void; - /** - * @inheritDoc - * @version Egret 2.4 - * @platform Web,Native - */ - dispatchEvent(event: Event): boolean; - /** - * @private - * 获取事件流列表。注意:Egret框架的事件流与Flash实现并不一致。 - * - * 事件流有三个阶段:捕获,目标,冒泡。 - * Flash里默认的的事件监听若不开启useCapture将监听目标和冒泡阶段。若开始capture将只能监听捕获当不包括目标的事件。 - * 可以在Flash中写一个简单的测试:实例化一个非容器显示对象,例如TextField。分别监听useCapture为true和false时的鼠标事件。 - * 点击后将只有useCapture为false的回调函数输出信息。也就带来一个问题「Flash的捕获阶段不能监听到最内层对象本身,只在父级列表有效」。 - * - * 而HTML里的事件流设置useCapture为true时是能监听到目标阶段的,也就是目标阶段会被触发两次,在捕获和冒泡过程各触发一次。这样可以避免 - * 前面提到的监听捕获无法监听目标本身的问题。 - * - * Egret最终采用了HTML里目标节点触发两次的事件流方式。 - */ - $getPropagationList(target: DisplayObject): DisplayObject[]; - /** - * @private - */ - $dispatchPropagationEvent(event: Event, list: DisplayObject[], targetIndex: number): void; - /** - * @inheritDoc - * @version Egret 2.4 - * @platform Web,Native - */ - willTrigger(type: string): boolean; - /** - * inspired by pixi.js - */ - private _tint; - /** - * @private - */ - $tintRGB: number; - /** - * Set a tint color for the current object - * @version Egret 5.2.24 - * @platform Web,Native - * @language en_US - */ - /** - * 给当前对象设置填充色 - * @version Egret 5.2.24 - * @platform Web,Native - * @language zh_CN - */ - tint: number; - /** - * @private - * inspired by pixi.js - */ - $sortDirty: boolean; - sortChildren(): void; - /** - * @private - */ - private _zIndex; - /** - * the z-order (front-to-back order) of the object - * @version Egret 5.2.24 - * @platform Web,Native - * @language en_US - */ - /** - * 设置对象的 Z 轴顺序(前后顺序) - * @version Egret 5.2.24 - * @platform Web,Native - * @language zh_CN - */ - zIndex: number; - /** - * @private - */ - $lastSortedIndex: number; - /** - * Allow objects to use zIndex sorting - * @version Egret 5.2.24 - * @platform Web,Native - * @language en_US - */ - /** - * 允许对象使用 zIndex 排序 - * @version Egret 5.2.24 - * @platform Web,Native - * @language zh_CN - */ - sortableChildren: boolean; - } -} -declare namespace egret { - let $TextureScaleFactor: number; - /** - * The Texture class encapsulates different image resources on different platforms. - * In HTML5, resource is an HTMLElement object - * In OpenGL / WebGL, resource is a texture ID obtained after the GPU is submitted - * The Texture class encapsulates the details implemented on the underlayer. Developers just need to focus on interfaces - * @see http://edn.egret.com/cn/docs/page/135 The use of texture packs - * @see http://edn.egret.com/cn/docs/page/123 Several ways of access to resources - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/Texture.ts - * @language en_US - */ - /** - * 纹理类是对不同平台不同的图片资源的封装 - * 在HTML5中,资源是一个HTMLElement对象 - * 在OpenGL / WebGL中,资源是一个提交GPU后获取的纹理id - * Texture类封装了这些底层实现的细节,开发者只需要关心接口即可 - * @see http://edn.egret.com/cn/docs/page/135 纹理集的使用 - * @see http://edn.egret.com/cn/docs/page/123 获取资源的几种方式 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/Texture.ts - * @language zh_CN - */ - class Texture extends HashObject { - /** - * Create an egret.Texture object - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 egret.Texture 对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(); - /** - * Whether to destroy the corresponding BitmapData when the texture is destroyed - * @version Egret 5.0.8 - * @platform Web,Native - * @language en_US - */ - /** - * 销毁纹理时是否销毁对应BitmapData - * @version Egret 5.0.8 - * @platform Web,Native - * @language zh_CN - */ - disposeBitmapData: boolean; - /** - * @private - * 表示这个纹理在 bitmapData 上的 x 起始位置 - */ - $bitmapX: number; - /** - * @private - * 表示这个纹理在 bitmapData 上的 y 起始位置 - */ - $bitmapY: number; - /** - * @private - * 表示这个纹理在 bitmapData 上的宽度 - */ - $bitmapWidth: number; - /** - * @private - * 表示这个纹理在 bitmapData 上的高度 - */ - $bitmapHeight: number; - /** - * @private - * 表示这个纹理显示了之后在 x 方向的渲染偏移量 - */ - $offsetX: number; - /** - * @private - * 表示这个纹理显示了之后在 y 方向的渲染偏移量 - */ - $offsetY: number; - /** - * @private - * 纹理宽度 - */ - private $textureWidth; - /** - * Texture width, read only - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 纹理宽度,只读属性,不可以设置 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly textureWidth: number; - $getTextureWidth(): number; - /** - * @private - * 纹理高度 - */ - private $textureHeight; - /** - * Texture height, read only - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 纹理高度,只读属性,不可以设置 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly textureHeight: number; - $getTextureHeight(): number; - $getScaleBitmapWidth(): number; - $getScaleBitmapHeight(): number; - /** - * @private - * 表示bitmapData.width - */ - $sourceWidth: number; - /** - * @private - * 表示bitmapData.height - */ - $sourceHeight: number; - /** - * @private - */ - $bitmapData: BitmapData; - /** - * @private - */ - $ktxData: ArrayBuffer; - /** - * @private - */ - $rotated: boolean; - /** - * The BitmapData object being referenced. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 被引用的 BitmapData 对象。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - bitmapData: BitmapData; - /** - * Set the BitmapData object. - * @version Egret 3.2.1 - * @platform Web,Native - * @language en_US - */ - /** - * 设置 BitmapData 对象。 - * @version Egret 3.2.1 - * @platform Web,Native - * @language zh_CN - */ - _setBitmapData(value: BitmapData): void; - /** - * The KTX object being referenced. - * @version Egret 5.2.21 - * @platform Web,Native - * @language en_US - */ - /** - * 被引用的 KTXData 对象。 - * @version Egret 5.2.21 - * @platform Web,Native - * @language zh_CN - */ - ktxData: ArrayBuffer; - /** - * Set the KTXData object. - * @version Egret 3.2.1 - * @platform Web,Native - * @language en_US - */ - /** - * 设置 KTXData 对象。 - * @version Egret 3.2.1 - * @platform Web,Native - * @language zh_CN - */ - _setKtxData(value: ArrayBuffer): void; - /** - * @private - * 设置Texture数据 - * @param bitmapX - * @param bitmapY - * @param bitmapWidth - * @param bitmapHeight - * @param offsetX - * @param offsetY - * @param textureWidth - * @param textureHeight - * @param sourceWidth - * @param sourceHeight - */ - $initData(bitmapX: number, bitmapY: number, bitmapWidth: number, bitmapHeight: number, offsetX: number, offsetY: number, textureWidth: number, textureHeight: number, sourceWidth: number, sourceHeight: number, rotated?: boolean): void; - /** - * @deprecated - */ - getPixel32(x: number, y: number): number[]; - /** - * Obtain the color value for the specified pixel region - * @param x The x coordinate of the pixel region - * @param y The y coordinate of the pixel region - * @param width The width of the pixel region - * @param height The height of the pixel region - * @returns Specifies the color value for the pixel region - * @version Egret 3.2.1 - * @platform Web,Native - * @language en_US - */ - /** - * 获取指定像素区域的颜色值 - * @param x 像素区域的X轴坐标 - * @param y 像素区域的Y轴坐标 - * @param width 像素区域的宽度 - * @param height 像素区域的高度 - * @returns 指定像素区域的颜色值 - * @version Egret 3.2.1 - * @platform Web - * @language zh_CN - */ - getPixels(x: number, y: number, width?: number, height?: number): number[]; - /** - * Convert base64 string, if the picture (or pictures included) cross-border or null - * @param type Type conversions, such as "image / png" - * @param rect The need to convert the area - * @param smoothing Whether to convert data to the smoothing process - * @returns {any} base64 string - * @version Egret 2.4 - * @language en_US - */ - /** - * 转换成base64字符串,如果图片(或者包含的图片)跨域,则返回null - * @param type 转换的类型,如 "image/png" - * @param rect 需要转换的区域 - * @param {any} encoderOptions 编码用的参数 - * @returns {any} base64字符串 - * @version Egret 2.4 - * @language zh_CN - */ - toDataURL(type: string, rect?: egret.Rectangle, encoderOptions?: any): string; - /** - * Crop designated area and save it as image. - * native support only "image / png" and "image / jpeg"; Web browser because of the various implementations are not the same, it is recommended to use only these two kinds. - * @param type Type conversions, such as "image / png" - * @param filePath The path name of the image (the home directory for the game's private space, the path can not have "../",Web supports only pass names.) - * @param rect The need to convert the area - * @version Egret 2.4 - * @platform Native - * @language en_US - */ - /** - * 裁剪指定区域并保存成图片。 - * native只支持 "image/png" 和 "image/jpeg";Web中由于各个浏览器的实现不一样,因此建议也只用这2种。 - * @param type 转换的类型,如 "image/png" - * @param filePath 图片的名称的路径(主目录为游戏的私有空间,路径中不能有 "../",Web只支持传名称。) - * @param rect 需要转换的区域 - * @version Egret 2.4 - * @platform Native - * @language zh_CN - */ - saveToFile(type: string, filePath: string, rect?: egret.Rectangle): void; - /** - * dispose texture - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 释放纹理 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - dispose(): void; - } -} -declare namespace egret { - /** - * The Event class is used as the base class for the creation of Event objects, which are passed as parameters to event - * listeners when an event occurs.The properties of the Event class carry basic information about an event, such as - * the event's type or whether the event's default behavior can be canceled. For many events, such as the events represented - * by the Event class constants, this basic information is sufficient. Other events, however, may require more detailed - * information. Events associated with a touch tap, for example, need to include additional information about the - * location of the touch event. You can pass such additional information to event listeners by extending the Event class, - * which is what the TouchEvent class does. Egret API defines several Event subclasses for common events that require - * additional information. Events associated with each of the Event subclasses are described in the documentation for - * each class.The methods of the Event class can be used in event listener functions to affect the behavior of the event - * object. Some events have an associated default behavior. Your event listener can cancel this behavior by calling the - * preventDefault() method. You can also make the current event listener the last one to process an event by calling - * the stopPropagation() or stopImmediatePropagation() method. - * @see egret.EventDispatcher - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/Event.ts - * @see http://edn.egret.com/cn/docs/page/798 取消触摸事件 - * @language en_US - */ - /** - * Event 类作为创建事件实例的基类,当发生事件时,Event 实例将作为参数传递给事件侦听器。Event 类的属性包含有关事件的基本信息,例如事件 - * 的类型或者是否可以取消事件的默认行为。对于许多事件(如由 Event 类常量表示的事件),此基本信息就足够了。但其他事件可能需要更详细的信息。 - * 例如,与触摸关联的事件需要包括有关触摸事件的位置信息。您可以通过扩展 Event 类(TouchEvent 类执行的操作)将此类其他信息传递给事件侦听器。 - * Egret API 为需要其他信息的常见事件定义多个 Event 子类。与每个 Event 子类关联的事件将在每个类的文档中加以介绍。Event 类的方法可以在 - * 事件侦听器函数中使用以影响事件对象的行为。某些事件有关联的默认行为,通过调用 preventDefault() 方法,您的事件侦听器可以取消此行为。 - * 可以通过调用 stopPropagation() 或 stopImmediatePropagation() 方法,将当前事件侦听器作为处理事件的最后一个事件侦听器。 - * @see egret.EventDispatcher - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/Event.ts - * @see http://edn.egret.com/cn/docs/page/798 取消触摸事件 - * @language zh_CN - */ - class Event extends HashObject { - /** - * Dispatched when a display object is added to the on stage display list, either directly or through the addition - * of a sub tree in which the display object is contained. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 在将显示对象直接添加到舞台显示列表或将包含显示对象的子树添加至舞台显示列表中时调度。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static ADDED_TO_STAGE: string; - /** - * Dispatched when a display object is about to be removed from the display list, either directly or through the removal - * of a sub tree in which the display object is contained. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 在从显示列表中直接删除显示对象或删除包含显示对象的子树时调度。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static REMOVED_FROM_STAGE: string; - /** - * Dispatched when a display object is added to the display list. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将显示对象添加到显示列表中时调度。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static ADDED: string; - /** - * Dispatched when a display object is about to be removed from the display list. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将要从显示列表中删除显示对象时调度。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static REMOVED: string; - /** - * [broadcast event] Dispatched when the playhead is entering a new frame. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * [广播事件] 进入新的一帧,监听此事件将会在下一帧开始时触发一次回调。这是一个广播事件,可以在任何一个显示对象上监听,无论它是否在显示列表中。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static ENTER_FRAME: string; - /** - * Dispatched when the display list is about to be updated and rendered. - * Note: Every time you want to receive a render event,you must call the stage.invalidate() method. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 渲染事件,监听此事件将会在本帧末即将开始渲染的前一刻触发回调,这是一个广播事件,可以在任何一个显示对象上监听,无论它是否在显示列表中。 - * 注意:每次您希望 Egret 发送 Event.RENDER 事件时,都必须调用 stage.invalidate() 方法,由于每帧只会触发一次屏幕刷新, - * 若在 Event.RENDER 回调函数执行期间再次调用stage.invalidate(),将会被忽略。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static RENDER: string; - /** - * Dispatched when the size of stage or UIComponent is changed. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 舞台尺寸或UI组件尺寸发生改变 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static RESIZE: string; - /** - * Dispatched when the value or selection of a property is chaned. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 属性值或状态发生改变。通常是按钮的选中状态,或者列表的选中项索引改变。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static CHANGE: string; - /** - * Dispatched when the value or selection of a property is going to change.you can cancel this by calling the - * preventDefault() method. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 属性值或状态即将发生改变,通常是按钮的选中状态,或者列表的选中项索引改变。可以通过调用 preventDefault() 方法阻止索引发生更改。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static CHANGING: string; - /** - * Dispatched when the net request is complete. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 网络请求加载完成 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static COMPLETE: string; - /** - * Dispatched when loop completed. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 循环完成。循环最后一次只派发 COMPLETE 事件,不派发 LOOP_COMPLETE 事件。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static LOOP_COMPLETE: string; - /** - * Dispatched when the TextInput instance gets focus. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * TextInput实例获得焦点 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static FOCUS_IN: string; - /** - * Dispatched when the TextInput instance loses focus. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * TextInput实例失去焦点 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static FOCUS_OUT: string; - /** - * Dispatched when the playback is ended. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 动画声音等播放完成 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static ENDED: string; - /** - * 游戏激活 - * @version Egret 2.4 - * @platform Web,Native - */ - static ACTIVATE: string; - /** - * 取消激活 - * @version Egret 2.4 - * @platform Web,Native - */ - static DEACTIVATE: string; - /** - * Event.CLOSE 常量定义 close 事件对象的 type 属性的值。 - * @version Egret 2.4 - * @platform Web,Native - */ - static CLOSE: string; - /** - * Event.CONNECT 常量定义 connect 事件对象的 type 属性的值。 - * @version Egret 2.4 - * @platform Web,Native - */ - static CONNECT: string; - /** - * Event.LEAVE_STAGE 常量定义 leaveStage 事件对象的 type 属性的值。 - * @version Egret 2.4 - * @platform Web,Native - */ - static LEAVE_STAGE: string; - /** - * Event.SOUND_COMPLETE 常量定义 在声音完成播放后调度。 - * @version Egret 2.4 - * @platform Web,Native - */ - static SOUND_COMPLETE: string; - /** - * Creates an Event object to pass as a parameter to event listeners. - * @param type The type of the event, accessible as Event.type. - * @param bubbles Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false. - * @param cancelable Determines whether the Event object can be canceled. The default values is false. - * @param data the optional data associated with this event - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个作为参数传递给事件侦听器的 Event 对象。 - * @param type 事件的类型,可以作为 Event.type 访问。 - * @param bubbles 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。 - * @param cancelable 确定是否可以取消 Event 对象。默认值为 false。 - * @param data 与此事件对象关联的可选数据。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(type: string, bubbles?: boolean, cancelable?: boolean, data?: any); - /** - * the optional data associated with this event - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 与此事件对象关联的可选数据。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - data: any; - /** - * @private - */ - $type: string; - /** - * The type of event. The type is case-sensitive. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 事件的类型。类型区分大小写。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly type: string; - /** - * @private - */ - $bubbles: boolean; - /** - * Indicates whether an event is a bubbling event. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示事件是否为冒泡事件。如果事件可以冒泡,则此值为 true;否则为 false。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly bubbles: boolean; - /** - * @private - */ - $cancelable: boolean; - /** - * Indicates whether the behavior associated with the event can be prevented. If the behavior can be - * canceled, this value is true; otherwise it is false. - * @see #preventDefault() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示是否可以阻止与事件相关联的行为。如果可以取消该行为,则此值为 true;否则为 false。 - * @see #preventDefault() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly cancelable: boolean; - /** - * @private - */ - $eventPhase: number; - /** - * The current phase in the event flow. This property can contain the following numeric values: - * The capture phase (EventPhase.CAPTURING_PHASE). - * The target phase (EventPhase.AT_TARGET) - * The bubbling phase (EventPhase.BUBBLING_PHASE). - * @see egret.EventPhase - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 事件流中的当前阶段。此属性可以包含以下数值: - * 捕获阶段 (EventPhase.CAPTURING_PHASE)。 - * 目标阶段 (EventPhase.AT_TARGET)。 - * 冒泡阶段 (EventPhase.BUBBLING_PHASE)。 - * @see egret.EventPhase - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly eventPhase: number; - /** - * @private - */ - $currentTarget: any; - /** - * The object that is actively processing the Event object with an event listener. For example, if a - * user clicks an OK button, the current target could be the node containing that button or one of its ancestors - * that has registered an event listener for that event. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 当前正在使用某个事件侦听器处理 Event 对象的对象。例如,如果用户单击“确定”按钮, - * 则当前目标可以是包含该按钮的节点,也可以是它的已为该事件注册了事件侦听器的始祖之一。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly currentTarget: any; - /** - * @private - */ - $target: any; - /** - * The event target. This property contains the target node. For example, if a user clicks an OK button, - * the target node is the display list node containing that button. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 事件目标。此属性包含目标节点。例如,如果用户单击“确定”按钮,则目标节点就是包含该按钮的显示列表节点。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly target: any; - $setTarget(target: any): boolean; - /** - * @private - */ - $isDefaultPrevented: boolean; - /** - * Checks whether the preventDefault() method has been called on the event. If the preventDefault() method has been - * called, returns true; otherwise, returns false. - * @returns If preventDefault() has been called, returns true; otherwise, returns false. - * @see #preventDefault() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 检查是否已对事件调用 preventDefault() 方法。 - * @returns 如果已调用 preventDefault() 方法,则返回 true;否则返回 false。 - * @see #preventDefault() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - isDefaultPrevented(): boolean; - /** - * Cancels an event's default behavior if that behavior can be canceled.Many events have associated behaviors that - * are carried out by default. For example, if a user types a character into a text input, the default behavior - * is that the character is displayed in the text input. Because the TextEvent.TEXT_INPUT event's default behavior - * can be canceled, you can use the preventDefault() method to prevent the character from appearing. - * You can use the Event.cancelable property to check whether you can prevent the default behavior associated with - * a particular event. If the value of Event.cancelable is true, then preventDefault() can be used to cancel the event; - * otherwise, preventDefault() has no effect. - * @see #cancelable - * @see #isDefaultPrevented - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 如果可以取消事件的默认行为,则取消该行为。 - * 许多事件都有默认执行的关联行为。例如,如果用户在文本字段中键入一个字符,则默认行为就是在文本字段中显示该字符。 - * 由于可以取消 TextEvent.TEXT_INPUT 事件的默认行为,因此您可以使用 preventDefault() 方法来防止显示该字符。 - * 您可以使用 Event.cancelable 属性来检查是否可以防止与特定事件关联的默认行为。如果 Event.cancelable 的值为 true, - * 则可以使用 preventDefault() 来取消事件;否则,preventDefault() 无效。 - * @see #cancelable - * @see #isDefaultPrevented - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - preventDefault(): void; - /** - * @private - */ - $isPropagationStopped: boolean; - /** - * Prevents processing of any event listeners in nodes subsequent to the current node in the event flow. This method - * does not affect any event listeners in the current node (currentTarget). In contrast, the stopImmediatePropagation() - * method prevents processing of event listeners in both the current node and subsequent nodes. Additional calls to this - * method have no effect. This method can be called in any phase of the event flow.
- * Note: This method does not cancel the behavior associated with this event; see preventDefault() for that functionality. - * @see #stopImmediatePropagation() - * @see #preventDefault() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 防止对事件流中当前节点的后续节点中的所有事件侦听器进行处理。此方法不会影响当前节点 currentTarget 中的任何事件侦听器。 - * 相比之下,stopImmediatePropagation() 方法可以防止对当前节点中和后续节点中的事件侦听器进行处理。 - * 对此方法的其它调用没有任何效果。可以在事件流的任何阶段中调用此方法。
- * 注意:此方法不会取消与此事件相关联的行为;有关此功能的信息,请参阅 preventDefault()。 - * @see #stopImmediatePropagation() - * @see #preventDefault() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - stopPropagation(): void; - /** - * @private - */ - $isPropagationImmediateStopped: boolean; - /** - * Prevents processing of any event listeners in the current node and any subsequent nodes in the event flow. - * This method takes effect immediately, and it affects event listeners in the current node. In contrast, the - * stopPropagation() method doesn't take effect until all the event listeners in the current node finish processing.
- * Note: This method does not cancel the behavior associated with this event; see preventDefault() for that functionality. - * @see #stopPropagation() - * @see #preventDefault() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 防止对事件流中当前节点中和所有后续节点中的事件侦听器进行处理。此方法会立即生效,并且会影响当前节点中的事件侦听器。 - * 相比之下,在当前节点中的所有事件侦听器都完成处理之前,stopPropagation() 方法不会生效。
- * 注意:此方法不会取消与此事件相关联的行为;有关此功能的信息,请参阅 preventDefault()。 - * @see #stopPropagation() - * @see #preventDefault() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - stopImmediatePropagation(): void; - /** - * This method will be called automatically when you pass the event object as the parameters to the Event.release() method. - * If your custom event is designed for reusable,you should override this method to make sure all the references to external - * objects are cleaned. if not,it may cause memory leaking. - * @see egret.Event.create() - * @see egret.Event.release() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 当事件实例传递给Event.release()静态方法时,实例上的clean()方法将会被自动调用。 - * 若此自定义事件的实例设计为可以循环复用的,为了避免引起内存泄露,自定义事件需要覆盖此方法来确保实例被缓存前断开对外部对象的一切引用。 - * @see egret.Event.create() - * @see egret.Event.release() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - protected clean(): void; - /** - * EventDispatcher object using the specified event object thrown Event. Objects thrown objects will be cached in the pool for the next round robin. - * @param target the event target - * @param type The type of the event. Event listeners can access this information through the inherited type property. - * @param bubbles Determines whether the Event object bubbles. Event listeners can access this information through - * the inherited bubbles property. - * @param data {any} data - * @method egret.Event.dispatchEvent - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 使用指定的 EventDispatcher 对象来抛出 Event 事件对象。抛出的对象将会缓存在对象池上,供下次循环复用。 - * @param target {egret.IEventDispatcher} 派发事件目标 - * @param type {string} 事件类型 - * @param bubbles {boolean} 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。 - * @param data {any} 事件data - * @method egret.Event.dispatchEvent - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static dispatchEvent(target: IEventDispatcher, type: string, bubbles?: boolean, data?: any): boolean; - /** - * @private - * - * @param EventClass - * @returns - */ - static _getPropertyData(EventClass: any): any; - /** - * Gets one event instance from the object pool or create a new one. We highly recommend using the Event.create() - * and Event.release() methods to create and release an event object,it can reduce the number of reallocate objects, - * which allows you to get better code execution performance.
- * Note: If you want to use this method to initialize your custom event object,you must make sure the constructor - * of your custom event is the same as the constructor of egret.Event. - * @param EventClass Event Class。 - * @param type The type of the event, accessible as Event.type. - * @param bubbles Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false. - * @param cancelable Determines whether the Event object can be canceled. The default values is false. - * @example - *
-         *    let event = Event.create(Event,type, bubbles);
-         *    event.data = data;    //optional,initializes custom data here
-         *    this.dispatchEvent(event);
-         *    Event.release(event);
-         * 
- * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从对象池中取出或创建一个新的事件实例。我们建议您尽可能使用Event.create()和Event.release() 这一对方法来创建和释放事件对象, - * 这一对方法会将事件实例在内部缓存下来供下次循环使用,减少对象的创建次数,从而获得更高的代码运行性能。
- * 注意:若使用此方法来创建自定义事件的实例,自定义的构造函数参数列表必须跟Event类一致。 - * @param EventClass Event类名。 - * @param type 事件的类型,可以作为 Event.type 访问。 - * @param bubbles 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。 - * @param cancelable 确定是否可以取消 Event 对象。默认值为 false。 - * @example - *
-         *    let event = Event.create(Event,type, bubbles);
-         *    event.data = data;  //可选,若指定义事件上需要附加其他参数,可以在获取实例后在此处设置。
-         *    this.dispatchEvent(event);
-         *    Event.release(event);
-         * 
- * @see #clean() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static create(EventClass: { - new (type: string, bubbles?: boolean, cancelable?: boolean): T; - eventPool?: Event[]; - }, type: string, bubbles?: boolean, cancelable?: boolean): T; - /** - * Releases an event object and cache it into the object pool.We highly recommend using the Event.create() - * and Event.release() methods to create and release an event object,it can reduce the number of reallocate objects, - * which allows you to get better code execution performance.
- * Note: The parameters of this method only accepts an instance created by the Event.create() method. - * if not,it may throw an error. - * @example - *
-         *    let event = Event.create(Event,type, bubbles);
-         *    event.data = data; //optional,initializes custom data here
-         *    this.dispatchEvent(event);
-         *    Event.release(event);
-         * 
- * @see #clean() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 释放一个事件对象,并缓存到对象池。我们建议您尽可能使用Event.create()和Event.release() 这一对方法来创建和释放事件对象, - * 这一对方法会将事件实例在内部缓存下来供下次循环使用,减少对象的创建次数,从而获得更高的代码运行性能。
- * 注意:此方法只能传入由Event.create()创建的事件实例,传入非法对象实例可能会导致报错。 - * @example - *
-         *    let event = Event.create(Event,type, bubbles);
-         *    event.data = data;   //可选,若指定义事件上需要附加其他参数,可以在获取实例后在此处设置。
-         *    this.dispatchEvent(event);
-         *    Event.release(event);
-         * 
- * @see #clean() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static release(event: Event): void; - } -} -/** - * Is debug mode. - * @version Egret 2.5 - * @platform Web,Native - * @language en_US - */ -/** - * 是否为 debug 模式。 - * @version Egret 2.5 - * @platform Web,Native - * @language zh_CN - */ -declare let DEBUG: boolean; -/** - * Is release mode. - * @version Egret 2.5 - * @platform Web,Native - * @language en_US - */ -/** - * 是否为 release 模式。 - * @version Egret 2.5 - * @platform Web,Native - * @language zh_CN - */ -declare let RELEASE: boolean; -declare namespace egret { - /** - * @private - */ - function $error(code: number, ...params: any[]): void; - /** - * @private - */ - function $warn(code: number, ...params: any[]): void; - /** - * @private - */ - function getString(code: number, ...params: any[]): string; - /** - * @private - */ - function $markCannotUse(instance: any, property: string, defaultVale: any): void; -} -declare namespace egret { - /** - * The Point object represents a location in a two-dimensional coordinate system, where x represents the horizontal - * axis and y represents the vertical axis. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/geom/Point.ts - * @language en_US - */ - /** - * Point 对象表示二维坐标系统中的某个位置,其中 x 表示水平轴,y 表示垂直轴。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/geom/Point.ts - * @language zh_CN - */ - class Point extends HashObject { - /** - * Releases a point instance to the object pool - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 释放一个Point实例到对象池 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static release(point: Point): void; - /** - * get a point instance from the object pool or create a new one. - * @param x The horizontal coordinate. - * @param y The vertical coordinate. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从对象池中取出或创建一个新的Point对象。 - * @param x 该对象的x属性值,默认为0 - * @param y 该对象的y属性值,默认为0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static create(x: number, y: number): Point; - /** - * Creates a new point. If you pass no parameters to this method, a point is created at (0,0). - * @param x The horizontal coordinate. - * @param y The vertical coordinate. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 egret.Point 对象.若不传入任何参数,将会创建一个位于(0,0)位置的点。 - * @param x 该对象的x属性值,默认为0 - * @param y 该对象的y属性值,默认为0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(x?: number, y?: number); - /** - * The horizontal coordinate. - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 该点的水平坐标。 - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - x: number; - /** - * The vertical coordinate. - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 该点的垂直坐标。 - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - y: number; - /** - * The length of the line segment from (0,0) to this point. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从 (0,0) 到此点的线段长度。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly length: number; - /** - * Sets the members of Point to the specified values - * @param x The horizontal coordinate. - * @param y The vertical coordinate. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将 Point 的成员设置为指定值 - * @param x 该对象的x属性值 - * @param y 该对象的y属性值 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - setTo(x: number, y: number): Point; - /** - * Creates a copy of this Point object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 克隆点对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - clone(): Point; - /** - * Determines whether two points are equal. Two points are equal if they have the same x and y values. - * @param toCompare The point to be compared. - * @returns A value of true if the object is equal to this Point object; false if it is not equal. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 确定两个点是否相同。如果两个点具有相同的 x 和 y 值,则它们是相同的点。 - * @param toCompare 要比较的点。 - * @returns 如果该对象与此 Point 对象相同,则为 true 值,如果不相同,则为 false。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - equals(toCompare: Point): boolean; - /** - * Returns the distance between pt1 and pt2. - * @param p1 The first point. - * @param p2 The second point. - * @returns The distance between the first and second points. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 返回 pt1 和 pt2 之间的距离。 - * @param p1 第一个点 - * @param p2 第二个点 - * @returns 第一个点和第二个点之间的距离。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static distance(p1: Point, p2: Point): number; - /** - * Copies all of the point data from the source Point object into the calling Point object. - * @param sourcePoint The Point object from which to copy the data. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将源 Point 对象中的所有点数据复制到调用方 Point 对象中。 - * @param sourcePoint 要从中复制数据的 Point 对象。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - copyFrom(sourcePoint: Point): void; - /** - * Adds the coordinates of another point to the coordinates of this point to create a new point. - * @param v The point to be added. - * @returns The new point. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将另一个点的坐标添加到此点的坐标以创建一个新点。 - * @param v 要添加的点。 - * @returns 新点。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - add(v: Point): Point; - /** - * Determines a point between two specified points. - * The parameter f determines where the new interpolated point is located relative to the two end points specified by parameters pt1 and pt2. The closer the value of the parameter f is to 1.0, the closer the interpolated point is to the first point (parameter pt1). The closer the value of the parameter f is to 0, the closer the interpolated point is to the second point (parameter pt2). - * @param pt1 The first point. - * @param pt2 The second point. - * @param f The level of interpolation between the two points. Indicates where the new point will be, along the line between pt1 and pt2. If f=1, pt1 is returned; if f=0, pt2 is returned. - * @returns The new interpolated point. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 确定两个指定点之间的点。 - * 参数 f 确定新的内插点相对于参数 pt1 和 pt2 指定的两个端点所处的位置。参数 f 的值越接近 1.0,则内插点就越接近第一个点(参数 pt1)。参数 f 的值越接近 0,则内插点就越接近第二个点(参数 pt2)。 - * @param pt1 第一个点。 - * @param pt2 第二个点。 - * @param f 两个点之间的内插级别。表示新点将位于 pt1 和 pt2 连成的直线上的什么位置。如果 f=1,则返回 pt1;如果 f=0,则返回 pt2。 - * @returns 新的内插点。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static interpolate(pt1: Point, pt2: Point, f: number): Point; - /** - * Scales the line segment between (0,0) and the current point to a set length. - * @param thickness The scaling value. For example, if the current point is (0,5), and you normalize it to 1, the point returned is at (0,1). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将 (0,0) 和当前点之间的线段缩放为设定的长度。 - * @param thickness 缩放值。例如,如果当前点为 (0,5) 并且您将它规范化为 1,则返回的点位于 (0,1) 处。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - normalize(thickness: number): void; - /** - * Offsets the Point object by the specified amount. The value of dx is added to the original value of x to create the new x value. The value of dy is added to the original value of y to create the new y value. - * @param dx The amount by which to offset the horizontal coordinate, x. - * @param dy The amount by which to offset the vertical coordinate, y. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 按指定量偏移 Point 对象。dx 的值将添加到 x 的原始值中以创建新的 x 值。dy 的值将添加到 y 的原始值中以创建新的 y 值。 - * @param dx 水平坐标 x 的偏移量。 - * @param dy 水平坐标 y 的偏移量。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - offset(dx: number, dy: number): void; - /** - * Converts a pair of polar coordinates to a Cartesian point coordinate. - * @param len The length coordinate of the polar pair. - * @param angle The angle, in radians, of the polar pair. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将一对极坐标转换为笛卡尔点坐标。 - * @param len 极坐标对的长度。 - * @param angle 极坐标对的角度(以弧度表示)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static polar(len: number, angle: number): Point; - /** - * Subtracts the coordinates of another point from the coordinates of this point to create a new point. - * @param v The point to be subtracted. - * @returns The new point. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从此点的坐标中减去另一个点的坐标以创建一个新点。 - * @param v 要减去的点。 - * @returns 新点。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - subtract(v: Point): Point; - /** - * Returns a string that contains the values of the x and y coordinates. The string has the form "(x=x, y=y)", so calling the toString() method for a point at 23,17 would return "(x=23, y=17)". - * @returns The string representation of the coordinates. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 返回包含 x 和 y 坐标的值的字符串。该字符串的格式为 "(x=x, y=y)",因此为点 23,17 调用 toString() 方法将返回 "(x=23, y=17)"。 - * @returns 坐标的字符串表示形式。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - toString(): string; - } - /** - * @private - * 仅供框架内复用,要防止暴露引用到外部。 - */ - let $TempPoint: Point; -} -declare namespace egret { - /** - * The DisplayObjectContainer class is a basic display list building block: a display list node that can contain children. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/DisplayObjectContainer.ts - * @language en_US - */ - /** - * DisplayObjectContainer 类是基本显示列表构造块:一个可包含子项的显示列表节点。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/DisplayObjectContainer.ts - * @language zh_CN - */ - class DisplayObjectContainer extends DisplayObject { - /** - * @private - */ - static $EVENT_ADD_TO_STAGE_LIST: DisplayObject[]; - /** - * @private - */ - static $EVENT_REMOVE_FROM_STAGE_LIST: DisplayObject[]; - /** - * Creates a new DisplayObjectContainer instance. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 实例化一个容器 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(); - /** - * Returns the number of children of this object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 返回此对象的子项数目。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly numChildren: number; - /** - * Set children sort mode. - * @param value {string} The sort mode - * @see egret.ChildrenSortMode - * @version Egret 5.2.19 - * @platform Native - * @language en_US - */ - /** - * 设置子项目的排序方式 - * @param value {string} 排序方式 - * @see egret.ChildrenSortMode - * @version Egret 5.2.19 - * @platform Native - * @language en_US - */ - setChildrenSortMode(value: string): void; - /** - * Adds a child DisplayObject instance to this DisplayObjectContainer instance. The child is added to the front - * (top) of all other children in this DisplayObjectContainer instance. (To add a child to a specific index position, - * use the addChildAt() method.)If you add a child object that already has a different display object container - * as a parent, the object is removed from the child list of the other display object container. - * @param child The DisplayObject instance to add as a child of this DisplayObjectContainer instance. - * @returns 在 child The DisplayObject instance that you pass in the child parameter. - * @see #addChildAt() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将一个 DisplayObject 子实例添加到该 DisplayObjectContainer 实例中。子项将被添加到该 DisplayObjectContainer 实例中其他 - * 所有子项的前(上)面。(要将某子项添加到特定索引位置,请使用 addChildAt() 方法。) - * @param child 要作为该 DisplayObjectContainer 实例的子项添加的 DisplayObject 实例。 - * @returns 在 child 参数中传递的 DisplayObject 实例。 - * @see #addChildAt() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - addChild(child: DisplayObject): DisplayObject; - /** - * Adds a child DisplayObject instance to this DisplayObjectContainer instance. The child is added at the index position - * specified. An index of 0 represents the back (bottom) of the display list for this DisplayObjectContainer object. - * If you add a child object that already has a different display object container as a parent, the object is removed - * from the child list of the other display object container. - * @param child The DisplayObject instance to add as a child of this DisplayObjectContainer instance. - * @param index The index position to which the child is added. If you specify a currently occupied index position, - * the child object that exists at that position and all higher positions are moved up one position in the child list. - * @returns The DisplayObject instance that you pass in the child parameter. - * @see #addChild() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将一个 DisplayObject 子实例添加到该 DisplayObjectContainer 实例中。该子项将被添加到指定的索引位置。索引为 0 表示该 - * DisplayObjectContainer 对象的显示列表的后(底)部。如果添加一个已将其它显示对象容器作为父项的子对象,则会从其它显示对象容器的子列表中删除该对象。 - * @param child 要作为该 DisplayObjectContainer 实例的子项添加的 DisplayObject 实例。 - * @param index 添加该子项的索引位置。 如果指定当前占用的索引位置,则该位置以及所有更高位置上的子对象会在子级列表中上移一个位置。 - * @returns 在 child 参数中传递的 DisplayObject 实例。 - * @see #addChild() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - addChildAt(child: DisplayObject, index: number): DisplayObject; - /** - * @private - */ - $doAddChild(child: DisplayObject, index: number, notifyListeners?: boolean): DisplayObject; - /** - * Determines whether the specified display object is a child of the DisplayObjectContainer instance or the instance - * itself. The search includes the entire display list including this DisplayObjectContainer instance. Grandchildren, - * great-grandchildren, and so on each return true. - * @param child The child object to test. - * @returns true if the child object is a child of the DisplayObjectContainer or the container itself; otherwise false. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 确定指定显示对象是 DisplayObjectContainer 实例的子项或该实例本身。搜索包括整个显示列表(其中包括此 DisplayObjectContainer 实例)。 - * 孙项、曾孙项等,每项都返回 true。 - * @param child 要测试的子对象。 - * @returns 如果 child 对象是 DisplayObjectContainer 的子项或容器本身,则为 true;否则为 false。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - contains(child: DisplayObject): boolean; - /** - * Returns the child display object instance that exists at the specified index. - * @param index The index position of the child object. - * @returns The child display object at the specified index position. - * @see #getChildByName() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 返回位于指定索引处的子显示对象实例。 - * @param index 子对象的索引位置。 - * @returns 位于指定索引位置处的子显示对象。 - * @see #getChildByName() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - getChildAt(index: number): DisplayObject; - /** - * Returns the index position of a child DisplayObject instance. - * @param child The DisplayObject instance to identify. - * @returns The index position of the child display object to identify. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 返回 DisplayObject 的 child 实例的索引位置。 - * @param child 要测试的子对象。 - * @returns 要查找的子显示对象的索引位置。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - getChildIndex(child: egret.DisplayObject): number; - /** - * Returns the child display object that exists with the specified name. If more that one child display object has - * the specified name, the method returns the first object in the child list.The getChildAt() method is faster than - * the getChildByName() method. The getChildAt() method accesses a child from a cached array, whereas the getChildByName() - * method has to traverse a linked list to access a child. - * @param name The name of the child to return. - * @returns The child display object with the specified name. - * @see #getChildAt() - * @see egret.DisplayObject#name - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 返回具有指定名称的子显示对象。如果多个子显示对象具有指定名称,则该方法会返回子级列表中的第一个对象。 - * getChildAt() 方法比 getChildByName() 方法快。getChildAt() 方法从缓存数组中访问子项,而 getChildByName() 方法则必须遍历链接的列表来访问子项。 - * @param name 要返回的子项的名称。 - * @returns 具有指定名称的子显示对象。 - * @see #getChildAt() - * @see egret.DisplayObject#name - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - getChildByName(name: string): DisplayObject; - /** - * Removes the specified child DisplayObject instance from the child list of the DisplayObjectContainer instance. - * The parent property of the removed child is set to null , and the object is garbage collected if no other references - * to the child exist. The index positions of any display objects above the child in the DisplayObjectContainer are - * decreased by 1. - * @param child The DisplayObject instance to remove. - * @returns The DisplayObject instance that you pass in the child parameter. - * @see #removeChildAt() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从 DisplayObjectContainer 实例的子列表中删除指定的 child DisplayObject 实例。将已删除子项的 parent 属性设置为 null; - * 如果不存在对该子项的任何其它引用,则将该对象作为垃圾回收。DisplayObjectContainer 中该子项之上的任何显示对象的索引位置都减去 1。 - * @param child 要删除的 DisplayObject 实例。 - * @returns 在 child 参数中传递的 DisplayObject 实例。 - * @see #removeChildAt() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - removeChild(child: DisplayObject): DisplayObject; - /** - * Removes a child DisplayObject from the specified index position in the child list of the DisplayObjectContainer. - * The parent property of the removed child is set to null, and the object is garbage collected if no other references - * to the child exist. The index positions of any display objects above the child in the DisplayObjectContainer are decreased by 1. - * @param index The child index of the DisplayObject to remove. - * @returns The DisplayObject instance that was removed. - * @see #removeChild() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从 DisplayObjectContainer 的子列表中指定的 index 位置删除子 DisplayObject。将已删除子项的 parent 属性设置为 null; - * 如果没有对该子项的任何其他引用,则将该对象作为垃圾回收。DisplayObjectContainer 中该子项之上的任何显示对象的索引位置都减去 1。 - * @param index 要删除的 DisplayObject 的子索引。 - * @returns 已删除的 DisplayObject 实例。 - * @see #removeChild() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - removeChildAt(index: number): DisplayObject; - /** - * @private - */ - $doRemoveChild(index: number, notifyListeners?: boolean): DisplayObject; - /** - * Changes the position of an existing child in the display object container. This affects the layering of child objects. - * @param child The child DisplayObject instance for which you want to change the index number. - * @param index The resulting index number for the child display object. - * @see #addChildAt() - * @see #getChildAt() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 更改现有子项在显示对象容器中的位置。这会影响子对象的分层。 - * @param child 要为其更改索引编号的 DisplayObject 子实例。 - * @param index 生成的 child 显示对象的索引编号。当新的索引编号小于0或大于已有子元件数量时,新加入的DisplayObject对象将会放置于最上层。 - * @see #addChildAt() - * @see #getChildAt() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - setChildIndex(child: DisplayObject, index: number): void; - /** - * @private - */ - private doSetChildIndex(child, index); - /** - * Swaps the z-order (front-to-back order) of the child objects at the two specified index positions in the child - * list. All other child objects in the display object container remain in the same index positions. - * @param index1 The index position of the first child object. - * @param index2 The index position of the second child object. - * @see #swapChildren() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 在子级列表中两个指定的索引位置,交换子对象的 Z 轴顺序(前后顺序)。显示对象容器中所有其他子对象的索引位置保持不变。 - * @param index1 第一个子对象的索引位置。 - * @param index2 第二个子对象的索引位置。 - * @see #swapChildren() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - swapChildrenAt(index1: number, index2: number): void; - /** - * Swaps the z-order (front-to-back order) of the two specified child objects. All other child objects in the - * display object container remain in the same index positions. - * @param child1 The first child object. - * @param child2 The second child object. - * @see #swapChildrenAt() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 交换两个指定子对象的 Z 轴顺序(从前到后顺序)。显示对象容器中所有其他子对象的索引位置保持不变。 - * @param child1 第一个子对象。 - * @param child2 第二个子对象。 - * @see #swapChildrenAt() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - swapChildren(child1: DisplayObject, child2: DisplayObject): void; - /** - * @private - */ - private doSwapChildrenAt(index1, index2); - /** - * Removes all child DisplayObject instances from the child list of the DisplayObjectContainer instance. The parent - * property of the removed children is set to null , and the objects are garbage collected if no other references to the children exist. - * @see #removeChild() - * @see #removeChildAt() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从 DisplayObjectContainer 实例的子级列表中删除所有 child DisplayObject 实例。 - * @see #removeChild() - * @see #removeChildAt() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - removeChildren(): void; - /** - * @private - * 一个子项被添加到容器内,此方法不仅在操作addChild()时会被回调,在操作setChildIndex()或swapChildren时也会回调。 - * 当子项索引发生改变时,会先触发$childRemoved()方法,然后触发$childAdded()方法。 - */ - $childAdded(child: DisplayObject, index: number): void; - /** - * @private - * 一个子项从容器内移除,此方法不仅在操作removeChild()时会被回调,在操作setChildIndex()或swapChildren时也会回调。 - * 当子项索引发生改变时,会先触发$childRemoved()方法,然后触发$childAdded()方法。 - */ - $childRemoved(child: DisplayObject, index: number): void; - /** - * @private - */ - $onAddToStage(stage: Stage, nestLevel: number): void; - /** - * @private - * - */ - $onRemoveFromStage(): void; - /** - * @private - */ - $measureChildBounds(bounds: Rectangle): void; - $touchChildren: boolean; - /** - * Determines whether or not the children of the object are touch, or user input device, enabled. If an object is - * enabled, a user can interact with it by using a touch or user input device. - * @default true - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 确定对象的子级是否支持触摸或用户输入设备。如果对象支持触摸或用户输入设备,用户可以通过使用触摸或用户输入设备与之交互。 - * @default true - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - touchChildren: boolean; - /** - * @private - * - * @returns - */ - $getTouchChildren(): boolean; - /** - * @private - */ - $setTouchChildren(value: boolean): boolean; - /** - * @private - */ - $hitTest(stageX: number, stageY: number): DisplayObject; - private _sortChildrenFunc(a, b); - sortChildren(): void; - } -} -declare namespace egret { - /** - * SpriteSheet is a mosaic of multiple sub-bitmaps, comprising a plurality of Texture objects. - * Each Texture object shares the set bitmap of SpriteSheet, but it points to its different areas. - * On WebGL / OpenGL, this operation can significantly improve performance. - * At the same time, SpriteSheet can carry out material integration easily to reduce the number of HTTP requests - * For specification of the SpriteSheet format, see the document https://github.com/egret-labs/egret-core/wiki/Egret-SpriteSheet-Specification - * @see http://edn.egret.com/cn/docs/page/135 The use of texture packs - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/SpriteSheet.ts - * @language en_US - */ - /** - * SpriteSheet 是一张由多个子位图拼接而成的集合位图,它包含多个 Texture 对象。 - * 每一个 Texture 都共享 SpriteSheet 的集合位图,但是指向它的不同的区域。 - * 在WebGL / OpenGL上,这种做法可以显著提升性能 - * 同时,SpriteSheet可以很方便的进行素材整合,降低HTTP请求数量 - * SpriteSheet 格式的具体规范可以参见此文档 https://github.com/egret-labs/egret-core/wiki/Egret-SpriteSheet-Specification - * @see http://edn.egret.com/cn/docs/page/135 纹理集的使用 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/SpriteSheet.ts - * @language zh_CN - */ - class SpriteSheet extends HashObject { - /** - * Create an egret.SpriteSheet object - * @param texture {Texture} Texture - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 egret.SpriteSheet 对象 - * @param texture {Texture} 纹理 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(texture: Texture); - /** - * @private - * 表示这个SpriteSheet的位图区域在bitmapData上的起始位置x。 - */ - private _bitmapX; - /** - * @private - * 表示这个SpriteSheet的位图区域在bitmapData上的起始位置y。 - */ - private _bitmapY; - /** - * @private - * 共享的位图数据 - */ - $texture: Texture; - /** - * @private - * 纹理缓存字典 - */ - _textureMap: MapLike; - /** - * Obtain a cached Texture object according to the specified texture name - * @param name {string} Cache the name of this Texture object - * @returns {egret.Texture} The Texture object - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 根据指定纹理名称获取一个缓存的 Texture 对象 - * @param name {string} 缓存这个 Texture 对象所使用的名称 - * @returns {egret.Texture} Texture 对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - getTexture(name: string): Texture; - /** - * Create a new Texture object for the specified area on SpriteSheet and cache it - * @param name {string} Cache the name of this Texture object. If the name already exists, the previous Texture object will be overwrited. - * @param bitmapX {number} Starting coordinate x of texture area on bitmapData - * @param bitmapY {number} Starting coordinate y of texture area on bitmapData - * @param bitmapWidth {number} Width of texture area on bitmapData - * @param bitmapHeight {number} Height of texture area on bitmapData - * @param offsetX {number} Starting point x for a non-transparent area of the original bitmap - * @param offsetY {number} Starting point y for a non-transparent area of the original bitmap - * @param textureWidth {number} Width of the original bitmap. If it is not passed, use the bitmapWidth value. - * @param textureHeight {number} Height of the original bitmap. If it is not passed, use the bitmapHeight value. - * @returns {egret.Texture} The created Texture object - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 为 SpriteSheet 上的指定区域创建一个新的 Texture 对象并缓存它 - * @param name {string} 缓存这个 Texture 对象所使用的名称,如果名称已存在,将会覆盖之前的 Texture 对象 - * @param bitmapX {number} 纹理区域在 bitmapData 上的起始坐标x - * @param bitmapY {number} 纹理区域在 bitmapData 上的起始坐标y - * @param bitmapWidth {number} 纹理区域在 bitmapData 上的宽度 - * @param bitmapHeight {number} 纹理区域在 bitmapData 上的高度 - * @param offsetX {number} 原始位图的非透明区域 x 起始点 - * @param offsetY {number} 原始位图的非透明区域 y 起始点 - * @param textureWidth {number} 原始位图的高度,若不传入,则使用 bitmapWidth 的值。 - * @param textureHeight {number} 原始位图的宽度,若不传入,则使用 bitmapHeight 的值。 - * @returns {egret.Texture} 创建的 Texture 对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - createTexture(name: string, bitmapX: number, bitmapY: number, bitmapWidth: number, bitmapHeight: number, offsetX?: number, offsetY?: number, textureWidth?: number, textureHeight?: number): Texture; - /** - * dispose texture - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 释放纹理 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - dispose(): void; - } -} -declare namespace egret { - /** - * @private - */ - let $locale_strings: any; - /** - * @private - */ - let $language: string; -} -declare namespace egret.sys { - /** - * @private - * 全局多语言翻译函数 - * @param code 要查询的字符串代码 - * @param args 替换字符串中{0}标志的参数列表 - * @returns 返回拼接后的字符串 - */ - function tr(code: number, ...args: any[]): string; -} -declare namespace egret { - /** - * The Bitmap class represents display objects that represent bitmap images. - * The Bitmap() constructor allows you to create a Bitmap object that contains a reference to a BitmapData object. - * After you create a Bitmap object, use the addChild() or addChildAt() method of the parent DisplayObjectContainer - * instance to place the bitmap on the display list.A Bitmap object can share its texture reference among several - * Bitmap objects, independent of translation or rotation properties. Because you can create multiple Bitmap objects - * that reference the same texture object, multiple display objects can use the same complex texture object - * without incurring the memory overhead of a texture object for each display object instance. - * - * @see egret.Texture - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/Bitmap.ts - * @language en_US - */ - /** - * Bitmap 类表示用于显示位图图片的显示对象。 - * 利用 Bitmap() 构造函数,可以创建包含对 BitmapData 对象引用的 Bitmap 对象。创建了 Bitmap 对象后, - * 使用父级 DisplayObjectContainer 实例的 addChild() 或 addChildAt() 方法可以将位图放在显示列表中。 - * 一个 Bitmap 对象可在若干 Bitmap 对象之中共享其 texture 引用,与缩放或旋转属性无关。 - * 由于能够创建引用相同 texture 对象的多个 Bitmap 对象,因此,多个显示对象可以使用相同的 texture 对象, - * 而不会因为每个显示对象实例使用一个 texture 对象而产生额外内存开销。 - * - * @see egret.Texture - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/Bitmap.ts - * @language zh_CN - */ - class Bitmap extends DisplayObject { - /** - * Initializes a Bitmap object to refer to the specified Texture object. - * @param value The Texture object being referenced. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个引用指定 Texture 实例的 Bitmap 对象 - * @param value 被引用的 Texture 实例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(value?: Texture); - protected $texture: Texture; - $bitmapData: BitmapData; - protected $bitmapX: number; - protected $bitmapY: number; - protected $bitmapWidth: number; - protected $bitmapHeight: number; - protected $offsetX: number; - protected $offsetY: number; - protected $textureWidth: number; - protected $textureHeight: number; - protected $sourceWidth: number; - protected $sourceHeight: number; - protected $smoothing: boolean; - protected $explicitBitmapWidth: number; - protected $explicitBitmapHeight: number; - protected createNativeDisplayObject(): void; - /** - * @private - * 显示对象添加到舞台 - */ - $onAddToStage(stage: Stage, nestLevel: number): void; - /** - * @private - * 显示对象从舞台移除 - */ - $onRemoveFromStage(): void; - /** - * The Texture object being referenced. - * If you pass the constructor of type BitmapData or last set for bitmapData, this value returns null. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 被引用的 Texture 对象。 - * 如果传入构造函数的类型为 BitmapData 或者最后设置的为 bitmapData,则此值返回 null。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - texture: Texture; - /** - * @private - */ - $setTexture(value: Texture): boolean; - $setBitmapData(value: any): void; - /** - * @private - */ - protected setBitmapDataToWasm(data?: Texture): void; - /** - * @private - */ - $refreshImageData(): void; - /** - * @private - */ - private setImageData(bitmapData, bitmapX, bitmapY, bitmapWidth, bitmapHeight, offsetX, offsetY, textureWidth, textureHeight, sourceWidth, sourceHeight); - /** - * @private - */ - $scale9Grid: egret.Rectangle; - /** - * Represent a Rectangle Area that the 9 scale area of Image. - * Notice: This property is valid only when fillMode - * is BitmapFillMode.SCALE. - * - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 矩形区域,它定义素材对象的九个缩放区域。 - * 注意:此属性仅在fillModeBitmapFillMode.SCALE时有效。 - * - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - scale9Grid: egret.Rectangle; - protected $setScale9Grid(value: egret.Rectangle): void; - /** - * @private - */ - $fillMode: string; - /** - * Determines how the bitmap fills in the dimensions. - *

When set to BitmapFillMode.REPEAT, the bitmap - * repeats to fill the region.

- *

When set to BitmapFillMode.SCALE, the bitmap - * stretches to fill the region.

- * - * @default BitmapFillMode.SCALE - * - * @version Egret 2.4 - * @platform Web - * @language en_US - */ - /** - * 确定位图填充尺寸的方式。 - *

设置为 BitmapFillMode.REPEAT时,位图将重复以填充区域。

- *

设置为 BitmapFillMode.SCALE时,位图将拉伸以填充区域。

- * - * @default BitmapFillMode.SCALE - * - * @version Egret 2.4 - * @platform Web - * @language zh_CN - */ - fillMode: string; - $setFillMode(value: string): boolean; - /** - * The default value of whether or not is smoothed when scaled. - * When object such as Bitmap is created,smoothing property will be set to this value. - * @default true。 - * @version Egret 3.0 - * @platform Web - * @language en_US - */ - /** - * 控制在缩放时是否进行平滑处理的默认值。 - * 在 Bitmap 等对象创建时,smoothing 属性会被设置为该值。 - * @default true。 - * @version Egret 3.0 - * @platform Web - * @language zh_CN - */ - static defaultSmoothing: boolean; - /** - * Whether or not the bitmap is smoothed when scaled. - * @version Egret 2.4 - * @platform Web - * @language en_US - */ - /** - * 控制在缩放时是否对位图进行平滑处理。 - * @version Egret 2.4 - * @platform Web - * @language zh_CN - */ - smoothing: boolean; - /** - * @private - * - * @param value - */ - $setWidth(value: number): boolean; - /** - * @private - * - * @param value - */ - $setHeight(value: number): boolean; - /** - * @private - * 获取显示宽度 - */ - $getWidth(): number; - /** - * @private - * 获取显示宽度 - */ - $getHeight(): number; - /** - * @private - */ - $measureContentBounds(bounds: Rectangle): void; - /** - * @private - */ - $updateRenderNode(): void; - private _pixelHitTest; - /** - * Specifies whether this object use precise hit testing by checking the alpha value of each pixel.If pixelHitTest - * is set to true,the transparent area of the bitmap will be touched through.
- * Note:If the image is loaded from cross origin,that we can't access to the pixel data,so it might cause - * the pixelHitTest property invalid. - * @default false - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 是否开启精确像素碰撞。设置为true显示对象本身的透明区域将能够被穿透。
- * 注意:若图片资源是以跨域方式从外部服务器加载的,将无法访问图片的像素数据,而导致此属性失效。 - * @default false - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - pixelHitTest: boolean; - $hitTest(stageX: number, stageY: number): DisplayObject; - } -} -declare namespace egret.sys { - /** - * @private - * 渲染节点类型 - */ - const enum RenderNodeType { - /** - * 位图渲染节点 - */ - BitmapNode = 1, - /** - * 文本渲染节点 - */ - TextNode = 2, - /** - * 矢量渲染节点 - */ - GraphicsNode = 3, - /** - * 组渲染节点 - */ - GroupNode = 4, - /** - * Mesh 节点 - */ - MeshNode = 5, - /** - * 普通位图渲染节点 - */ - NormalBitmapNode = 6, - } - /** - * @private - * 渲染节点基类 - */ - class RenderNode { - /** - * 节点类型.. - */ - type: number; - /** - * 绘制数据 - */ - drawData: any[]; - /** - * 绘制次数 - */ - protected renderCount: number; - /** - * 在显示对象的$updateRenderNode()方法被调用前,自动清空自身的drawData数据。 - */ - cleanBeforeRender(): void; - $getRenderCount(): number; - } -} -declare namespace egret.sys { - /** - * @private - * 路径类型 - */ - const enum PathType { - /** - * 纯色填充路径 - */ - Fill = 1, - /** - * 渐变填充路径 - */ - GradientFill = 2, - /** - * 线条路径 - */ - Stroke = 3, - } - /** - * @private - * 2D路径命令 - */ - const enum PathCommand { - MoveTo = 1, - LineTo = 2, - CurveTo = 3, - CubicCurveTo = 4, - } - /** - * @private - * 2D路径 - */ - class Path2D { - /** - * 路径类型 - */ - type: number; - $commands: number[]; - $data: number | number[][]; - protected commandPosition: number; - protected dataPosition: number; - /** - * 当前移动到的坐标X - * 注意:目前只有drawArc之前会被赋值 - */ - $lastX: number; - /** - * 当前移动到的坐标Y - * 注意:目前只有drawArc之前会被赋值 - */ - $lastY: number; - /** - * 将当前绘图位置移动到 (x, y)。如果缺少任何一个参数,则此方法将失败,并且当前绘图位置不改变。 - * @param x 一个表示相对于父显示对象注册点的水平位置的数字(以像素为单位)。 - * @param y 一个表示相对于父显示对象注册点的垂直位置的数字(以像素为单位)。 - */ - moveTo(x: number, y: number): void; - /** - * 使用当前线条样式绘制一条从当前绘图位置开始到 (x, y) 结束的直线;当前绘图位置随后会设置为 (x, y)。 - * @param x 一个表示相对于父显示对象注册点的水平位置的数字(以像素为单位)。 - * @param y 一个表示相对于父显示对象注册点的垂直位置的数字(以像素为单位)。 - */ - lineTo(x: number, y: number): void; - /** - * 使用当前线条样式和由 (controlX, controlY) 指定的控制点绘制一条从当前绘图位置开始到 (anchorX, anchorY) 结束的二次贝塞尔曲线。当前绘图位置随后设置为 (anchorX, anchorY)。 - * 如果在调用 moveTo() 方法之前调用了 curveTo() 方法,则当前绘图位置的默认值为 (0, 0)。如果缺少任何一个参数,则此方法将失败,并且当前绘图位置不改变。 - * 绘制的曲线是二次贝塞尔曲线。二次贝塞尔曲线包含两个锚点和一个控制点。该曲线内插这两个锚点,并向控制点弯曲。 - * @param controlX 一个数字,指定控制点相对于父显示对象注册点的水平位置。 - * @param controlY 一个数字,指定控制点相对于父显示对象注册点的垂直位置。 - * @param anchorX 一个数字,指定下一个锚点相对于父显示对象注册点的水平位置。 - * @param anchorY 一个数字,指定下一个锚点相对于父显示对象注册点的垂直位置。 - */ - curveTo(controlX: number, controlY: number, anchorX: number, anchorY: number): void; - /** - * 从当前绘图位置到指定的锚点绘制一条三次贝塞尔曲线。三次贝塞尔曲线由两个锚点和两个控制点组成。该曲线内插这两个锚点,并向两个控制点弯曲。 - * @param controlX1 指定首个控制点相对于父显示对象的注册点的水平位置。 - * @param controlY1 指定首个控制点相对于父显示对象的注册点的垂直位置。 - * @param controlX2 指定第二个控制点相对于父显示对象的注册点的水平位置。 - * @param controlY2 指定第二个控制点相对于父显示对象的注册点的垂直位置。 - * @param anchorX 指定锚点相对于父显示对象的注册点的水平位置。 - * @param anchorY 指定锚点相对于父显示对象的注册点的垂直位置。 - */ - cubicCurveTo(controlX1: number, controlY1: number, controlX2: number, controlY2: number, anchorX: number, anchorY: number): void; - /** - * 绘制一个矩形 - * @param x 圆心相对于父显示对象注册点的 x 位置(以像素为单位)。 - * @param y 相对于父显示对象注册点的圆心的 y 位置(以像素为单位)。 - * @param width 矩形的宽度(以像素为单位)。 - * @param height 矩形的高度(以像素为单位)。 - */ - drawRect(x: number, y: number, width: number, height: number): void; - /** - * 绘制一个圆角矩形。 - * @param x 圆心相对于父显示对象注册点的 x 位置(以像素为单位)。 - * @param y 相对于父显示对象注册点的圆心的 y 位置(以像素为单位)。 - * @param width 矩形的宽度(以像素为单位)。 - * @param height 矩形的高度(以像素为单位)。 - * @param ellipseWidth 用于绘制圆角的椭圆的宽度(以像素为单位)。 - * @param ellipseHeight 用于绘制圆角的椭圆的高度(以像素为单位)。 (可选)如果未指定值,则默认值与为 ellipseWidth 参数提供的值相匹配。 - */ - drawRoundRect(x: number, y: number, width: number, height: number, ellipseWidth: number, ellipseHeight?: number): void; - /** - * 绘制一个圆。 - * @param x 圆心相对于父显示对象注册点的 x 位置(以像素为单位)。 - * @param y 相对于父显示对象注册点的圆心的 y 位置(以像素为单位)。 - * @param radius 圆的半径(以像素为单位)。 - */ - drawCircle(x: number, y: number, radius: number): void; - /** - * 绘制一个椭圆。 - * @param x 一个表示相对于父显示对象注册点的水平位置的数字(以像素为单位)。 - * @param y 一个表示相对于父显示对象注册点的垂直位置的数字(以像素为单位)。 - * @param width 矩形的宽度(以像素为单位)。 - * @param height 矩形的高度(以像素为单位)。 - */ - drawEllipse(x: number, y: number, width: number, height: number): void; - /** - * 绘制一段圆弧路径。圆弧路径的圆心在 (x, y) 位置,半径为 r ,根据anticlockwise (默认为顺时针)指定的方向从 startAngle 开始绘制,到 endAngle 结束。 - * @param x 圆弧中心(圆心)的 x 轴坐标。 - * @param y 圆弧中心(圆心)的 y 轴坐标。 - * @param radius 圆弧的半径。 - * @param startAngle 圆弧的起始点, x轴方向开始计算,单位以弧度表示。 - * 注意,必须在0~2π之间。 - * @param endAngle 圆弧的终点, 单位以弧度表示。 - * 注意,必须在0~2π之间。 - * @param anticlockwise 如果为 true,逆时针绘制圆弧,反之,顺时针绘制。 - */ - drawArc(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise: boolean): void; - /** - * 绘制一段圆弧路径 - * @param x 圆弧中心(圆心)的 x 轴坐标。 - * @param y 圆弧中心(圆心)的 y 轴坐标。 - * @param radiusX 圆弧的半径 x。 - * @param radiusY 圆弧的半径 y。 - * @param startAngle 圆弧的起始点, x轴方向开始计算,单位以弧度表示。 - * 注意:必须为正数。 - * @param endAngle 圆弧的终点, 单位以弧度表示。 - * 注意:与startAngle差值必须在0~2π之间。 - * @param anticlockwise 如果为 true,逆时针绘制圆弧,反之,顺时针绘制。 - * 注意:如果为true,endAngle必须小于startAngle,反之必须大于。 - */ - private arcToBezier(x, y, radiusX, radiusY, startAngle, endAngle, anticlockwise?); - } -} -declare namespace egret { - /** - * Writes an error message to the console if the assertion is false. If the assertion is true, nothing will happen. - * @param assertion Any boolean expression. If the assertion is false, the message will get written to the console. - * @param message the message written to the console - * @param optionalParams the extra messages written to the console - * @language en_US - */ - /** - * 判断参数assertion是否为true,若为false则抛出异常并且在console输出相应信息,反之什么也不做。 - * @param assertion 一个 boolean 表达式,若结果为false,则抛出错误并输出信息。 - * @param message 要输出到控制台的信息 - * @param optionalParams 要输出到控制台的额外可选信息 - * @language zh_CN - */ - function assert(assertion?: boolean, message?: string, ...optionalParams: any[]): void; - /** - * Writes a warning message to the console. - * @param message the message written to the console - * @param optionalParams the extra messages written to the console - * @language en_US - */ - /** - * 输出一个警告信息到控制台。 - * @param message 要输出到控制台的信息 - * @param optionalParams 要输出到控制台的额外信息 - * @language zh_CN - */ - function warn(message?: any, ...optionalParams: any[]): void; - /** - * Writes an error message to the console. - * @param message the message written to the console - * @param optionalParams the extra messages written to the console - * @language en_US - */ - /** - * 输出一个错误信息到控制台。 - * @param message 要输出到控制台的信息 - * @param optionalParams 要输出到控制台的额外信息 - * @language zh_CN - */ - function error(message?: any, ...optionalParams: any[]): void; - /** - * Writes an message to the console. - * @param message the message written to the console - * @param optionalParams the extra messages written to the console - * @language en_US - */ - /** - * 输出一个日志信息到控制台。 - * @param message 要输出到控制台的信息 - * @param optionalParams 要输出到控制台的额外信息 - * @language zh_CN - */ - function log(message?: any, ...optionalParams: any[]): void; -} -/** - * @private - */ -declare namespace egret { - /** - * @private - */ - let fontMapping: {}; -} -/** - * @private - */ -declare namespace egret_native { - function readUpdateFileSync(filePath: any): any; - function readResourceFileSync(filePath: any): any; - function sendInfoToPlugin(info: string): void; - function receivedPluginInfo(info: string): void; - function nrInit(): void; - function nrDownloadBuffers(callback: (displayCmdBuffer: Float32Array) => void): void; - function nrSetRenderMode(mode: number): void; - function nrRenderDisplayObject(id: number, scale: number, useClip: boolean, clipX: number, clipY: number, clipW: number, clipH: number): void; - function nrRenderDisplayObject2(id: number, offsetX: number, offsetY: number, forHitTest: boolean): void; - function nrLocalToGlobal(id: number, localX: number, localY: number): string; - function nrGlobalToLocal(id: number, globalX: number, globalY: number): string; - function nrGetTextFieldWidth(id: number): number; - function nrGetTextFieldHeight(id: number): number; - function nrGetTextWidth(id: number): number; - function nrGetTextHeight(id: number): number; - function nrResize(width: number, height: number): void; - function nrSetCanvasScaleFactor(factor: number, scalex: number, scaley: number): void; - function nrUpdate(): void; - function nrRender(): void; - function nrSendTextFieldData(textFieldId: number, strData: string): void; - function nrUpdateCallbackList(dt: number): void; - function nrActiveBuffer(id: number, width: number, height: number): void; - function nrGetPixels(x: number, y: number, width: number, height: number, pixels: Uint8Array): void; - function nrGetCustomImageId(type: number): number; - function nrSetCustomImageData(customImageId: number, pvrtcData: any, width: any, height: any, mipmapsCount: any, format: any): void; - class NrNode { - constructor(id: number, type: number); - } -} -/** - * @private - */ -declare namespace egret_native { - let rootWebGLBuffer: egret.sys.RenderBuffer; - let forHitTest: boolean; - let addModuleCallback: (callback: Function, thisObj: any) => void; - let initNativeRender: () => void; - let updateNativeRender: () => void; - let activateBuffer: (buffer: egret.sys.RenderBuffer) => void; - let getJsCustomFilterVertexSrc: (key: any) => any; - let getJsCustomFilterFragSrc: (key: any) => any; - let getJsCustomFilterUniforms: (key: any) => any; - let nrABIVersion: number; - let nrMinEgretVersion: string; -} -declare namespace egret_native { - /** - * @private - */ - class NativeRenderSurface { - width: number; - height: number; - constructor(currRenderBuffer: any, w?: number, h?: number, root?: boolean); - resize(w: number, h: number): void; - } - /** - * @private - */ - class NativeBitmapData { - $init(): any; - $id: any; - } - /** - * @private - */ - class NativeDisplayObject { - id: number; - constructor(type: number); - setChildrenSortMode(mode: string): void; - addChildAt(childId: number, index: number): void; - removeChild(childId: number): void; - swapChild(index1: number, index2: number): void; - setX(value: number): void; - setY(value: number): void; - setRotation(value: number): void; - setScaleX(value: number): void; - setScaleY(value: number): void; - setSkewX(value: number): void; - setSkewY(value: number): void; - setAlpha(value: number): void; - setAnchorOffsetX(value: number): void; - setAnchorOffsetY(value: number): void; - setVisible(value: boolean): void; - setBlendMode(value: number): void; - setMaskRect(x: number, y: number, w: number, h: number): void; - setScrollRect(x: number, y: number, w: number, h: number): void; - setFilters(filters: Array): void; - static createFilter(filter: egret.Filter): void; - static setFilterPadding(filterId: number, paddingTop: number, paddingBottom: number, paddingLeft: number, paddingRight: number): void; - setMask(value: number): void; - static setSourceToNativeBitmapData(nativeBitmapData: egret_native.NativeBitmapData, source: any): any; - setTexture(texture: egret.Texture): void; - setBitmapDataToMesh(texture: egret.Texture): void; - setBitmapDataToParticle(texture: egret.Texture): void; - setWidth(value: number): void; - setHeight(value: number): void; - setCacheAsBitmap(value: boolean): void; - setBitmapFillMode(fillMode: string): void; - setScale9Grid(x: number, y: number, w: number, h: number): void; - setMatrix(a: number, b: number, c: number, d: number, tx: number, ty: number): void; - setIsTyping(value: boolean): void; - setDataToBitmapNode(id: number, texture: egret.Texture, arr: number[]): void; - setDataToMesh(vertexArr: number[], indiceArr: number[], uvArr: number[]): void; - static setDataToFilter(currFilter: egret.Filter): void; - static disposeNativeBitmapData(nativeBitmapData: egret_native.NativeBitmapData): void; - static disposeTextData(node: egret.TextField): void; - static disposeGraphicData(graphic: egret.Graphics): void; - setFontSize(value: number): void; - setLineSpacing(value: number): void; - setTextColor(value: number): void; - setTextFieldWidth(value: number): void; - setTextFieldHeight(value: number): void; - setFontFamily(value: string): void; - setTextFlow(textArr: Array): void; - setTextAlign(value: string): void; - setVerticalAlign(value: string): void; - setText(value: string): void; - setBold(value: boolean): void; - setItalic(value: boolean): void; - setWordWrap(value: boolean): void; - setMaxChars(value: number): void; - setType(value: string): void; - setStrokeColor(value: number): void; - setStroke(value: number): void; - setScrollV(value: number): void; - setMultiline(value: boolean): void; - setBorder(value: boolean): void; - setBorderColor(value: number): void; - setBackground(value: boolean): void; - setBackgroundColor(value: number): void; - setInputType(value: string): void; - setBeginFill(color: number, alpha?: number): void; - setBeginGradientFill(type: string, colors: number[], alphas: number[], ratios: number[], matrix: egret.Matrix): void; - setEndFill(): void; - setLineStyle(thickness?: number, color?: number, alpha?: number, pixelHinting?: boolean, scaleMode?: string, caps?: string, joints?: string, miterLimit?: number, lineDash?: number[]): void; - setDrawRect(x: number, y: number, width: number, height: number): void; - setDrawRoundRect(x: number, y: number, width: number, height: number, ellipseWidth: number, ellipseHeight?: number): void; - setDrawCircle(x: number, y: number, radius: number): void; - setDrawEllipse(x: number, y: number, width: number, height: number): void; - setMoveTo(x: number, y: number): void; - setLineTo(x: number, y: number): void; - setCurveTo(controlX: number, controlY: number, anchorX: number, anchorY: number): void; - setCubicCurveTo(controlX1: number, controlY1: number, controlX2: number, controlY2: number, anchorX: number, anchorY: number): void; - setDrawArc(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: boolean): void; - setGraphicsClear(): void; - } -} -/** - * @private - */ -declare namespace egret_native { - /** - * @private - */ - const enum NativeObjectType { - /** - * 容器 - */ - CONTAINER = 0, - /** - * 位图 - */ - BITMAP = 1, - /** - * 位图数据 - */ - BITMAP_DATA = 2, - /** - * 滤镜 - */ - FILTER = 6, - /** - * 文本 - */ - TEXT = 7, - /** - * 矢量绘图 - */ - GRAPHICS = 8, - /** - * 含一个适量绘图的容器 - */ - SPRITE = 9, - /** - * 粒子系统 - */ - PARTICLE_SYSTEM = 10, - /** - * 位图文本 - */ - BITMAP_TEXT = 11, - /** - * 网格 - */ - MESH = 12, - /** - * 舞台(根容器) - */ - STAGE = 13, - } -} -declare namespace egret { - /** - * @private - */ - interface MapLike { - [key: string]: T; - [key: number]: T; - } - /** - * @private - */ - function createMap(): MapLike; -} -declare namespace egret { - /** - * @class egret.GlowFilter - * @classdesc - * 使用 GlowFilter 类可以对显示对象应用发光效果。在投影滤镜的 distance 和 angle 属性设置为 0 时,发光滤镜与投影滤镜极为相似。 - * @extends egret.Filter - * @version Egret 3.1.4 - * @platform Web,Native - */ - class GlowFilter extends Filter { - /** - * @private - */ - $red: number; - /** - * @private - */ - $green: number; - /** - * @private - */ - $blue: number; - /** - * Initializes a new GlowFilter instance. - * @method egret.GlowFilter#constructor - * @param color {number} The color of the glow. Valid values are in the hexadecimal format 0xRRGGBB. The default value is 0xFF0000. - * @param alpha {number} The alpha transparency value for the color. Valid values are 0 to 1. For example, .25 sets a transparency value of 25%. The default value is 1. - * @param blurX {number} The amount of horizontal blur. Valid values are 0 to 255 (floating point). - * @param blurY {number} The amount of vertical blur. Valid values are 0 to 255 (floating point). - * @param strength {number} The strength of the imprint or spread. The higher the value, the more color is imprinted and the stronger the contrast between the glow and the background. Valid values are 0 to 255. - * @param quality {number} The number of times to apply the filter. - * @param inner {boolean} Specifies whether the glow is an inner glow. The value true indicates an inner glow. The default is false, an outer glow (a glow around the outer edges of the object). - * @param knockout {number} Specifies whether the object has a knockout effect. A value of true makes the object's fill transparent and reveals the background color of the document. The default value is false (no knockout effect). - * @version Egret 3.1.4 - * @platform Web - * @language en_US - */ - /** - * 初始化 GlowFilter 对象 - * @method egret.GlowFilter#constructor - * @param color {number} 光晕颜色,采用十六进制格式 0xRRGGBB。默认值为 0xFF0000。 - * @param alpha {number} 颜色的 Alpha 透明度值。有效值为 0 到 1。例如,0.25 设置透明度值为 25%。 - * @param blurX {number} 水平模糊量。有效值为 0 到 255(浮点)。 - * @param blurY {number} 垂直模糊量。有效值为 0 到 255(浮点)。 - * @param strength {number} 印记或跨页的强度。该值越高,压印的颜色越深,而且发光与背景之间的对比度也越强。有效值为 0 到 255。 - * @param quality {number} 应用滤镜的次数。暂未实现。 - * @param inner {boolean} 指定发光是否为内侧发光。值 true 指定发光是内侧发光。值 false 指定发光是外侧发光(对象外缘周围的发光)。 - * @param knockout {number} 指定对象是否具有挖空效果。值为 true 将使对象的填充变为透明,并显示文档的背景颜色。 - * @version Egret 3.1.4 - * @platform Web - * @language zh_CN - */ - constructor(color?: number, alpha?: number, blurX?: number, blurY?: number, strength?: number, quality?: number, inner?: boolean, knockout?: boolean); - /** - * @private - */ - $color: number; - /** - * The color of the glow. - * @version Egret 3.1.4 - * @platform Web - * @language en_US - */ - /** - * 光晕颜色。 - * @version Egret 3.1.4 - * @platform Web - * @language zh_CN - */ - color: number; - /** - * @private - */ - $alpha: number; - /** - * The alpha transparency value for the color. - * @version Egret 3.1.4 - * @platform Web - * @language en_US - */ - /** - * 颜色的 Alpha 透明度值。 - * @version Egret 3.1.4 - * @platform Web - * @language zh_CN - */ - alpha: number; - /** - * @private - */ - $blurX: number; - /** - * The amount of horizontal blur. - * @version Egret 3.1.4 - * @platform Web - * @language en_US - */ - /** - * 水平模糊量。 - * @version Egret 3.1.4 - * @platform Web - * @language zh_CN - */ - blurX: number; - /** - * @private - */ - $blurY: number; - /** - * The amount of vertical blur. - * @version Egret 3.1.4 - * @platform Web - * @language en_US - */ - /** - * 垂直模糊量。 - * @version Egret 3.1.4 - * @platform Web - * @language zh_CN - */ - blurY: number; - /** - * @private - */ - $strength: number; - /** - * The strength of the imprint or spread. - * @version Egret 3.1.4 - * @platform Web - * @language en_US - */ - /** - * 印记或跨页的强度。 - * @version Egret 3.1.4 - * @platform Web - * @language zh_CN - */ - strength: number; - /** - * @private - */ - $quality: number; - /** - * The number of times to apply the filter. - * @version Egret 3.1.4 - * @platform Web - * @language en_US - */ - /** - * 应用滤镜的次数。 - * @version Egret 3.1.4 - * @platform Web - * @language zh_CN - */ - quality: number; - /** - * @private - */ - $inner: boolean; - /** - * Specifies whether the glow is an inner glow. - * @version Egret 3.1.4 - * @platform Web - * @language en_US - */ - /** - * 指定发光是否为内侧发光。 - * @version Egret 3.1.4 - * @platform Web - * @language zh_CN - */ - inner: boolean; - /** - * @private - */ - $knockout: boolean; - /** - * Specifies whether the object has a knockout effect. - * @version Egret 3.1.4 - * @platform Web - * @language en_US - */ - /** - * 指定对象是否具有挖空效果。 - * @version Egret 3.1.4 - * @platform Web - * @language zh_CN - */ - knockout: boolean; - /** - * @private - */ - $toJson(): string; - protected updatePadding(): void; - } -} -declare namespace egret { - /** - * The Stage class represents the main drawing area.The Stage object is not globally accessible. You need to access - * it through the stage property of a DisplayObject instance.
- * The Stage class has several ancestor classes — Sprite, DisplayObject, and EventDispatcher — from which it inherits - * properties and methods. Many of these properties and methods are inapplicable to Stage objects. - * @event egret.Event.RESIZE Dispatched when the stageWidth or stageHeight property of the Stage object is changed. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/Stage.ts - * @language en_US - */ - /** - * Stage 类代表主绘图区。 - * 可以利用 DisplayObject 实例的 stage 属性进行访问。
- * Stage 类具有多个祖代类: Sprite、DisplayObject 和 EventDispatcher,属性和方法便是从这些类继承而来的。 - * 从这些继承的许多属性和方法不适用于 Stage 对象。 - * @event egret.Event.RESIZE 当stageWidth或stageHeight属性发生改变时调度 - * @event egret.Event.DEACTIVATE 当stage失去焦点后调度 - * @event egret.Event.ACTIVATE 当stage获得焦点后调度 - * - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/Stage.ts - * @language zh_CN - */ - class Stage extends DisplayObjectContainer { - /** - * @private - * Stage不许允许自行实例化 - * @version Egret 2.4 - * @platform Web,Native - */ - constructor(); - protected createNativeDisplayObject(): void; - /** - * Gets and sets the frame rate of the stage. The frame rate is defined as frames per second. Valid range for the - * frame rate is from 0.01 to 1000 frames per second.
- * Note: setting the frameRate property of one Stage object changes the frame rate for all Stage objects - * @default 30 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 获取并设置舞台的帧速率。帧速率是指每秒显示的帧数。帧速率的有效范围为每秒 0.01 到 60 个帧。
- * 注意: 修改任何一个Stage的frameRate属性都会同步修改其他Stage的帧率。 - * @default 30 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - frameRate: number; - /** - * @private - */ - $stageWidth: number; - /** - * Indicates the width of the stage, in pixels. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 舞台的当前宽度(以像素为单位)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly stageWidth: number; - /** - * @private - */ - $stageHeight: number; - /** - * Indicates the height of the stage, in pixels. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 舞台的当前高度(以像素为单位)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly stageHeight: number; - /** - * After you call the invalidate() method, when the display list is next rendered, the Egret runtime sends a render - * event to each display object that has registered to listen for the render event. You must call the invalidate() - * method each time you want the Egret runtime to send render events. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 调用 invalidate() 方法后,在显示列表下次呈现时,Egret 会向每个已注册侦听 Event.RENDER 事件的显示对象发送一个 Event.RENDER 事件。 - * 每次您希望 Egret 发送 Event.RENDER 事件时,都必须调用 invalidate() 方法。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - invalidate(): void; - /** - * @deprecated - */ - registerImplementation(interfaceName: string, instance: any): void; - /** - * @deprecated - */ - getImplementation(interfaceName: string): any; - /** - * @private - * 设备屏幕引用 - */ - $screen: egret.sys.Screen; - $scaleMode: string; - /** - * A StageScaleMode class that specifies which scale mode to use. The following are valid values:
- *
    - *
  • StageScaleMode.EXACT_FIT -- The entire application be visible in the specified area without trying to preserve the original aspect ratio. Distortion can occur, the application may be stretched or compressed.
  • - *
  • StageScaleMode.SHOW_ALL -- The entire application is visible in the specified area without distortion while maintaining the application of the original aspect ratio. Applications may display border.
  • - *
  • StageScaleMode.NO_SCALE -- The size of the entire application is fixed, so that even if the size of the player window changes, it remains unchanged. If the player window is smaller than the content, it may do some trimming.
  • - *
  • StageScaleMode.NO_BORDER -- Keep the original aspect ratio scaling application content, after scaling a narrow direction of application content to fill the viewport players on both sides in the other direction may exceed the viewport and the player is cut.
  • - *
  • StageScaleMode.FIXED_WIDTH -- Keep the original aspect ratio scaling application content, after scaling application content in the horizontal and vertical directions to fill the viewport player, but only to keep the contents of the original application constant width, height may change.
  • - *
  • StageScaleMode.FIXED_HEIGHT -- Keep the original aspect ratio scaling application content, after scaling application content in the horizontal and vertical directions to fill the viewport player, but only to keep the contents of the original application constant height, width may change.
  • - *
- * @default egret.StageScaleMode.SHOW_ALL - * @language en_US - */ - /** - * 一个 StageScaleMode 类中指定要使用哪种缩放模式的值。以下是有效值:
- *
    - *
  • StageScaleMode.EXACT_FIT -- 整个应用程序在指定区域中可见,但不尝试保持原始高宽比。可能会发生扭曲,应用程序可能会拉伸或压缩显示。
  • - *
  • StageScaleMode.SHOW_ALL -- 整个应用程序在指定区域中可见,且不发生扭曲,同时保持应用程序的原始高宽比。应用程序的可能会显示边框。
  • - *
  • StageScaleMode.NO_SCALE -- 整个应用程序的大小固定,因此,即使播放器窗口的大小更改,它也会保持不变。如果播放器窗口比内容小,则可能进行一些裁切。
  • - *
  • StageScaleMode.NO_BORDER -- 保持原始宽高比缩放应用程序内容,缩放后应用程序内容的较窄方向填满播放器视口,另一个方向的两侧可能会超出播放器视口而被裁切。
  • - *
  • StageScaleMode.FIXED_WIDTH -- 保持原始宽高比缩放应用程序内容,缩放后应用程序内容在水平和垂直方向都填满播放器视口,但只保持应用程序内容的原始宽度不变,高度可能会改变。
  • - *
  • StageScaleMode.FIXED_HEIGHT -- 保持原始宽高比缩放应用程序内容,缩放后应用程序内容在水平和垂直方向都填满播放器视口,但只保持应用程序内容的原始高度不变,宽度可能会改变。
  • - *
- * @default egret.StageScaleMode.SHOW_ALL - * @language zh_CN - */ - scaleMode: string; - $orientation: string; - /** - * Horizontal and vertical screen display screen, can only be set under the current Native in the configuration file. A egret.OrientationMode class that specifies which display mode to use. The following are valid values:
- *
    - *
  • egret.OrientationMode.AUTO -- Always follow the direction of application display screen, always guaranteed by the look down.
  • - *
  • egret.OrientationMode.PORTRAIT -- Applications remain portrait mode, namely horizontal screen look, the screen from left to right.
  • - *
  • egret.OrientationMode.LANDSCAPE -- Applications remain horizontal screen mode, namely vertical screen, the screen from right to left.
  • - *
  • egret.OrientationMode.LANDSCAPE_FLIPPED -- Applications remain horizontal screen mode, namely vertical screen, the screen from left to right.
  • - *
- * @platform Web - * @version 2.4 - * @language en_US - */ - /** - * 屏幕横竖屏显示方式,目前 Native 下只能在配置文件里设置。一个 egret.OrientationMode 类中指定要使用哪种显示方式。以下是有效值:
- *
    - *
  • egret.OrientationMode.AUTO -- 应用始终跟随屏幕的方向显示,始终保证由上往下看。
  • - *
  • egret.OrientationMode.PORTRAIT -- 应用始终保持竖屏模式,即横屏看时,屏幕由左往右看。
  • - *
  • egret.OrientationMode.LANDSCAPE -- 应用始终保持横屏模式,即竖屏看时,屏幕显示由右往左。
  • - *
  • egret.OrientationMode.LANDSCAPE_FLIPPED -- 应用始终保持横屏模式,即竖屏看时,屏幕显示由左往右。
  • - *
- * @platform Web - * @version 2.4 - * @language zh_CN - */ - orientation: string; - /** - * Draw texture zoom ratio - * @default 1 - * @language en_US - */ - /** - * 绘制纹理的缩放比率,默认值为1 - * @default 1 - * @language zh_CN - */ - textureScaleFactor: number; - $maxTouches: number; - /** - * Set the number of screens can simultaneously touch. Above this amount will not be triggered in response. - * @default 99 - * @language en_US - */ - /** - * 设置屏幕同时可以触摸的数量。高于这个数量将不会被触发响应。 - * @default 99 - * @language zh_CN - */ - maxTouches: number; - /** - * Set resolution size - * @param width width - * @param height height - * @version Egret 2.5.5 - * @platform Web,Native - * @language en_US - */ - /** - * 设置分辨率尺寸 - * @param width 宽度 - * @param height 高度 - * @version Egret 2.5.5 - * @platform Web,Native - * @language zh_CN - */ - setContentSize(width: number, height: number): void; - } -} -declare namespace egret { - /** - * A class that provides constant values for visual blend mode effects. These constants are used in the blendMode - * property of the DisplayObject class. - * @see egret.DisplayObject#blendMode - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/BlendMode.ts - * @see http://edn.egret.com/cn/docs/page/108 显示容器的概念与实现 - * @language en_US - */ - /** - * 提供混合模式可视效果的常量值的类,通常用于 DisplayObject 的 blendMode 属性上。 - * @see egret.DisplayObject#blendMode - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/BlendMode.ts - * @see http://edn.egret.com/cn/docs/page/108 显示容器的概念与实现 - * @language zh_CN - */ - class BlendMode { - /** - * The display object appears in front of the background. Pixel values of the display object override the pixel - * values of the background. Where the display object is transparent, the background is visible. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 该显示对象出现在背景前面。显示对象的像素值会覆盖背景的像素值。在显示对象为透明的区域,背景是可见的。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static NORMAL: string; - /** - * Adds the values of the constituent colors of the display object to the colors of its background, applying a - * ceiling of 0xFF. This setting is commonly used for animating a lightening dissolve between two objects.
- * For example, if the display object has a pixel with an RGB value of 0xAAA633, and the background pixel has an - * RGB value of 0xDD2200, the resulting RGB value for the displayed pixel is 0xFFC833 (because 0xAA + 0xDD > 0xFF, - * 0xA6 + 0x22 = 0xC8, and 0x33 + 0x00 = 0x33). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将显示对象的原色值添加到它的背景颜色中,上限值为 0xFF。此设置通常用于使两个对象间的加亮溶解产生动画效果。
- * 例如,如果显示对象的某个像素的 RGB 值为 0xAAA633,背景像素的 RGB 值为 0xDD2200,则显示像素的结果 RGB 值为 0xFFC833 - * (因为 0xAA + 0xDD > 0xFF,0xA6 + 0x22 = 0xC8,且 0x33 + 0x00 = 0x33)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static ADD: string; - /** - * Erases the background based on the alpha value of the display object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 根据显示对象的 Alpha 值擦除背景。Alpha 值不为0的区域将被擦除。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static ERASE: string; - } -} -declare namespace egret.sys { - /** - * @private - * 转换 blendMode 字符串为数字。 - */ - function blendModeToNumber(blendMode: string): number; - /** - * @private - * 转换数字为 blendMode 字符串。 - */ - function numberToBlendMode(blendMode: number): string; -} -declare namespace egret { - /** - * The ChildrenSortMode class defines a pattern enumeration for children sort mode of egret.DisplayObjectContainer. - * @version Egret 5.2.19 - * @platform Native - * @language en_US - */ - /** - * BitmapFillMode 类定义egret.DisplayObjectContainer的子项目排序方式。 - * @version Egret 5.2.19 - * @platform Native - * @language zh_CN - */ - const ChildrenSortMode: { - DEFAULT: string; - INCREASE_Y: string; - DECREASE_Y: string; - }; -} -declare namespace egret { - /** - * The CapsStyle class is an enumeration of constant values that specify the caps style to use in drawing lines. - * The constants are provided for use as values in the caps parameter of the egret.Graphics.lineStyle() method. - * @see egret.Graphics#lineStyle() - * @version Egret 2.5 - * @platform Web,Native - * @language en_US - */ - /** - * CapsStyle 类是可指定在绘制线条中使用的端点样式的常量值枚举。常量可用作 egret.Graphics.lineStyle() 方法的 caps 参数中的值。 - * @see egret.Graphics#lineStyle() - * @version Egret 2.5 - * @platform Web,Native - * @language zh_CN - */ - const CapsStyle: { - NONE: string; - ROUND: string; - SQUARE: string; - }; -} -declare namespace egret { - /** - * @private - */ - class WebGLUtils { - static compileProgram(gl: WebGLRenderingContext, vertexSrc: string, fragmentSrc: string): WebGLProgram; - static compileFragmentShader(gl: WebGLRenderingContext, shaderSrc: string): WebGLShader; - static compileVertexShader(gl: WebGLRenderingContext, shaderSrc: string): WebGLShader; - private static _compileShader(gl, shaderSrc, shaderType); - private static canUseWebGL; - static checkCanUseWebGL(): boolean; - static deleteWebGLTexture(webglTexture: WebGLTexture): void; - /** - * inspired by pixi.js - */ - static premultiplyTint(tint: number, alpha: number): number; - } -} -declare namespace egret { - /** - * The EventPhase class provides values for the eventPhase property of the Event class. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/EventPhase.ts - * @language en_US - */ - /** - * EventPhase 可为 Event 类的 eventPhase 属性提供值。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/EventPhase.ts - * @language zh_CN - */ - const enum EventPhase { - /** - * The capturing phase, which is the first phase of the event flow. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 捕获阶段。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - CAPTURING_PHASE = 1, - /** - * The target phase, which is the second phase of the event flow. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 目标阶段,是事件流的第二个阶段。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - AT_TARGET = 2, - /** - * The bubbling phase, which is the third phase of the event flow. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 冒泡阶段。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - BUBBLING_PHASE = 3, - } -} -declare namespace egret { - /** - * When the user changes the focus from one object in the display list to another object, the object dispatches a FocusEvent object. Currently only supports input text. - * Focus events: FocusEvent.FOCUS_IN FocusEvent.FOCUS_OUT - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 用户将焦点从显示列表中的一个对象更改到另一个对象时,对象将调度 FocusEvent 对象。目前只支持输入文本。 - * 焦点事件:FocusEvent.FOCUS_IN FocusEvent.FOCUS_OUT - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - class FocusEvent extends egret.Event { - /** - * Gets focus - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 获得焦点 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static FOCUS_IN: "focusIn"; - /** - * Loses focus - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 失去焦点 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static FOCUS_OUT: "focusOut"; - /** - * Create a egret.FocusEvent objects - * @param type The type of the event, accessible as Event.type. - * @param bubbles Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false. - * @param cancelable Determines whether the Event object can be canceled. The default values is false. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 egret.FocusEvent 对象 - * @param type 事件的类型,可以作为 Event.type 访问。 - * @param bubbles 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。 - * @param cancelable 确定是否可以取消 Event 对象。默认值为 false。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(type: string, bubbles?: boolean, cancelable?: boolean); - } -} -declare namespace egret { - interface Geolocation { - addEventListener(type: "ioError", listener: (this: Z, e: GeolocationEvent) => void, thisObject: Z, useCapture?: boolean, priority?: number): any; - addEventListener(type: string, listener: Function, thisObject: any, useCapture?: boolean, priority?: number): any; - } - /** - * The GeolocationEvent represents the position and altitude of the device on Earth, - * and show errors occurred while getting the location of the device. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/sensor/Geolocation.ts - * @see http://edn.egret.com/cn/docs/page/662 获取位置信息 - * @language en_US - */ - /** - * GeolocationEvent 提供设备的地理位置信息和获取位置时发生的错误信息 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/sensor/Geolocation.ts - * @see http://edn.egret.com/cn/docs/page/662 获取位置信息 - * @language zh_CN - */ - class GeolocationEvent extends Event { - /** - * The acquisition of the location information failed because of app don't have permission. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 由于用户拒绝访问位置信息,获取位置信息失败 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static PERMISSION_DENIED: string; - /** - * The acquisition of the location failed because at least one internal source of position returned an internal error. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 设备位置服务不可用或者超时等原因没有得到位置信息 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static UNAVAILABLE: string; - /** - * The position's longitude in decimal degrees. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 当前位置的经度信息 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - longitude: number; - /** - * The position's latitude in decimal degrees. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 当前位置的纬度信息 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - latitude: number; - /** - * The velocity of the device in meters per second. This value can be null. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 当前设备的速度 单位是 米/秒,这个值可能为 null - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - speed: number; - /** - * The direction in which the device is traveling. This value, specified in degrees, - * indicates how far off from heading due north the device is. 0 degrees represents - * true true north, and the direction is determined clockwise (which means that east - * is 90 degrees and west is 270 degrees). If speed is 0, heading is NaN. If the - * device is unable to provide heading information, this value is null. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示设备正在前进的方向,单位是度。heading 表示从正北开始顺时针旋转到当前方向的角度, - * 比如正东是 90 度,正西是 270 度,如果 speed 是 0,heading 为 NaN。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - heading: number; - /** - * The position's altitude in metres, relative to sea level. - * This value can be null if the implementation cannot provide the data. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 该位置的海拔信息,如果设备没有实现这个属性时,这个值有可能为 null - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - altitude: number; - /** - * The accuracy of the latitude and longitude properties, expressed in meters. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 经纬度的准确性,单位是米 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - accuracy: number; - /** - * The accuracy of the altitude expressed in meters. This value can be null. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 该位置海拔信息的准确性,单位是米,这个值有可能为 null - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - altitudeAccuracy: number; - /** - * The type of error occurred while get the location of the device. The value could be: - * @see egret.GeolocationEvent.PERMISSION_DENIED - * @see egret.GeolocationEvent.UNAVAILABLE - * - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 获取位置信息错误时的错误类型。值可能为: - * @see egret.GeolocationEvent.PERMISSION_DENIED - * @see egret.GeolocationEvent.UNAVAILABLE - * - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - errorType: string; - /** - * The error message occurred while get the location of the device. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 获取位置信息错误的错误信息 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - errorMessage: string; - } -} -declare namespace egret { - /** - * When a network request returns an HTTP status code, the application dispatches HTTPStatusEvent objects. - * Before error or completion events will always send HTTPStatusEvent object. HTTPStatusEvent object does not necessarily indicate an error condition; it simply reflects the HTTP status code provided by the network stack (if any). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 在网络请求返回 HTTP 状态代码时,应用程序将调度 HTTPStatusEvent 对象。 - * 在错误或完成事件之前,将始终发送 HTTPStatusEvent 对象。HTTPStatusEvent 对象不一定表示错误条件;它仅反映网络堆栈提供的 HTTP 状态代码(如果有的话)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - class HTTPStatusEvent extends Event { - /** - * HTTPStatusEvent.HTTP_STATUS constant defines the value of the type property httpStatus event object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * HTTPStatusEvent.HTTP_STATUS 常量定义 httpStatus 事件对象的 type 属性值。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static HTTP_STATUS: "httpStatus"; - /** - * Create a egret.HTTPStatusEvent objects - * @param type The type of the event, accessible as Event.type. - * @param bubbles Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false. - * @param cancelable Determines whether the Event object can be canceled. The default values is false. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 egret.HTTPStatusEvent 对象 - * @param type 事件的类型,可以作为 Event.type 访问。 - * @param bubbles 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。 - * @param cancelable 确定是否可以取消 Event 对象。默认值为 false。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(type: string, bubbles?: boolean, cancelable?: boolean); - /** - * @private - */ - private _status; - /** - * he server returns the HTTP status code. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 由服务器返回的 HTTP 状态代码。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly status: number; - /** - * EventDispatcher object using the specified event object thrown Event. The objects will be thrown in the object cache pool for the next round robin. - * @param target {egret.IEventDispatcher} Distribute event target - * @param status {number} The server returns the HTTP status code - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 使用指定的EventDispatcher对象来抛出Event事件对象。抛出的对象将会缓存在对象池上,供下次循环复用。 - * @param target {egret.IEventDispatcher} 派发事件目标 - * @param status {number} 由服务器返回的 HTTP 状态代码 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static dispatchHTTPStatusEvent(target: IEventDispatcher, status: number): boolean; - } -} -declare namespace egret { - /** - * The IEventDispatcher interface defines methods for adding or removing event listeners, checks whether specific types - * of event listeners are registered, and dispatches events. Event targets are an important part of the Egret event model. - * The event target serves as the focal point for how events flow through the display list hierarchy. When an event - * such as a touch tap occurs, an event object is dispatched into the event flow from the root of the display list. - * The event object makes a round-trip journey to the event target, which is conceptually divided into three phases:
- * the capture phase includes the journey from the root to the last node before the event target's node; the target - * phase includes only the event target node; and the bubbling phase includes any subsequent nodes encountered on the - * return trip to the root of the display list.In general, the easiest way for a user-defined class to gain event - * dispatching capabilities is to extend EventDispatcher. If this is impossible (that is, if the class is already - * extending another class), you can instead implement the IEventDispatcher interface, create an EventDispatcher member, - * and write simple hooks to route calls into the aggregated EventDispatcher. - * @see egret.EventDispatcher - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/IEventDispatcher.ts - * @language en_US - */ - /** - * IEventDispatcher 接口定义用于添加或删除事件侦听器的方法,检查是否已注册特定类型的事件侦听器,并调度事件。 - * 事件目标是 Egret 事件模型的重要组成部分。事件目标是事件如何通过显示列表层次结构这一问题的焦点。当发生触摸轻拍事件时, - * 会将事件对象调度到从显示列表根开始的事件流中。事件对象进行到事件目标的往返行程,在概念上,此往返行程被划分为三个阶段:
- * 捕获阶段包括从根到事件目标节点之前的最后一个节点的行程,目标阶段仅包括事件目标节点,冒泡阶段包括到显示列表的根的回程上遇到的任何后续节点。 - * 通常,使用户定义的类能够调度事件的最简单方法是扩展 EventDispatcher。如果无法扩展(即,如果该类已经扩展了另一个类), - * 则可以实现 IEventDispatcher 接口,创建 EventDispatcher 成员,并编写一些简单的挂钩,将调用连接到聚合的 EventDispatcher 中。 - * @see egret.EventDispatcher - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/IEventDispatcher.ts - * @language zh_CN - */ - interface IEventDispatcher extends HashObject { - /** - * Registers an event listener object with an EventDispatcher object so that the listener receives notification of an - * event. You can register event listeners on all nodes in the display list for a specific type of event, phase, - * and priority.After you successfully register an event listener, you cannot change its priority through additional - * calls to on(). To change a listener's priority, you must first call removeEventListener(). Then you can register the - * listener again with the new priority level.After the listener is registered, subsequent calls to on() with a - * different value for either type or useCapture result in the creation of a separate listener registration.
- * When you no longer need an event listener, remove it by calling EventDispatcher.removeEventListener(); otherwise, memory - * problems might result. Objects with registered event listeners are not automatically removed from memory because - * the garbage collector does not remove objects that still have references.Copying an EventDispatcher instance does - * not copy the event listeners attached to it. (If your newly created node needs an event listener, you must attach - * the listener after creating the node.) However, if you move an EventDispatcher instance, the event listeners attached - * to it move along with it.If the event listener is being registered on a node while an event is also being processed - * on this node, the event listener is not triggered during the current phase but may be triggered during a later phase - * in the event flow, such as the bubbling phase.If an event listener is removed from a node while an event is being - * processed on the node, it is still triggered by the current actions. After it is removed, the event listener is - * never invoked again (unless it is registered again for future processing). - * @param type The type of event. - * @param listener The listener function that processes the event. This function must accept an event object as - * its only parameter and must return nothing, as this example shows: function(evt:Event):void The function can - * have any name. - * @param thisObject the listener function's "this" - * @param useCapture Determines whether the listener works in the capture phase or the bubbling phases. If useCapture - * is set to true, the listener processes the event only during the capture phase and not in the bubbling phase. - * If useCapture is false, the listener processes the event only during the bubbling phase. To listen for the event - * in all three phases, call on() twice, once with useCapture set to true, then again with useCapture set to false. - * @param priority The priority level of the event listener. Priorities are designated by a integer. The higher - * the number, the higher the priority. All listeners with priority n are processed before listeners of priority n-1. - * If two or more listeners share the same priority, they are processed in the order in which they were added. - * The default priority is - * @see #once() - * @see #removeEventListener() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 使用 EventDispatcher 对象注册事件侦听器对象,以使侦听器能够接收事件通知。可以为特定类型的事件、阶段和优先级在显示列表的所有节 - * 点上注册事件侦听器。成功注册一个事件侦听器后,无法通过额外调用 on() 来更改其优先级。要更改侦听器的优先级,必须 - * 先调用 removeEventListener()。然后,可以使用新的优先级再次注册该侦听器。注册该侦听器后,如果继续调用具有不同 type 或 useCapture - * 值的 on(),则会创建单独的侦听器注册。
- * 如果不再需要某个事件侦听器,可调用 EventDispatcher.removeEventListener() - * 删除它;否则会产生内存问题。由于垃圾回收器不会删除仍包含引用的对象,因此不会从内存中自动删除使用已注册事件侦听器的对象。复制 - * EventDispatcher 实例时并不复制其中附加的事件侦听器。(如果新近创建的节点需要一个事件侦听器,必须在创建该节点后附加该侦听器。) - * 但是,如果移动 EventDispatcher 实例,则其中附加的事件侦听器也会随之移动。如果在正在处理事件的节点上注册事件侦听器,则不会在当 - * 前阶段触发事件侦听器,但会在事件流的稍后阶段触发,如冒泡阶段。如果从正在处理事件的节点中删除事件侦听器,则该事件侦听器仍由当前操 - * 作触发。删除事件侦听器后,决不会再次调用该事件侦听器(除非再次注册以备将来处理)。 - * @param type 事件的类型。 - * @param listener 处理事件的侦听器函数。此函数必须接受 Event 对象作为其唯一的参数,并且不能返回任何结果, - * 如下面的示例所示: function(evt:Event):void 函数可以有任何名称。 - * @param thisObject 侦听函数绑定的this对象 - * @param useCapture 确定侦听器是运行于捕获阶段还是运行于冒泡阶段。如果将 useCapture 设置为 true, - * 则侦听器只在捕获阶段处理事件,而不在冒泡阶段处理事件。如果 useCapture 为 false,则侦听器只在冒泡阶段处理事件。 - * 要在两个阶段都侦听事件,请调用 on() 两次:一次将 useCapture 设置为 true,一次将 useCapture 设置为 false。 - * @param priority 事件侦听器的优先级。优先级由一个带符号的整数指定。数字越大,优先级越高。优先级为 n 的所有侦听器会在 - * 优先级为 n -1 的侦听器之前得到处理。如果两个或更多个侦听器共享相同的优先级,则按照它们的添加顺序进行处理。默认优先级为 0。 - * @see #once() - * @see #removeEventListener() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - addEventListener(type: string, listener: Function, thisObject: any, useCapture?: boolean, priority?: number): void; - /** - * Registers an event listener object with an EventDispatcher object so that the listener receives notification of an - * event. Different from the on() method,the listener receives notification only once,and then it will be removed - * automatically. - * @param type The type of event. - * @param listener The listener function that processes the event. This function must accept an event object as - * its only parameter and must return nothing, as this example shows: function(evt:Event):void The function can - * have any name. - * @param thisObject the listener function's "this" - * @param useCapture Determines whether the listener works in the capture phase or the bubbling phases. If useCapture - * is set to true, the listener processes the event only during the capture phase and not in the bubbling phase. - * If useCapture is false, the listener processes the event only during the bubbling phase. To listen for the event - * in all three phases, call on() twice, once with useCapture set to true, then again with useCapture set to false. - * @param priority The priority level of the event listener. Priorities are designated by a integer. The higher - * the number, the higher the priority. All listeners with priority n are processed before listeners of priority n-1. - * If two or more listeners share the same priority, they are processed in the order in which they were added. - * The default priority is - * @see #on() - * @see #removeEventListener() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 添加仅回调一次的事件侦听器,此方法与on()方法不同,on()方法会持续产生回调,而此方法在第一次回调时就会自动移除监听。 - * @param type 事件的类型。 - * @param listener 处理事件的侦听器函数。此函数必须接受 Event 对象作为其唯一的参数,并且不能返回任何结果, - * 如下面的示例所示: function(evt:Event):void 函数可以有任何名称。 - * @param thisObject 侦听函数绑定的this对象 - * @param useCapture 确定侦听器是运行于捕获阶段还是运行于冒泡阶段。如果将 useCapture 设置为 true, - * 则侦听器只在捕获阶段处理事件,而不在冒泡阶段处理事件。如果 useCapture 为 false,则侦听器只在冒泡阶段处理事件。 - * 要在两个阶段都侦听事件,请调用 once() 两次:一次将 useCapture 设置为 true,一次将 useCapture 设置为 false。 - * @param priority 事件侦听器的优先级。优先级由一个带符号整数指定。数字越大,优先级越高。优先级为 n 的所有侦听器会在 - * 优先级为 n -1 的侦听器之前得到处理。如果两个或更多个侦听器共享相同的优先级,则按照它们的添加顺序进行处理。默认优先级为 0。 - * @see #on() - * @see #removeEventListener() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - once(type: string, listener: Function, thisObject: any, useCapture?: boolean, priority?: number): void; - /** - * Removes a listener from the EventDispatcher object. If there is no matching listener registered with the - * EventDispatcher object, a call to this method has no effect. - * @param type The type of event. - * @param listener The listener object to remove. - * @param thisObject the listener function's "this" - * @param useCapture Specifies whether the listener was registered for the capture phase or the bubbling phases. - * If the listener was registered for both the capture phase and the bubbling phases, two calls to removeEventListener() - * are required to remove both: one call with useCapture set to true, and another call with useCapture set to false. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从 EventDispatcher 对象中删除侦听器。如果没有向 EventDispatcher 对象注册任何匹配的侦听器,则对此方法的调用没有任何效果。 - * @param type 事件的类型。 - * @param listener 要删除的侦听器对象 - * @param thisObject 侦听函数绑定的this对象 - * @param useCapture 指出是为捕获阶段还是为冒泡阶段注册了侦听器。如果为捕获阶段以及冒泡阶段注册了侦听器,则需要对 - * removeEventListener() 进行两次调用才能将这两个侦听器删除:一次调用将 useCapture 设置为 true,另一次调用将 useCapture 设置为 false。。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - removeEventListener(type: string, listener: Function, thisObject: any, useCapture?: boolean): void; - /** - * Checks whether the EventDispatcher object has any listeners registered for a specific type of event. This allows - * you to determine where an EventDispatcher object has altered handling of an event type in the event flow hierarchy. - * To determine whether a specific event type will actually trigger an event listener, use IEventDispatcher.willTrigger(). - * The difference between hasEventListener() and willTrigger() is that hasEventListener() examines only the object to - * which it belongs, whereas willTrigger() examines the entire event flow for the event specified by the type parameter. - * @param type The type of event. - * @returns A value of true if a listener of the specified type is registered; false otherwise. - * @see #willTrigger() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 检查 EventDispatcher 对象是否为特定事件类型注册了任何侦听器。这样,您就可以确定 EventDispatcher 对象在事件流层次结构中的哪个 - * 位置改变了对事件类型的处理。要确定特定事件类型是否确实会触发事件侦听器,请使用 IEventDispatcher.willTrigger()。hasEventListener() - * 与 willTrigger() 的区别是:hasEventListener() 只检查它所属的对象,而 willTrigger() 检查整个事件流以查找由 type 参数指定的事件。 - * @param type 事件的类型。 - * @returns 如果指定类型的侦听器已注册,则值为 true;否则,值为 false。 - * @see #willTrigger() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - hasEventListener(type: string): boolean; - /** - * Dispatches an event into the event flow. The event target is the EventDispatcher object upon which dispatchEvent() is called. - * @param event The event object dispatched into the event flow. - * @returns A value of true unless preventDefault() is called on the event, in which case it returns false. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将事件分派到事件流中。事件目标是对其调用 dispatchEvent() 方法的 EventDispatcher 对象。 - * @param event 调度到事件流中的 Event 对象。 - * @returns 如果成功调度了事件,则值为 true。值 false 表示失败或对事件调用了 preventDefault()。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - dispatchEvent(event: Event): boolean; - /** - * Checks whether an event listener is registered with this EventDispatcher object or any of its ancestors for the - * specified event type. This method returns true if an event listener is triggered during any phase of the event - * flow when an event of the specified type is dispatched to this EventDispatcher object or any of its descendants. - * @param type The type of event. - * @returns A value of true if a listener of the specified type will be triggered; false otherwise. - * @see #hasEventListener() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 检查是否用此 EventDispatcher 对象或其任何始祖为指定事件类型注册了事件侦听器。将指定类型的事件调度给此 - * EventDispatcher 对象或其任一后代时,如果在事件流的任何阶段触发了事件侦听器,则此方法返回 true。 - * hasEventListener() 与 willTrigger() 方法的区别是:hasEventListener() 只检查它所属的对象, - * 而 willTrigger() 方法检查整个事件流以查找由 type 参数指定的事件。 - * @param type 事件类型 - * @returns 是否注册过监听器,如果注册过返回true,反之返回false - * @see #hasEventListener() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - willTrigger(type: string): boolean; - } -} -declare namespace egret { - interface HttpRequest { - addEventListener(type: "ioError", listener: (this: Z, e: IOErrorEvent) => void, thisObject: Z, useCapture?: boolean, priority?: number): any; - addEventListener(type: string, listener: Function, thisObject: any, useCapture?: boolean, priority?: number): any; - } - /** - * @classdesc IO流事件,当错误导致输入或输出操作失败时调度 IOErrorEvent 对象。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/IOErrorEvent.ts - * @language en_US - */ - /** - * @classdesc IO流事件,当错误导致输入或输出操作失败时调度 IOErrorEvent 对象。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/IOErrorEvent.ts - * @language zh_CN - */ - class IOErrorEvent extends Event { - /** - * io error - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * io发生错误 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static IO_ERROR: "ioError"; - /** - * Create a egret.IOErrorEvent objects - * @param type {string} Type of event, accessible as Event.type. - * @param bubbles {boolean} Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false. - * @param cancelable {boolean} Determine whether the Event object can be canceled. The default value is false. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 egret.IOErrorEvent 对象 - * @param type {string} 事件的类型,可以作为 Event.type 访问。 - * @param bubbles {boolean} 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。 - * @param cancelable {boolean} 确定是否可以取消 Event 对象。默认值为 false。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(type: string, bubbles?: boolean, cancelable?: boolean); - /** - * EventDispatcher object using the specified event object thrown Event. The objects will be thrown in the object cache pool for the next round robin. - * @param target {egret.IEventDispatcher} Distribute event target - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 使用指定的EventDispatcher对象来抛出Event事件对象。抛出的对象将会缓存在对象池上,供下次循环复用。 - * @param target {egret.IEventDispatcher} 派发事件目标 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static dispatchIOErrorEvent(target: IEventDispatcher): boolean; - } -} -declare namespace egret { - /** - * MotionEvent represents the device's movement - * Acceleration and accelerationIncludingGravity to represents the device's acceleration - * RotationRate to represents the device's rotation - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/sensor/Motion.ts - * @language en_US - */ - /** - * MotionEvent 类呈现设备运动的具体信息 - * Acceleration 和 accelerationIncludingGravity 呈现设备三个维度的加速度信息 - * RotationRate 呈现设备的旋转状态信息 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/sensor/Motion.ts - * @language zh_CN - */ - class MotionEvent extends Event { - /** - * An object giving the acceleration of the device on the three axis X, Y and Z. Acceleration is expressed in m/s2. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * acceleration 表示设备在 X Y Z 轴方将的加速度信息,单位是 m/s2,不包含重力 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - acceleration: DeviceAcceleration; - /** - * An object giving the acceleration of the device on the three axis X, Y and Z with the effect of gravity. Acceleration is expressed in m/s2. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * acceleration 表示设备在 X Y Z 轴方将的加速度信息,单位是 m/s2,包含重力 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - accelerationIncludingGravity: DeviceAcceleration; - /** - * An object giving the rate of change of the device's orientation on the three orientation axis alpha, beta and gamma. Rotation rate is express in degrees per seconds. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * rotationRate 表示设备在 alpha、 beta 和 gamma 三个轴向的角速度信息,单位是 角度每秒 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - rotationRate: DeviceRotationRate; - } -} -declare namespace egret { - /** - * The OrientationEvent provides information from the physical orientation of the device. - * Note: Currently, Browsers on the iOS and Android does not handle the coordinates the same way. - * Take care about this while using them. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/sensor/DeviceOrientation.ts - * @language en_US - */ - /** - * OrientationEvent 提供设备的方向信息 - * 注意: 目前各个浏览器和操作系统处理方向的方式不完全相同,请根据使用场景做相应的校正, - * 比如使用两次方向数据的变化而不是直接使用方向的值 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/sensor/DeviceOrientation.ts - * @language zh_CN - */ - class OrientationEvent extends Event { - /** - * A number representing the motion of the device around the z axis, - * express in degrees with values ranging from 0 to 360 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示设备绕 Z 轴的角度,单位是 角度 范围是 0 到 360 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - alpha: number; - /** - * A number representing the motion of the device around the x axis, - * express in degrees with values ranging from -180 to 180. - * This represents a front to back motion of the device. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示设备绕 X 轴的角度,单位是 角度 范围是 -180 到 180. - * 这个值表示设备从前向后的旋转状态 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - beta: number; - /** - * A number representing the motion of the device around the y axis, - * express in degrees with values ranging from -90 to 90. - * This represents a left to right motion of the device. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示设备绕 Y 轴的角度,单位是 角度 范围是 -90 到 90. - * 这个值表示设备从前向后的旋转状态 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - gamma: number; - } -} -declare namespace egret { - interface HttpRequest { - addEventListener(type: "progress", listener: (this: Z, e: ProgressEvent) => void, thisObject: Z, useCapture?: boolean, priority?: number): any; - addEventListener(type: string, listener: Function, thisObject: any, useCapture?: boolean, priority?: number): any; - } - /** - * When a load operation has begun or a socket has received data, ProgressEvent object is dispatched. - * There are two types of progress events: ProgressEvent.PROGRESS and ProgressEvent.SOCKET_DATA. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 当加载操作已开始或套接字已接收到数据时,将调度 ProgressEvent 对象。 - * 有两种类型的进程事件:ProgressEvent.PROGRESS 和 ProgressEvent.SOCKET_DATA。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - class ProgressEvent extends egret.Event { - /** - * Changes in the loading progress - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 加载进度发生变化 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static PROGRESS: "progress"; - /** - * Get the data - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 获取到数据 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static SOCKET_DATA: "socketData"; - /** - * Number of items or bytes when the listener processes the event。 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 在侦听器处理事件时加载的项数或字节数。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - bytesLoaded: number; - /** - * If the loading process succeeds, the total number or the total number of bytes that will be loaded term. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 如果加载过程成功,将加载的总项数或总字节数。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - bytesTotal: number; - /** - * 创建一个 egret.ProgressEvent 对象 - * @param type The type of the event, accessible as Event.type. - * @param bubbles Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false. - * @param cancelable Determines whether the Event object can be canceled. The default values is false. - * @param bytesLoaded {number} Number of items or bytes loaded - * @param bytesTotal {number} The total number of items or bytes loaded - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 egret.ProgressEvent 对象 - * @param type 事件的类型,可以作为 Event.type 访问。 - * @param bubbles 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。 - * @param cancelable 确定是否可以取消 Event 对象。默认值为 false。 - * @param bytesLoaded {number} 加载的项数或字节数 - * @param bytesTotal {number} 加载的总项数或总字节数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(type: string, bubbles?: boolean, cancelable?: boolean, bytesLoaded?: number, bytesTotal?: number); - /** - * EventDispatcher object using the specified event object thrown Event. The objects will be thrown in the object cache pool for the next round robin. - * @param target {egret.IEventDispatcher} Distribute event target - * @param type The type of the event, accessible as Event.type. - * @param bytesLoaded {number} Number of items or bytes loaded - * @param bytesTotal {number} The total number of items or bytes loaded - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 使用指定的EventDispatcher对象来抛出Event事件对象。抛出的对象将会缓存在对象池上,供下次循环复用。 - * @param target {egret.IEventDispatcher} 派发事件目标 - * @param type {string} 事件类型 - * @param bytesLoaded {number} 加载的项数或字节数 - * @param bytesTotal {number} 加载的总项数或总字节数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static dispatchProgressEvent(target: IEventDispatcher, type: string, bytesLoaded?: number, bytesTotal?: number): boolean; - } -} -declare namespace egret { - interface Stage { - addEventListener(type: "orientationChange", listener: (this: Z, e: StageOrientationEvent) => void, thisObject: Z, useCapture?: boolean, priority?: number): any; - addEventListener(type: string, listener: Function, thisObject: any, useCapture?: boolean, priority?: number): any; - } - /** - * When the direction of the stage of change, Stage object dispatches StageOrientationEvent object. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/StageOrientationEvent.ts - * @language en_US - */ - /** - * 当舞台的方向更改时,Stage 对象将调度 StageOrientationEvent 对象。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/StageOrientationEvent.ts - * @language zh_CN - */ - class StageOrientationEvent extends Event { - /** - * After screen rotation distribute events. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 屏幕旋转后派发的事件。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static ORIENTATION_CHANGE: "orientationChange"; - /** - * Creating contains specific information related to the event and the stage direction of StageOrientationEvent object. - * @param type Event types:StageOrientationEvent.ORIENTATION_CHANGE - * @param bubbles It indicates whether the Event object participates in the bubbling stage of the event flow. - * @param cancelable It indicates whether the Event object can be canceled. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建包含与舞台方向事件相关的特定信息的 StageOrientationEvent 对象。 - * @param type 事件的类型:StageOrientationEvent.ORIENTATION_CHANGE - * @param bubbles 表示 Event 对象是否参与事件流的冒泡阶段。 - * @param cancelable 表示是否可以取消 Event 对象。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(type: string, bubbles?: boolean, cancelable?: boolean); - /** - * 派发一个屏幕旋转的事件。 - * @param target {egret.IEventDispatcher} 派发事件目标 - * @param type {egret.IEventDispatcher} 派发事件类型 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 派发一个屏幕旋转的事件。 - * @param target {egret.IEventDispatcher} Distribute event target - * @param type {egret.IEventDispatcher} Distribute event type - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static dispatchStageOrientationEvent(target: IEventDispatcher, type: string): boolean; - } -} -declare namespace egret { - /** - * When a user clicks a hyperlink rich text object dispatches TextEvent object. Text Event Type: TextEvent.LINK. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/TextEvent.ts - * @language en_US - */ - /** - * 用户在富文本中单击超链接时,对象将调度 TextEvent 对象。文本事件类型:TextEvent.LINK。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/TextEvent.ts - * @language zh_CN - */ - class TextEvent extends Event { - /** - * TextEvent create an object that contains information about text events. - * @param type Type of event, you can access the TextEvent.type. - * @param bubbles Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false. - * @param cancelable Determine whether the Event object can be canceled. The default value is false. - * @param text One or more characters of text entered by the user. Event listeners can access this information through the text property. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 TextEvent 对象,其中包含有关文本事件的信息。 - * @param type 事件的类型,可以作为 TextEvent.type 访问。 - * @param bubbles 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。 - * @param cancelable 确定是否可以取消 Event 对象。默认值为 false。 - * @param text 用户输入的一个或多个文本字符。事件侦听器可以通过 text 属性访问此信息。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(type: string, bubbles?: boolean, cancelable?: boolean, text?: string); - /** - * It defines the value of the type property of a link event object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 定义 link 事件对象的 type 属性值。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static LINK: "link"; - /** - * In TextEvent.LINK event, event corresponding string. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 在 TextEvent.LINK 事件中,event对应的字符串。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - text: string; - /** - * EventDispatcher object using the specified event object thrown TextEvent. The objects will be thrown in the object cache pool for the next round robin. - * @param type The type of the event, accessible as Event.type. - * @param bubbles Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false. - * @param text Text TextEvent object assignment - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 使用指定的EventDispatcher对象来抛出TextEvent事件对象。抛出的对象将会缓存在对象池上,供下次循环复用。 - * @param target 派发事件目标 - * @param type 事件类型 - * @param text TextEvent对象的text赋值 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static dispatchTextEvent(target: IEventDispatcher, type: string, text: string): boolean; - } -} -declare namespace egret { - interface Timer { - addEventListener(type: "timer" | "timerComplete", listener: (this: Z, e: TimerEvent) => void, thisObject: Z, useCapture?: boolean, priority?: number): any; - addEventListener(type: string, listener: Function, thisObject: any, useCapture?: boolean, priority?: number): any; - } - /** - * A Timer object dispatches a TimerEvent objects whenever the Timer object reaches the interval specified by the Timer.delay property. - * @see egret.Timer - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/TimerEvent.ts - * @language en_US - */ - /** - * 每当 Timer 对象达到由 Timer.delay 属性指定的间隔时,Timer 对象即会调度 TimerEvent 对象。 - * @see egret.Timer - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/TimerEvent.ts - * @language zh_CN - */ - class TimerEvent extends Event { - /** - * Dispatched whenever a Timer object reaches an interval specified according to the Timer.delay property. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 每当 Timer 对象达到根据 Timer.delay 属性指定的间隔时调度。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static TIMER: "timer"; - /** - * Dispatched whenever it has completed the number of requests set by Timer.repeatCount. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 每当它完成 Timer.repeatCount 设置的请求数后调度。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static TIMER_COMPLETE: "timerComplete"; - /** - * Creates an Event object with specific information relevant to timer events. - * @param type The type of the event. Event listeners can access this information through the inherited type property. - * @param bubbles Determines whether the Event object bubbles. Event listeners can access this information through - * the inherited bubbles property. - * @param cancelable Determines whether the Event object can be canceled. Event listeners can access this information - * through the inherited cancelable property. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 Event 对象,其中包含有关 timer 事件的特定信息。 - * @param type 事件的类型。事件侦听器可以通过继承的 type 属性访问此信息。 - * @param bubbles 确定 Event 对象是否冒泡。事件侦听器可以通过继承的 bubbles 属性访问此信息。 - * @param cancelable 确定是否可以取消 Event 对象。事件侦听器可以通过继承的 cancelable 属性访问此信息。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(type: string, bubbles?: boolean, cancelable?: boolean); - /** - * Instructs Egret runtime to render after processing of this event completes, if the display list has been modified. - * @example - *
-         *    function onTimer(event:TimerEvent):void {
-         *        if (40 < mySp.x && mySp.x < 375) {
-         *            mySp.x-= 50;
-         *        } else {
-         *            mySp.x=374;
-         *        }
-         *        event.updateAfterEvent();
-         *    }
-         *
-         *    let moveTimer:Timer=new Timer(50,250);
-         *    moveTimer.addEventListener(TimerEvent.TIMER,onTimer);
-         *    moveTimer.start();
-         * 
- * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 如果已修改显示列表,调用此方法将会忽略帧频限制,在此事件处理完成后立即重绘屏幕。 - * @example - *
-         *    function onTimer(event:TimerEvent):void {
-         *        if (40 < mySp.x && mySp.x < 375) {
-         *            mySp.x-= 50;
-         *        } else {
-         *            mySp.x=374;
-         *        }
-         *        event.updateAfterEvent();
-         *    }
-         *
-         *    let moveTimer:Timer=new Timer(50,250);
-         *    moveTimer.addEventListener(TimerEvent.TIMER,onTimer);
-         *    moveTimer.start();
-         * 
- * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - updateAfterEvent(): void; - /** - * uses a specified target to dispatchEvent an event. Using this method can reduce the number of - * reallocate event objects, which allows you to get better code execution performance. - * @param target the event target - * @param type The type of the event. Event listeners can access this information through the inherited type property. - * @param bubbles Determines whether the Event object bubbles. Event listeners can access this information through - * the inherited bubbles property. - * @param cancelable Determines whether the Event object can be canceled. Event listeners can access this information - * through the inherited cancelable property. - * @see egret.Event.create() - * @see egret.Event.release() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 使用指定的EventDispatcher对象来抛出事件对象。抛出的对象将会缓存在对象池上,供下次循环复用。 - * @param target 事件派发目标 - * @param type 事件的类型。事件侦听器可以通过继承的 type 属性访问此信息。 - * @param bubbles 确定 Event 对象是否冒泡。事件侦听器可以通过继承的 bubbles 属性访问此信息。 - * @param cancelable 确定是否可以取消 Event 对象。事件侦听器可以通过继承的 cancelable 属性访问此信息。 - * @see egret.Event.create() - * @see egret.Event.release() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static dispatchTimerEvent(target: IEventDispatcher, type: string, bubbles?: boolean, cancelable?: boolean): boolean; - } -} -declare namespace egret { - class CompressedTextureData { - glInternalFormat: number; - width: number; - height: number; - byteArray: Uint8Array; - face: number; - level: number; - } - const etc_alpha_mask = "etc_alpha_mask"; - const engine_default_empty_texture = "engine_default_empty_texture"; - const is_compressed_texture = "is_compressed_texture"; - const glContext = "glContext"; - const UNPACK_PREMULTIPLY_ALPHA_WEBGL = "UNPACK_PREMULTIPLY_ALPHA_WEBGL"; - /** - * A BitmapData object contains an array of pixel data. This data can represent either a fully opaque bitmap or a - * transparent bitmap that contains alpha channel data. Either type of BitmapData object is stored as a buffer of 32-bit - * integers. Each 32-bit integer determines the properties of a single pixel in the bitmap.
- * Each 32-bit integer is a combination of four 8-bit channel values (from 0 to 255) that describe the alpha transparency - * and the red, green, and blue (ARGB) values of the pixel. (For ARGB values, the most significant byte represents the - * alpha channel value, followed by red, green, and blue.) - * @see egret.Bitmap - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * BitmapData 对象是一个包含像素数据的数组。此数据可以表示完全不透明的位图,或表示包含 Alpha 通道数据的透明位图。 - * 以上任一类型的 BitmapData 对象都作为 32 位整数的缓冲区进行存储。每个 32 位整数确定位图中单个像素的属性。
- * 每个 32 位整数都是四个 8 位通道值(从 0 到 255)的组合,这些值描述像素的 Alpha 透明度以及红色、绿色、蓝色 (ARGB) 值。 - * (对于 ARGB 值,最高有效字节代表 Alpha 通道值,其后的有效字节分别代表红色、绿色和蓝色通道值。) - * @see egret.Bitmap - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - class BitmapData extends HashObject { - /** - * The width of the bitmap image in pixels. - * @readOnly - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 位图图像的宽度,以像素为单位。 - * @readOnly - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - width: number; - /** - * The height of the bitmap image in pixels. - * @readOnly - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 位图图像的高度,以像素为单位。 - * @readOnly - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - height: number; - /** - * Original bitmap image. - * HTMLImageElement|HTMLCanvasElement|HTMLVideoElement - * @version Egret 2.4 - * @platform Web,Native - * @private - * @language en_US - */ - /** - * 原始位图图像。 - * HTMLImageElement|HTMLCanvasElement|HTMLVideoElement - * @version Egret 2.4 - * @platform Web,Native - * @private - * @language zh_CN - */ - $source: any; - /** - * WebGL texture. - * @version Egret 2.4 - * @platform Web,Native - * @private - * @language en_US - */ - /** - * WebGL纹理。 - * @version Egret 2.4 - * @platform Web,Native - * @private - * @language zh_CN - */ - webGLTexture: any; - /** - * Texture format. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 纹理格式。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - format: string; - /** - * @private - * webgl纹理生成后,是否删掉原始图像数据 - */ - $deleteSource: boolean; - /** - * @private - * id - */ - $nativeBitmapData: egret_native.NativeBitmapData; - /** - * @private - * - */ - readonly compressedTextureData: Array>; - debugCompressedTextureURL: string; - etcAlphaMask: Nullable; - /** - * Initializes a BitmapData object to refer to the specified source object. - * @param source The source object being referenced. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个引用指定 source 实例的 BitmapData 对象 - * @param source 被引用的 source 实例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(source: any); - source: any; - static create(type: "arraybuffer", data: ArrayBuffer, callback?: (bitmapData: BitmapData) => void): BitmapData; - static create(type: "base64", data: string, callback?: (bitmapData: BitmapData) => void): BitmapData; - $dispose(): void; - private static _displayList; - static $addDisplayObject(displayObject: DisplayObject, bitmapData: BitmapData): void; - static $removeDisplayObject(displayObject: DisplayObject, bitmapData: BitmapData): void; - static $invalidate(bitmapData: BitmapData): void; - static $dispose(bitmapData: BitmapData): void; - private _getCompressedTextureData(level, face); - getCompressed2dTextureData(): CompressedTextureData; - hasCompressed2d(): boolean; - clearCompressedTextureData(): void; - } -} -declare namespace egret { - interface DisplayObject { - addEventListener(type: "touchMove" | "touchBegin" | "touchEnd" | "touchCancel" | "touchTap" | "touchReleaseOutside" | "touchRollOut" | "touchRollOver", listener: (this: Z, e: TouchEvent) => void, thisObject: Z, useCapture?: boolean, priority?: number): any; - addEventListener(type: string, listener: Function, thisObject: any, useCapture?: boolean, priority?: number): any; - } - /** - * The TouchEvent class lets you handle events on devices that detect user contact with the device (such as a finger - * on a touch screen).When a user interacts with a device such as a mobile phone or tablet with a touch screen, the - * user typically touches the screen with his or her fingers or a pointing device. You can develop applications that - * respond to basic touch events (such as a single finger tap) with the TouchEvent class. Create event listeners using - * the event types defined in this class. - * Note: When objects are nested on the display list, touch events target the deepest possible nested object that is - * visible in the display list. This object is called the target node. To have a target node's ancestor (an object - * containing the target node in the display list) receive notification of a touch event, use EventDispatcher.addEventListener() - * on the ancestor node with the type parameter set to the specific touch event you want to detect. - * - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/TouchEvent.ts - * @language en_US - */ - /** - * 使用 TouchEvent 类,您可以处理设备上那些检测用户与设备之间的接触的事件。 - * 当用户与带有触摸屏的移动电话或平板电脑等设备交互时,用户通常使用手指或指针设备接触屏幕。可使用 TouchEvent - * 类开发响应基本触摸事件(如单个手指点击)的应用程序。使用此类中定义的事件类型创建事件侦听器。 - * 注意:当对象嵌套在显示列表中时,触摸事件的目标将是显示列表中可见的最深的可能嵌套对象。 - * 此对象称为目标节点。要使目标节点的祖代(祖代是一个包含显示列表中所有目标节点的对象,从舞台到目标节点的父节点均包括在内) - * 接收触摸事件的通知,请对祖代节点使用 EventDispatcher.on() 并将 type 参数设置为要检测的特定触摸事件。 - * - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/events/TouchEvent.ts - * @language zh_CN - */ - class TouchEvent extends Event { - /** - * Dispatched when the user touches the device, and is continuously dispatched until the point of contact is removed. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 当用户触碰设备时进行调度,而且会连续调度,直到接触点被删除。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static TOUCH_MOVE: "touchMove"; - /** - * Dispatched when the user first contacts a touch-enabled device (such as touches a finger to a mobile phone or tablet with a touch screen). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 当用户第一次触摸启用触摸的设备时(例如,用手指触摸配有触摸屏的移动电话或平板电脑)调度。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static TOUCH_BEGIN: "touchBegin"; - /** - * Dispatched when the user removes contact with a touch-enabled device (such as lifts a finger off a mobile phone - * or tablet with a touch screen). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 当用户移除与启用触摸的设备的接触时(例如,将手指从配有触摸屏的移动电话或平板电脑上抬起)调度。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static TOUCH_END: "touchEnd"; - /** - * Dispatched when an event of some kind occurred that canceled the touch. - * Such as the eui.Scroller will dispatch 'TOUCH_CANCEL' when it start move, the 'TOUCH_END' and 'TOUCH_TAP' will not be triggered. - * @version Egret 3.0.1 - * @platform Web,Native - * @language en_US - */ - /** - * 由于某个事件取消了触摸时触发。比如 eui.Scroller 在开始滚动后会触发 'TOUCH_CANCEL' 事件,不再触发后续的 'TOUCH_END' 和 'TOUCH_TAP' 事件 - * @version Egret 3.0.1 - * @platform Web,Native - * @language zh_CN - */ - static TOUCH_CANCEL: "touchCancel"; - /** - * Dispatched when the user lifts the point of contact over the same DisplayObject instance on which the contact - * was initiated on a touch-enabled device. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 当用户在触摸设备上与开始触摸的同一 DisplayObject 实例上抬起接触点时调度。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static TOUCH_TAP: "touchTap"; - /** - * Dispatched when the user lifts the point of contact over the different DisplayObject instance on which the contact - * was initiated on a touch-enabled device (such as presses and releases a finger from a single point over a display - * object on a mobile phone or tablet with a touch screen). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 当用户在触摸设备上与开始触摸的不同 DisplayObject 实例上抬起接触点时调度。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static TOUCH_RELEASE_OUTSIDE: "touchReleaseOutside"; - /** - * Creates an Event object that contains information about touch events. - * @param type The type of the event, accessible as Event.type. - * @param bubbles Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false. - * @param cancelable Determines whether the Event object can be canceled. The default values is false. - * @param stageX The horizontal coordinate at which the event occurred in global Stage coordinates. - * @param stageY The vertical coordinate at which the event occurred in global Stage coordinates. - * @param touchPointID A unique identification number assigned to the touch point. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 TouchEvent 对象,其中包含有关Touch事件的信息 - * @param type 事件的类型,可以作为 Event.type 访问。 - * @param bubbles 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。 - * @param cancelable 确定是否可以取消 Event 对象。默认值为 false。 - * @param stageX 事件发生点在全局舞台坐标系中的水平坐标 - * @param stageY 事件发生点在全局舞台坐标系中的垂直坐标 - * @param touchPointID 分配给触摸点的唯一标识号 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(type: string, bubbles?: boolean, cancelable?: boolean, stageX?: number, stageY?: number, touchPointID?: number); - /** - * @private - */ - $initTo(stageX: number, stageY: number, touchPointID: number): void; - /** - * @private - */ - $stageX: number; - /** - * The horizontal coordinate at which the event occurred in global Stage coordinates. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 事件发生点在全局舞台坐标中的水平坐标。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly stageX: number; - /** - * @private - */ - $stageY: number; - /** - * The vertical coordinate at which the event occurred in global Stage coordinates. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 事件发生点在全局舞台坐标中的垂直坐标。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly stageY: number; - private _localX; - /** - * The horizontal coordinate at which the event occurred relative to the display object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 事件发生点相对于所属显示对象的水平坐标。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly localX: number; - private _localY; - /** - * The vertical coordinate at which the event occurred relative to the display object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 事件发生点相对于所属显示对象的垂直坐标。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly localY: number; - private targetChanged; - /** - * @private - */ - private getLocalXY(); - $setTarget(target: any): boolean; - /** - * A unique identification number assigned to the touch point. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 分配给触摸点的唯一标识号 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - touchPointID: number; - /** - * Instructs Egret runtime to render after processing of this event completes, if the display list has been modified. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 如果已修改显示列表,调用此方法将会忽略帧频限制,在此事件处理完成后立即重绘屏幕。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - updateAfterEvent(): void; - /** - * Whether the touch is pressed (true) or not pressed (false). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示触摸已按下 (true) 还是未按下 (false)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - touchDown: boolean; - /** - * uses a specified target to dispatchEvent an event. Using this method can reduce the number of - * reallocate event objects, which allows you to get better code execution performance. - * @param target the event target - * @param type The type of the event, accessible as Event.type. - * @param bubbles Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false. - * @param cancelable Determines whether the Event object can be canceled. The default values is false. - * @param stageX The horizontal coordinate at which the event occurred in global Stage coordinates. - * @param stageY The vertical coordinate at which the event occurred in global Stage coordinates. - * @param touchPointID A unique identification number (as an int) assigned to the touch point. - * - * @see egret.Event.create() - * @see egret.Event.release() - * - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 使用指定的EventDispatcher对象来抛出Event事件对象。抛出的对象将会缓存在对象池上,供下次循环复用。 - * @param target 派发事件目标 - * @param type 事件的类型,可以作为 Event.type 访问。 - * @param bubbles 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。 - * @param cancelable 确定是否可以取消 Event 对象。默认值为 false。 - * @param stageX 事件发生点在全局舞台坐标系中的水平坐标 - * @param stageY 事件发生点在全局舞台坐标系中的垂直坐标 - * @param touchPointID 分配给触摸点的唯一标识号 - * - * @see egret.Event.create() - * @see egret.Event.release() - * - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static dispatchTouchEvent(target: IEventDispatcher, type: string, bubbles?: boolean, cancelable?: boolean, stageX?: number, stageY?: number, touchPointID?: number, touchDown?: boolean): boolean; - } -} -declare namespace egret { - /** - * h5 and native interaction. - * @see http://edn.egret.com/cn/article/index/id/714 Egret basic skills to communicate with Native - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/external/ExternalInterface.ts - * @language en_US - */ - /** - * h5与native交互。 - * @see http://edn.egret.com/cn/article/index/id/714 Egret 与 Native 通信基本技巧 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/external/ExternalInterface.ts - * @language zh_CN - */ - interface ExternalInterface { - } - let ExternalInterface: { - /** - * Call functionName, and the value passed to the native. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 调用 functionName,并将value传入到native中。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - call(functionName: string, value: string): void; - /** - * FunctionName callback listener, you need to have to call functionName this field in native rather than such a call. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 监听 functionName 回调,需要在native中有调用 functionName 这个字段,而不是 此类的call。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - addCallback(functionName: string, listener: (value: string) => void): void; - }; -} -declare namespace egret { - /** - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - const enum BitmapFilterQuality { - /** - * 定义低品质滤镜设置 - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - LOW = 1, - /** - * 定义中等品质滤镜设置 - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - MEDIUM = 2, - /** - * 定义高品质滤镜设置 - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - HIGH = 3, - } -} -declare namespace egret { - /** - * The BlurFilter class lets you apply a blur visual effect to display objects. A blur effect softens the details of an image. - * You can produce blurs that range from a softly unfocused look to a Gaussian blur, a hazy appearance like viewing an image through semi-opaque glass. - * @version Egret 3.0.1 - * @platform Web - * @see http://edn.egret.com/cn/docs/page/947#模糊滤镜 模糊滤镜 - * @language en_US - */ - /** - * 可使用 BlurFilter 类将模糊视觉效果应用于显示对象。模糊效果可以柔化图像的细节。 - * 您可以生成一些模糊效果,范围从创建一个柔化的、未聚焦的外观到高斯模糊(就像通过半透明玻璃查看图像一样的朦胧的外观)。 - * @version Egret 3.1.0 - * @platform Web - * @see http://edn.egret.com/cn/docs/page/947#模糊滤镜 模糊滤镜 - * @language zh_CN - */ - class BlurFilter extends Filter { - /** - * Initializes a BlurFilter object. - * @param blurX {number} The amount of horizontal blur. Valid values are 0 to 255 (floating point). - * @param blurY {number} The amount of vertical blur. Valid values are 0 to 255 (floating point). - * @param quality {number} The number of times to apply the filter. - * @version Egret 3.1.0 - * @platform Web - * @language en_US - */ - /** - * 创建一个 BlurFilter 对象。 - * @param blurX {number} 水平模糊量。有效值为 0 到 255(浮点)。 - * @param blurY {number} 垂直模糊量。有效值为 0 到 255(浮点)。 - * @param quality {number} 应用滤镜的次数。暂未实现。 - * @version Egret 3.1.0 - * @platform Web - * @language zh_CN - */ - constructor(blurX?: number, blurY?: number, quality?: number); - /** - * @private - */ - blurXFilter: IBlurXFilter; - /** - * @private - */ - blurYFilter: IBlurYFilter; - /** - * @private - */ - $quality: number; - /** - * The amount of horizontal blur. - * @version Egret 3.1.0 - * @platform Web - * @language en_US - */ - /** - * 水平模糊量。 - * @version Egret 3.1.0 - * @platform Web - * @language zh_CN - */ - blurX: number; - /** - * @private - */ - $blurX: number; - /** - * The amount of vertical blur. - * @version Egret 3.1.0 - * @platform Web - * @language en_US - */ - /** - * 垂直模糊量。 - * @version Egret 3.1.0 - * @platform Web - * @language zh_CN - */ - blurY: number; - /** - * @private - */ - $blurY: number; - /** - * @private - */ - $toJson(): string; - protected updatePadding(): void; - onPropertyChange(): void; - } - /** - * @private - */ - interface IBlurXFilter extends Filter { - type: string; - $uniforms: any; - blurX: number; - } - /** - * @private - */ - interface IBlurYFilter extends Filter { - type: string; - $uniforms: any; - blurY: number; - } -} -declare namespace egret { - /** - * The ColorMatrixFilter class lets you apply a 4 x 5 matrix transformation on the RGBA color and alpha values of every pixel in the input image to produce a result with a new set of RGBA color and alpha values. - * It allows saturation changes, hue rotation, luminance to alpha, and various other effects. - * @version Egret 3.1.0 - * @platform Web - * @see http://edn.egret.com/cn/docs/page/947 颜色矩阵滤镜 - * @language en_US - */ - /** - * 使用 ColorMatrixFilter 类可以将 4 x 5 矩阵转换应用于输入图像上的每个像素的 RGBA 颜色和 Alpha 值,以生成具有一组新的 RGBA 颜色和 Alpha 值的结果。 - * 该类允许饱和度更改、色相旋转、亮度为 Alpha 以及各种其他效果。 - * @version Egret 3.1.0 - * @platform Web - * @see http://edn.egret.com/cn/docs/page/947 颜色矩阵滤镜 - * @language zh_CN - */ - class ColorMatrixFilter extends Filter { - /** - * @private - */ - $matrix: number[]; - /** - * @private - */ - private matrix2; - /** - * Initializes a ColorMatrixFilter object. - * @version Egret 3.1.0 - * @platform Web - * @language en_US - */ - /** - * 创建一个 ColorMatrixFilter 对象。 - * @version Egret 3.1.0 - * @platform Web - * @language zh_CN - */ - constructor(matrix?: number[]); - /** - * A comma delimited list of 20 doubles that comprise a 4x5 matrix applied to the rendered element. - * The matrix is in row major order -- that is, the first five elements are multipled by the vector [srcR,srcG,srcB,srcA,1] to determine the output red value, the second five determine the output green value, etc. - * The value must either be an array or comma delimited string of 20 numbers. - * @version Egret 3.1.0 - * @platform Web - * @language en_US - */ - /** - * 构成应用于所呈示的元素的一个 4x5 矩阵的、以逗号分隔的 20 个双精度数的列表。 - * 矩阵以行作为主要顺序,即用第一行五个元素乘以矢量 [srcR,srcG,srcB,srcA,1] 以确定输出的红色值,用第二行的五个元素确定输出的绿色值,等等。 - * 该值必须为 20 个数字组成的数组或以逗号分隔的字符串。 - * @version Egret 3.1.0 - * @platform Web - * @language zh_CN - */ - matrix: number[]; - /** - * @private - */ - private setMatrix(value); - /** - * @private - */ - $toJson(): string; - } -} -declare namespace egret { - /** - * custom filter, now support WebGL mode only. - * @version Egret 4.1.0 - * @platform Web - * @language en_US - */ - /** - * 自定义滤镜,目前仅支持WebGL模式 - * @version Egret 4.1.0 - * @platform Web - * @language zh_CN - */ - class CustomFilter extends Filter { - /** - * @private - */ - $vertexSrc: string; - /** - * @private - */ - $fragmentSrc: string; - /** - * @private - */ - $shaderKey: string; - /** - * @private - */ - type: string; - private $padding; - /** - * The inner margin of the filter. - * If the desired area of the custom filter is larger than the original area (stroke, etc.), you need to set it manually. - * @version Egret 4.1.0 - * @platform Web - * @language en_US - */ - /** - * 滤镜的内边距 - * 如果自定义滤镜所需区域比原区域大(描边等),需要手动设置 - * @version Egret 4.1.0 - * @platform Web - * @language zh_CN - */ - padding: number; - /** - * The initial value of the uniform in the shader (key, value one-to-one correspondence), currently only supports numbers and arrays. - * @version Egret 4.1.0 - * @platform Web - * @language en_US - */ - /** - * 着色器中uniform的初始值(key,value一一对应),目前仅支持数字和数组。 - * @version Egret 4.1.0 - * @platform Web - * @language zh_CN - */ - readonly uniforms: any; - /** - * Initialize the CustomFilter object. - * @param vertexSrc Custom vertex shader program. - * @param fragmentSrc Custom fragment shader program. - * @param uniforms The initial value of the uniform in the shader (key, value one-to-one correspondence), currently only supports numbers and arrays. - * @version Egret 4.1.0 - * @platform Web - * @language en_US - */ - /** - * 初始化 CustomFilter 对象 - * @param vertexSrc 自定义的顶点着色器程序。 - * @param fragmentSrc 自定义的片段着色器程序。 - * @param uniforms 着色器中uniform的初始值(key,value一一对应),目前仅支持数字和数组。 - * @version Egret 4.1.0 - * @platform Web - * @language zh_CN - */ - constructor(vertexSrc: string, fragmentSrc: string, uniforms?: any); - onPropertyChange(): void; - } -} -declare namespace egret { - /** - * @class egret.DropShadowFilter - * @classdesc - * 可使用 DropShadowFilter 类向显示对象添加投影。 - * @extends egret.GlowFilter - * @version Egret 3.1.4 - * @platform Web,Native - */ - class DropShadowFilter extends GlowFilter { - /** - * Initializes a new DropShadowFilter instance. - * @method egret.DropShadowFilter#constructor - * @param distance {number} The offset distance of the bevel. Valid values are in pixels (floating point). - * @param angle {number} The angle of the bevel. Valid values are from 0 to 360°. - * @param color {number} The color of the glow. Valid values are in the hexadecimal format 0xRRGGBB. The default value is 0xFF0000. - * @param alpha {number} The alpha transparency value for the color. Valid values are 0 to 1. For example, .25 sets a transparency value of 25%. The default value is 1. - * @param blurX {number} The amount of horizontal blur. Valid values are 0 to 255 (floating point). - * @param blurY {number} The amount of vertical blur. Valid values are 0 to 255 (floating point). - * @param strength {number} The strength of the imprint or spread. The higher the value, the more color is imprinted and the stronger the contrast between the glow and the background. Valid values are 0 to 255. - * @param quality {number} The number of times to apply the filter. - * @param inner {boolean} Specifies whether the glow is an inner glow. The value true indicates an inner glow. The default is false, an outer glow (a glow around the outer edges of the object). - * @param knockout {number} Specifies whether the object has a knockout effect. A value of true makes the object's fill transparent and reveals the background color of the document. The default value is false (no knockout effect). - * @param hideObject {number} Indicates whether or not the object is hidden. The value true indicates that the object itself is not drawn; only the shadow is visible. The default is false, meaning that the object is shown. - * @version Egret 3.1.4 - * @platform Web - * @language en_US - */ - /** - * 初始化 DropShadowFilter 对象 - * @method egret.DropShadowFilter#constructor - * @param distance {number} 阴影的偏移距离,以像素为单位。 - * @param angle {number} 阴影的角度,0 到 360 度(浮点)。 - * @param color {number} 光晕颜色,采用十六进制格式 0xRRGGBB。默认值为 0xFF0000。 - * @param alpha {number} 颜色的 Alpha 透明度值。有效值为 0 到 1。例如,0.25 设置透明度值为 25%。 - * @param blurX {number} 水平模糊量。有效值为 0 到 255(浮点)。 - * @param blurY {number} 垂直模糊量。有效值为 0 到 255(浮点)。 - * @param strength {number} 印记或跨页的强度。该值越高,压印的颜色越深,而且发光与背景之间的对比度也越强。有效值为 0 到 255。 - * @param quality {number} 应用滤镜的次数。暂未实现。 - * @param inner {boolean} 指定发光是否为内侧发光。值 true 指定发光是内侧发光。值 false 指定发光是外侧发光(对象外缘周围的发光)。 - * @param knockout {number} 指定对象是否具有挖空效果。值为 true 将使对象的填充变为透明,并显示文档的背景颜色。 - * @param hideObject {number} 表示是否隐藏对象。如果值为 true,则表示没有绘制对象本身,只有阴影是可见的。默认值为 false(显示对象)。 - * @version Egret 3.1.4 - * @platform Web - * @language zh_CN - */ - constructor(distance?: number, angle?: number, color?: number, alpha?: number, blurX?: number, blurY?: number, strength?: number, quality?: number, inner?: boolean, knockout?: boolean, hideObject?: boolean); - /** - * @private - */ - $distance: number; - /** - * The offset distance of the bevel. - * @version Egret 3.1.4 - * @platform Web - * @language en_US - */ - /** - * 阴影的偏移距离,以像素为单位。 - * @version Egret 3.1.4 - * @platform Web - * @language zh_CN - */ - distance: number; - /** - * @private - */ - $angle: number; - /** - * The angle of the bevel. - * @version Egret 3.1.4 - * @platform Web - * @language en_US - */ - /** - * 阴影的角度。 - * @version Egret 3.1.4 - * @platform Web - * @language zh_CN - */ - angle: number; - /** - * @private - */ - $hideObject: boolean; - /** - * Indicates whether or not the object is hidden. - * @version Egret 3.1.4 - * @platform Web - * @language en_US - */ - /** - * 表示是否隐藏对象。 - * @version Egret 3.1.4 - * @platform Web - * @language zh_CN - */ - hideObject: boolean; - /** - * @private - */ - $toJson(): string; - protected updatePadding(): void; - } -} -declare namespace egret { - /** - * The GradientType class provides values for the type parameter in the beginGradientFill() methods of the egret.Graphics class. - * - * @see egret.Graphics#beginGradientFill() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * GradientType 类为 egret.Graphics 类的 beginGradientFill() 方法中的 type 参数提供值。 - * - * @see egret.Graphics#beginGradientFill() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - class GradientType { - /** - * Value used to specify a linear gradient fill. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 用于指定线性渐变填充的值 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static LINEAR: string; - /** - * Value used to specify a radial gradient fill. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 用于指定放射状渐变填充的值 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static RADIAL: string; - } -} -declare namespace egret { - /** - * The Graphics class contains a set of methods for creating vector shape. Display objects that support drawing include Sprite and Shape objects. Each class in these classes includes the graphics attribute that is a Graphics object. - * The following auxiliary functions are provided for ease of use: drawRect(), drawRoundRect(), drawCircle(), and drawEllipse(). - * @see http://edn.egret.com/cn/docs/page/136 Draw Rectangle - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/Graphics.ts - * @language en_US - */ - /** - * Graphics 类包含一组可用来创建矢量形状的方法。支持绘制的显示对象包括 Sprite 和 Shape 对象。这些类中的每一个类都包括 graphics 属性,该属性是一个 Graphics 对象。 - * 以下是为便于使用而提供的一些辅助函数:drawRect()、drawRoundRect()、drawCircle() 和 drawEllipse()。 - * @see http://edn.egret.com/cn/docs/page/136 绘制矩形 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/Graphics.ts - * @language zh_CN - */ - class Graphics extends HashObject { - /** - * Initializes a Graphics object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 Graphics 对象。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(); - /** - * @private - */ - $renderNode: sys.GraphicsNode; - /** - * 绑定到的目标显示对象 - */ - $targetDisplay: DisplayObject; - $targetIsSprite: boolean; - /** - * @private - * 设置绑定到的目标显示对象 - */ - $setTarget(target: DisplayObject): void; - /** - * 当前移动到的坐标X - */ - private lastX; - /** - * 当前移动到的坐标Y - */ - private lastY; - /** - * 当前正在绘制的填充 - */ - private fillPath; - /** - * 当前正在绘制的线条 - */ - private strokePath; - /** - * 线条的左上方宽度 - */ - private topLeftStrokeWidth; - /** - * 线条的右下方宽度 - */ - private bottomRightStrokeWidth; - /** - * 对1像素和3像素特殊处理,向右下角偏移0.5像素,以显示清晰锐利的线条。 - */ - private setStrokeWidth(width); - /** - * Specify a simple single color fill that will be used for subsequent calls to other Graphics methods (for example, lineTo() and drawCircle()) when drawing. - * Calling the clear() method will clear the fill. - * @param color Filled color - * @param alpha Filled Alpha value - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 指定一种简单的单一颜色填充,在绘制时该填充将在随后对其他 Graphics 方法(如 lineTo() 或 drawCircle())的调用中使用。 - * 调用 clear() 方法会清除填充。 - * @param color 填充的颜色 - * @param alpha 填充的 Alpha 值 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - beginFill(color: number, alpha?: number): void; - /** - * Specifies a gradient fill used by subsequent calls to other Graphics methods (such as lineTo() or drawCircle()) for the object. - * Calling the clear() method clears the fill. - * @param type A value from the GradientType class that specifies which gradient type to use: GradientType.LINEAR or GradientType.RADIAL. - * @param colors An array of RGB hexadecimal color values used in the gradient; for example, red is 0xFF0000, blue is 0x0000FF, and so on. You can specify up to 15 colors. For each color, specify a corresponding value in the alphas and ratios parameters. - * @param alphas An array of alpha values for the corresponding colors in the colors array; - * @param ratios An array of color distribution ratios; valid values are 0-255. - * @param matrix A transformation matrix as defined by the egret.Matrix class. The egret.Matrix class includes a createGradientBox() method, which lets you conveniently set up the matrix for use with the beginGradientFill() method. - * @platform Web,Native - * @version Egret 2.4 - * @language en_US - */ - /** - * 指定一种渐变填充,用于随后调用对象的其他 Graphics 方法(如 lineTo() 或 drawCircle())。 - * 调用 clear() 方法会清除填充。 - * @param type 用于指定要使用哪种渐变类型的 GradientType 类的值:GradientType.LINEAR 或 GradientType.RADIAL。 - * @param colors 渐变中使用的 RGB 十六进制颜色值的数组(例如,红色为 0xFF0000,蓝色为 0x0000FF,等等)。对于每种颜色,请在 alphas 和 ratios 参数中指定对应值。 - * @param alphas colors 数组中对应颜色的 alpha 值数组。 - * @param ratios 颜色分布比率的数组。有效值为 0 到 255。 - * @param matrix 一个由 egret.Matrix 类定义的转换矩阵。egret.Matrix 类包括 createGradientBox() 方法,通过该方法可以方便地设置矩阵,以便与 beginGradientFill() 方法一起使用 - * @platform Web,Native - * @version Egret 2.4 - * @language zh_CN - */ - beginGradientFill(type: string, colors: number[], alphas: number[], ratios: number[], matrix?: egret.Matrix): void; - /** - * Apply fill to the lines and curves added after the previous calling to the beginFill() method. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 对从上一次调用 beginFill()方法之后添加的直线和曲线应用填充。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - endFill(): void; - /** - * Specify a line style that will be used for subsequent calls to Graphics methods such as lineTo() and drawCircle(). - * @param thickness An integer, indicating the thickness of the line in points. Valid values are 0 to 255. If a number is not specified, or if the parameter is undefined, a line is not drawn. If a value less than 0 is passed, the default value is 0. Value 0 indicates hairline thickness; the maximum thickness is 255. If a value greater than 255 is passed, the default value is 255. - * @param color A hexadecimal color value of the line (for example, red is 0xFF0000, and blue is 0x0000FF, etc.). If no value is specified, the default value is 0x000000 (black). Optional. - * @param alpha Indicates Alpha value of the line's color. Valid values are 0 to 1. If no value is specified, the default value is 1 (solid). If the value is less than 0, the default value is 0. If the value is greater than 1, the default value is 1. - * @param pixelHinting A boolean value that specifies whether to hint strokes to full pixels. This affects both the position of anchors of a curve and the line stroke size itself. With pixelHinting set to true, the line width is adjusted to full pixel width. With pixelHinting set to false, disjoints can appear for curves and straight lines. - * @param scaleMode Specifies the scale mode to be used - * @param caps Specifies the value of the CapsStyle class of the endpoint type at the end of the line. (default = CapsStyle.ROUND) - * @param joints Specifies the type of joint appearance of corner. (default = JointStyle.ROUND) - * @param miterLimit Indicates the limit number of cut miter. - * @param lineDash set the line dash. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 指定一种线条样式以用于随后对 lineTo() 或 drawCircle() 等 Graphics 方法的调用。 - * @param thickness 一个整数,以点为单位表示线条的粗细,有效值为 0 到 255。如果未指定数字,或者未定义该参数,则不绘制线条。如果传递的值小于 0,则默认值为 0。值 0 表示极细的粗细;最大粗细为 255。如果传递的值大于 255,则默认值为 255。 - * @param color 线条的十六进制颜色值(例如,红色为 0xFF0000,蓝色为 0x0000FF 等)。如果未指明值,则默认值为 0x000000(黑色)。可选。 - * @param alpha 表示线条颜色的 Alpha 值的数字;有效值为 0 到 1。如果未指明值,则默认值为 1(纯色)。如果值小于 0,则默认值为 0。如果值大于 1,则默认值为 1。 - * @param pixelHinting 布尔型值,指定是否提示笔触采用完整像素。它同时影响曲线锚点的位置以及线条笔触大小本身。在 pixelHinting 设置为 true 的情况下,线条宽度会调整到完整像素宽度。在 pixelHinting 设置为 false 的情况下,对于曲线和直线可能会出现脱节。 - * @param scaleMode 用于指定要使用的比例模式 - * @param caps 用于指定线条末端处端点类型的 CapsStyle 类的值。默认值:CapsStyle.ROUND - * @param joints 指定用于拐角的连接外观的类型。默认值:JointStyle.ROUND - * @param miterLimit 用于表示剪切斜接的极限值的数字。 - * @param lineDash 设置虚线样式。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - lineStyle(thickness?: number, color?: number, alpha?: number, pixelHinting?: boolean, scaleMode?: string, caps?: string, joints?: string, miterLimit?: number, lineDash?: number[]): void; - /** - * Draw a rectangle - * @param x x position of the center, relative to the registration point of the parent display object (in pixels). - * @param y y position of the center, relative to the registration point of the parent display object (in pixels). - * @param width Width of the rectangle (in pixels). - * @param height Height of the rectangle (in pixels). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 绘制一个矩形 - * @param x 圆心相对于父显示对象注册点的 x 位置(以像素为单位)。 - * @param y 相对于父显示对象注册点的圆心的 y 位置(以像素为单位)。 - * @param width 矩形的宽度(以像素为单位)。 - * @param height 矩形的高度(以像素为单位)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - drawRect(x: number, y: number, width: number, height: number): void; - /** - * Draw a rectangle with rounded corners. - * @param x x position of the center, relative to the registration point of the parent display object (in pixels). - * @param y y position of the center, relative to the registration point of the parent display object (in pixels). - * @param width Width of the rectangle (in pixels). - * @param height Height of the rectangle (in pixels). - * @param ellipseWidth Width used to draw an ellipse with rounded corners (in pixels). - * @param ellipseHeight Height used to draw an ellipse with rounded corners (in pixels). (Optional) If no value is specified, the default value matches the value of the ellipseWidth parameter. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 绘制一个圆角矩形。 - * @param x 圆心相对于父显示对象注册点的 x 位置(以像素为单位)。 - * @param y 相对于父显示对象注册点的圆心的 y 位置(以像素为单位)。 - * @param width 矩形的宽度(以像素为单位)。 - * @param height 矩形的高度(以像素为单位)。 - * @param ellipseWidth 用于绘制圆角的椭圆的宽度(以像素为单位)。 - * @param ellipseHeight 用于绘制圆角的椭圆的高度(以像素为单位)。 (可选)如果未指定值,则默认值与为 ellipseWidth 参数提供的值相匹配。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - drawRoundRect(x: number, y: number, width: number, height: number, ellipseWidth: number, ellipseHeight?: number): void; - /** - * Draw a circle. - * @param x x position of the center, relative to the registration point of the parent display object (in pixels). - * @param y y position of the center, relative to the registration point of the parent display object (in pixels). - * @param r Radius of the circle (in pixels). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 绘制一个圆。 - * @param x 圆心相对于父显示对象注册点的 x 位置(以像素为单位)。 - * @param y 相对于父显示对象注册点的圆心的 y 位置(以像素为单位)。 - * @param radius 圆的半径(以像素为单位)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - drawCircle(x: number, y: number, radius: number): void; - /** - * Draw an ellipse. - * @param x A number indicating the horizontal position, relative to the registration point of the parent display object (in pixels). - * @param y A number indicating the vertical position, relative to the registration point of the parent display object (in pixels). - * @param width Width of the rectangle (in pixels). - * @param height Height of the rectangle (in pixels). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 绘制一个椭圆。 - * @param x 一个表示相对于父显示对象注册点的水平位置的数字(以像素为单位)。 - * @param y 一个表示相对于父显示对象注册点的垂直位置的数字(以像素为单位)。 - * @param width 矩形的宽度(以像素为单位)。 - * @param height 矩形的高度(以像素为单位)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - drawEllipse(x: number, y: number, width: number, height: number): void; - /** - * Move the current drawing position to (x, y). If any of these parameters is missed, calling this method will fail and the current drawing position keeps unchanged. - * @param x A number indicating the horizontal position, relative to the registration point of the parent display object (in pixels). - * @param y A number indicating the vertical position, relative to the registration point of the parent display object (in pixels). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将当前绘图位置移动到 (x, y)。如果缺少任何一个参数,则此方法将失败,并且当前绘图位置不改变。 - * @param x 一个表示相对于父显示对象注册点的水平位置的数字(以像素为单位)。 - * @param y 一个表示相对于父显示对象注册点的垂直位置的数字(以像素为单位)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - moveTo(x: number, y: number): void; - /** - * Draw a straight line from the current drawing position to (x, y) using the current line style; the current drawing position is then set to (x, y). - * @param x A number indicating the horizontal position, relative to the registration point of the parent display object (in pixels). - * @param y A number indicating the vertical position, relative to the registration point of the parent display object (in pixels). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 使用当前线条样式绘制一条从当前绘图位置开始到 (x, y) 结束的直线;当前绘图位置随后会设置为 (x, y)。 - * @param x 一个表示相对于父显示对象注册点的水平位置的数字(以像素为单位)。 - * @param y 一个表示相对于父显示对象注册点的垂直位置的数字(以像素为单位)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - lineTo(x: number, y: number): void; - /** - * Draw a quadratic Bezier curve from the current drawing position to (anchorX, anchorY) using the current line style according to the control points specified by (controlX, controlY). The current drawing position is then set to (anchorX, anchorY). - * If the curveTo() method is called before the moveTo() method, the default value of the current drawing position is (0, 0). If any of these parameters is missed, calling this method will fail and the current drawing position keeps unchanged. - * The drawn curve is a quadratic Bezier curve. A quadratic Bezier curve contains two anchor points and one control point. The curve interpolates the two anchor points and bends to the control point. - * @param controlX A number indicating the horizontal position of the control point, relative to the registration point of the parent display object. - * @param controlY A number indicating the vertical position of the control point, relative to the registration point of the parent display object. - * @param anchorX A number indicating the horizontal position of the next anchor point, relative to the registration point of the parent display object. - * @param anchorY A number indicating the vertical position of the next anchor point, relative to the registration point of the parent display object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 使用当前线条样式和由 (controlX, controlY) 指定的控制点绘制一条从当前绘图位置开始到 (anchorX, anchorY) 结束的二次贝塞尔曲线。当前绘图位置随后设置为 (anchorX, anchorY)。 - * 如果在调用 moveTo() 方法之前调用了 curveTo() 方法,则当前绘图位置的默认值为 (0, 0)。如果缺少任何一个参数,则此方法将失败,并且当前绘图位置不改变。 - * 绘制的曲线是二次贝塞尔曲线。二次贝塞尔曲线包含两个锚点和一个控制点。该曲线内插这两个锚点,并向控制点弯曲。 - * @param controlX 一个数字,指定控制点相对于父显示对象注册点的水平位置。 - * @param controlY 一个数字,指定控制点相对于父显示对象注册点的垂直位置。 - * @param anchorX 一个数字,指定下一个锚点相对于父显示对象注册点的水平位置。 - * @param anchorY 一个数字,指定下一个锚点相对于父显示对象注册点的垂直位置。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - curveTo(controlX: number, controlY: number, anchorX: number, anchorY: number): void; - /** - * Draws a cubic Bezier curve from the current drawing position to the specified anchor. Cubic Bezier curves consist of two anchor points and two control points. The curve interpolates the two anchor points and two control points to the curve. - * @param controlX1 Specifies the first control point relative to the registration point of the parent display the horizontal position of the object. - * @param controlY1 Specifies the first control point relative to the registration point of the parent display the vertical position of the object. - * @param controlX2 Specify the second control point relative to the registration point of the parent display the horizontal position of the object. - * @param controlY2 Specify the second control point relative to the registration point of the parent display the vertical position of the object. - * @param anchorX Specifies the anchor point relative to the registration point of the parent display the horizontal position of the object. - * @param anchorY Specifies the anchor point relative to the registration point of the parent display the vertical position of the object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从当前绘图位置到指定的锚点绘制一条三次贝塞尔曲线。三次贝塞尔曲线由两个锚点和两个控制点组成。该曲线内插这两个锚点,并向两个控制点弯曲。 - * @param controlX1 指定首个控制点相对于父显示对象的注册点的水平位置。 - * @param controlY1 指定首个控制点相对于父显示对象的注册点的垂直位置。 - * @param controlX2 指定第二个控制点相对于父显示对象的注册点的水平位置。 - * @param controlY2 指定第二个控制点相对于父显示对象的注册点的垂直位置。 - * @param anchorX 指定锚点相对于父显示对象的注册点的水平位置。 - * @param anchorY 指定锚点相对于父显示对象的注册点的垂直位置。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - cubicCurveTo(controlX1: number, controlY1: number, controlX2: number, controlY2: number, anchorX: number, anchorY: number): void; - /** - * adds an arc to the path which is centered at (x, y) position with radius r starting at startAngle and ending - * at endAngle going in the given direction by anticlockwise (defaulting to clockwise). - * @param x The x coordinate of the arc's center. - * @param y The y coordinate of the arc's center. - * @param radius The arc's radius. - * @param startAngle The angle at which the arc starts, measured clockwise from the positive x axis and expressed in radians. - * @param endAngle The angle at which the arc ends, measured clockwise from the positive x axis and expressed in radians. - * @param anticlockwise if true, causes the arc to be drawn counter-clockwise between the two angles. By default it is drawn clockwise. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 绘制一段圆弧路径。圆弧路径的圆心在 (x, y) 位置,半径为 r ,根据anticlockwise (默认为顺时针)指定的方向从 startAngle 开始绘制,到 endAngle 结束。 - * @param x 圆弧中心(圆心)的 x 轴坐标。 - * @param y 圆弧中心(圆心)的 y 轴坐标。 - * @param radius 圆弧的半径。 - * @param startAngle 圆弧的起始点, x轴方向开始计算,单位以弧度表示。 - * @param endAngle 圆弧的终点, 单位以弧度表示。 - * @param anticlockwise 如果为 true,逆时针绘制圆弧,反之,顺时针绘制。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - drawArc(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: boolean): void; - private dirty(); - /** - * @private - * 测量圆弧的矩形大小 - */ - private arcBounds(x, y, radius, startAngle, endAngle); - /** - * Clear graphics that are drawn to this Graphics object, and reset fill and line style settings. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 清除绘制到此 Graphics 对象的图形,并重置填充和线条样式设置。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - clear(): void; - /** - * @private - */ - private minX; - /** - * @private - */ - private minY; - /** - * @private - */ - private maxX; - /** - * @private - */ - private maxY; - /** - * @private - */ - private extendBoundsByPoint(x, y); - /** - * @private - */ - private extendBoundsByX(x); - /** - * @private - */ - private extendBoundsByY(y); - /** - * @private - */ - private updateNodeBounds(); - /** - * 是否已经包含上一次moveTo的坐标点 - */ - private includeLastPosition; - /** - * 更新当前的lineX和lineY值,并标记尺寸失效。 - * @private - */ - private updatePosition(x, y); - /** - * @private - */ - $measureContentBounds(bounds: Rectangle): void; - /** - * @private - * - */ - $hitTest(stageX: number, stageY: number): DisplayObject; - /** - * @private - */ - $onRemoveFromStage(): void; - } -} -declare namespace egret { - /** - * The Matrix class represents a transformation matrix that determines how to map points from one coordinate space to - * another. You can perform various graphical transformations on a display object by setting the properties of a Matrix - * object, applying that Matrix object to the matrix property of a display object, These transformation functions include - * translation (x and y repositioning), rotation, scaling, and skewing. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/geom/Matrix.ts - * @language en_US - */ - /** - * Matrix 类表示一个转换矩阵,它确定如何将点从一个坐标空间映射到另一个坐标空间。 - * 您可以对一个显示对象执行不同的图形转换,方法是设置 Matrix 对象的属性,将该 Matrix - * 对象应用于显示对象的 matrix 属性。这些转换函数包括平移(x 和 y 重新定位)、旋转、缩放和倾斜。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/geom/Matrix.ts - * @language zh_CN - */ - class Matrix extends HashObject { - /** - * Releases a matrix instance to the object pool - * @param matrix matrix that Needs to be recycled - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 释放一个Matrix实例到对象池 - * @param matrix 需要回收的 matrix - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static release(matrix: Matrix): void; - /** - * get a matrix instance from the object pool or create a new one. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从对象池中取出或创建一个新的Matrix对象。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static create(): Matrix; - /** - * Creates a new Matrix object with the specified parameters. - * @param a The value that affects the positioning of pixels along the x axis when scaling or rotating an image. - * @param b The value that affects the positioning of pixels along the y axis when rotating or skewing an image. - * @param c The value that affects the positioning of pixels along the x axis when rotating or skewing an image. - * @param d The value that affects the positioning of pixels along the y axis when scaling or rotating an image.. - * @param tx The distance by which to translate each point along the x axis. - * @param ty The distance by which to translate each point along the y axis. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 使用指定参数创建一个 Matrix 对象 - * @param a 缩放或旋转图像时影响像素沿 x 轴定位的值。 - * @param b 旋转或倾斜图像时影响像素沿 y 轴定位的值。 - * @param c 旋转或倾斜图像时影响像素沿 x 轴定位的值。 - * @param d 缩放或旋转图像时影响像素沿 y 轴定位的值。 - * @param tx 沿 x 轴平移每个点的距离。 - * @param ty 沿 y 轴平移每个点的距离。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(a?: number, b?: number, c?: number, d?: number, tx?: number, ty?: number); - /** - * The value that affects the positioning of pixels along the x axis when scaling or rotating an image. - * @default 1 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 缩放或旋转图像时影响像素沿 x 轴定位的值 - * @default 1 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - a: number; - /** - * The value that affects the positioning of pixels along the y axis when rotating or skewing an image. - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 旋转或倾斜图像时影响像素沿 y 轴定位的值 - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - b: number; - /** - * The value that affects the positioning of pixels along the x axis when rotating or skewing an image. - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 旋转或倾斜图像时影响像素沿 x 轴定位的值 - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - c: number; - /** - * The value that affects the positioning of pixels along the y axis when scaling or rotating an image. - * @default 1 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 缩放或旋转图像时影响像素沿 y 轴定位的值 - * @default 1 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - d: number; - /** - * The distance by which to translate each point along the x axis. - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 沿 x 轴平移每个点的距离 - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - tx: number; - /** - * The distance by which to translate each point along the y axis. - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 沿 y 轴平移每个点的距离 - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - ty: number; - /** - * Returns a new Matrix object that is a clone of this matrix, with an exact copy of the contained object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 返回一个新的 Matrix 对象,它是此矩阵的克隆,带有与所含对象完全相同的副本。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - clone(): Matrix; - /** - * Concatenates a matrix with the current matrix, effectively combining the geometric effects of the two. In mathematical - * terms, concatenating two matrixes is the same as combining them using matrix multiplication. - * @param other The matrix to be concatenated to the source matrix. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将某个矩阵与当前矩阵连接,从而将这两个矩阵的几何效果有效地结合在一起。在数学术语中,将两个矩阵连接起来与使用矩阵乘法将它们结合起来是相同的。 - * @param other 要连接到源矩阵的矩阵。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - concat(other: Matrix): void; - /** - * Copies all of the matrix data from the source Point object into the calling Matrix object. - * @param other The Matrix object from which to copy the data. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将源 Matrix 对象中的所有矩阵数据复制到调用方 Matrix 对象中。 - * @param other 要拷贝的目标矩阵 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - copyFrom(other: Matrix): Matrix; - /** - * Sets each matrix property to a value that causes a null transformation. An object transformed by applying an - * identity matrix will be identical to the original. After calling the identity() method, the resulting matrix - * has the following properties: a=1, b=0, c=0, d=1, tx=0, ty=0. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 为每个矩阵属性设置一个值,该值将导致矩阵无转换。通过应用恒等矩阵转换的对象将与原始对象完全相同。 - * 调用 identity() 方法后,生成的矩阵具有以下属性:a=1、b=0、c=0、d=1、tx=0 和 ty=0。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - identity(): void; - /** - * Performs the opposite transformation of the original matrix. You can apply an inverted matrix to an object to - * undo the transformation performed when applying the original matrix. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 执行原始矩阵的逆转换。 - * 您可以将一个逆矩阵应用于对象来撤消在应用原始矩阵时执行的转换。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - invert(): void; - /** - * @private - */ - $invertInto(target: Matrix): void; - /** - * Applies a rotation transformation to the Matrix object. - * The rotate() method alters the a, b, c, and d properties of the Matrix object. - * @param angle The rotation angle in radians. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 对 Matrix 对象应用旋转转换。 - * rotate() 方法将更改 Matrix 对象的 a、b、c 和 d 属性。 - * @param angle 以弧度为单位的旋转角度。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - rotate(angle: number): void; - /** - * Applies a scaling transformation to the matrix. The x axis is multiplied by sx, and the y axis it is multiplied by sy. - * The scale() method alters the a and d properties of the Matrix object. - * @param sx A multiplier used to scale the object along the x axis. - * @param sy A multiplier used to scale the object along the y axis. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 对矩阵应用缩放转换。x 轴乘以 sx,y 轴乘以 sy。 - * scale() 方法将更改 Matrix 对象的 a 和 d 属性。 - * @param sx 用于沿 x 轴缩放对象的乘数。 - * @param sy 用于沿 y 轴缩放对象的乘数。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - scale(sx: number, sy: number): void; - /** - * Sets the members of Matrix to the specified values - * @param a The value that affects the positioning of pixels along the x axis when scaling or rotating an image. - * @param b The value that affects the positioning of pixels along the y axis when rotating or skewing an image. - * @param c The value that affects the positioning of pixels along the x axis when rotating or skewing an image. - * @param d The value that affects the positioning of pixels along the y axis when scaling or rotating an image.. - * @param tx The distance by which to translate each point along the x axis. - * @param ty The distance by which to translate each point along the y axis. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将 Matrix 的成员设置为指定值 - * @param a 缩放或旋转图像时影响像素沿 x 轴定位的值。 - * @param b 旋转或倾斜图像时影响像素沿 y 轴定位的值。 - * @param c 旋转或倾斜图像时影响像素沿 x 轴定位的值。 - * @param d 缩放或旋转图像时影响像素沿 y 轴定位的值。 - * @param tx 沿 x 轴平移每个点的距离。 - * @param ty 沿 y 轴平移每个点的距离。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - setTo(a: number, b: number, c: number, d: number, tx: number, ty: number): Matrix; - /** - * Returns the result of applying the geometric transformation represented by the Matrix object to the specified point. - * @param pointX The x coordinate for which you want to get the result of the Matrix transformation. - * @param pointY The y coordinate for which you want to get the result of the Matrix transformation. - * @param resultPoint A reusable instance of Point for saving the results. Passing this parameter can reduce the - * number of reallocate objects, which allows you to get better code execution performance. - * @returns The point resulting from applying the Matrix transformation. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 返回将 Matrix 对象表示的几何转换应用于指定点所产生的结果。 - * @param pointX 想要获得其矩阵转换结果的点的x坐标。 - * @param pointY 想要获得其矩阵转换结果的点的y坐标。 - * @param resultPoint 框架建议尽可能减少创建对象次数来优化性能,可以从外部传入一个复用的Point对象来存储结果,若不传入将创建一个新的Point对象返回。 - * @returns 由应用矩阵转换所产生的点。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - transformPoint(pointX: number, pointY: number, resultPoint?: Point): Point; - /** - * Translates the matrix along the x and y axes, as specified by the dx and dy parameters. - * @param dx The amount of movement along the x axis to the right, in pixels. - * @param dy The amount of movement down along the y axis, in pixels. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 沿 x 和 y 轴平移矩阵,由 dx 和 dy 参数指定。 - * @param dx 沿 x 轴向右移动的量(以像素为单位)。 - * @param dy 沿 y 轴向下移动的量(以像素为单位)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - translate(dx: number, dy: number): void; - /** - * Determines whether two matrixes are equal. - * @param other The matrix to be compared. - * @returns A value of true if the object is equal to this Matrix object; false if it is not equal. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 是否与另一个矩阵数据相等 - * @param other 要比较的另一个矩阵对象。 - * @returns 是否相等,ture表示相等。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - equals(other: Matrix): boolean; - /** - * prepend matrix - * @param a The value that affects the positioning of pixels along the x axis when scaling or rotating an image. - * @param b The value that affects the positioning of pixels along the y axis when rotating or skewing an image. - * @param c The value that affects the positioning of pixels along the x axis when rotating or skewing an image. - * @param d The value that affects the positioning of pixels along the y axis when scaling or rotating an image.. - * @param tx The distance by which to translate each point along the x axis. - * @param ty The distance by which to translate each point along the y axis. - * @returns matrix - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 前置矩阵 - * @param a 缩放或旋转图像时影响像素沿 x 轴定位的值 - * @param b 缩放或旋转图像时影响像素沿 y 轴定位的值 - * @param c 缩放或旋转图像时影响像素沿 x 轴定位的值 - * @param d 缩放或旋转图像时影响像素沿 y 轴定位的值 - * @param tx 沿 x 轴平移每个点的距离 - * @param ty 沿 y 轴平移每个点的距离 - * @returns 矩阵自身 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - prepend(a: number, b: number, c: number, d: number, tx: number, ty: number): Matrix; - /** - * append matrix - * @param a The value that affects the positioning of pixels along the x axis when scaling or rotating an image. - * @param b The value that affects the positioning of pixels along the y axis when rotating or skewing an image. - * @param c The value that affects the positioning of pixels along the x axis when rotating or skewing an image. - * @param d The value that affects the positioning of pixels along the y axis when scaling or rotating an image.. - * @param tx The distance by which to translate each point along the x axis. - * @param ty The distance by which to translate each point along the y axis. - * @returns matrix - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 后置矩阵 - * @param a 缩放或旋转图像时影响像素沿 x 轴定位的值 - * @param b 缩放或旋转图像时影响像素沿 y 轴定位的值 - * @param c 缩放或旋转图像时影响像素沿 x 轴定位的值 - * @param d 缩放或旋转图像时影响像素沿 y 轴定位的值 - * @param tx 沿 x 轴平移每个点的距离 - * @param ty 沿 y 轴平移每个点的距离 - * @returns 矩阵自身 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - append(a: number, b: number, c: number, d: number, tx: number, ty: number): Matrix; - /** - * Given a point in the pretransform coordinate space, returns the coordinates of that point after the transformation occurs. - * Unlike the standard transformation applied using the transformPoint() method, the deltaTransformPoint() method's transformation does not consider the translation parameters tx and ty. - * @param point The point for which you want to get the result of the matrix transformation. - * @returns The point resulting from applying the matrix transformation. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 如果给定预转换坐标空间中的点,则此方法返回发生转换后该点的坐标。 - * 与使用 transformPoint() 方法应用的标准转换不同,deltaTransformPoint() 方法的转换不考虑转换参数 tx 和 ty。 - * @param point 想要获得其矩阵转换结果的点 - * @returns 由应用矩阵转换所产生的点 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - deltaTransformPoint(point: Point): Point; - /** - * Returns a text value listing the properties of the Matrix object. - * @returns A string containing the values of the properties of the Matrix object: a, b, c, d, tx, and ty. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 返回将 Matrix 对象表示的几何转换应用于指定点所产生的结果。 - * @returns 一个字符串,它包含 Matrix 对象的属性值:a、b、c、d、tx 和 ty。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - toString(): string; - /** - * Includes parameters for scaling, rotation, and translation. When applied to a matrix it sets the matrix's values based on those parameters. - * @param scaleX The factor by which to scale horizontally. - * @param scaleY The factor by which scale vertically. - * @param rotation The amount to rotate, in radians. - * @param tx The number of pixels to translate (move) to the right along the x axis. - * @param ty The number of pixels to translate (move) down along the y axis. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 包括用于缩放、旋转和转换的参数。当应用于矩阵时,该方法会基于这些参数设置矩阵的值。 - * @param scaleX 水平缩放所用的系数 - * @param scaleY 垂直缩放所用的系数 - * @param rotation 旋转量(以弧度为单位) - * @param tx 沿 x 轴向右平移(移动)的像素数 - * @param ty 沿 y 轴向下平移(移动)的像素数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - createBox(scaleX: number, scaleY: number, rotation?: number, tx?: number, ty?: number): void; - /** - * Creates the specific style of matrix expected by the beginGradientFill() and lineGradientStyle() methods of the Graphics class. - * Width and height are scaled to a scaleX/scaleY pair and the tx/ty values are offset by half the width and height. - * @param width The width of the gradient box. - * @param height The height of the gradient box. - * @param rotation The amount to rotate, in radians. - * @param tx The distance, in pixels, to translate to the right along the x axis. This value is offset by half of the width parameter. - * @param ty The distance, in pixels, to translate down along the y axis. This value is offset by half of the height parameter. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建 Graphics 类的 beginGradientFill() 和 lineGradientStyle() 方法所需的矩阵的特定样式。 - * 宽度和高度被缩放为 scaleX/scaleY 对,而 tx/ty 值偏移了宽度和高度的一半。 - * @param width 渐变框的宽度 - * @param height 渐变框的高度 - * @param rotation 旋转量(以弧度为单位) - * @param tx 沿 x 轴向右平移的距离(以像素为单位)。此值将偏移 width 参数的一半 - * @param ty 沿 y 轴向下平移的距离(以像素为单位)。此值将偏移 height 参数的一半 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - createGradientBox(width: number, height: number, rotation?: number, tx?: number, ty?: number): void; - /** - * @private - */ - $transformBounds(bounds: Rectangle): void; - /** - * @private - */ - private getDeterminant(); - /** - * @private - */ - $getScaleX(): number; - /** - * @private - */ - $getScaleY(): number; - /** - * @private - */ - $getSkewX(): number; - /** - * @private - */ - $getSkewY(): number; - /** - * @private - */ - $updateScaleAndRotation(scaleX: number, scaleY: number, skewX: number, skewY: number): void; - /** - * @private - * target = other * this - */ - $preMultiplyInto(other: Matrix, target: Matrix): void; - } - /** - * @private - * 仅供框架内复用,要防止暴露引用到外部。 - */ - let $TempMatrix: Matrix; -} -declare namespace egret { - /** - * A Rectangle object is an area defined by its position, as indicated by its top-left corner point (x, y) and by its - * width and its height.
- * The x, y, width, and height properties of the Rectangle class are independent of each other; changing the value of - * one property has no effect on the others. However, the right and bottom properties are integrally related to those - * four properties. For example, if you change the value of the right property, the value of the width property changes; - * if you change the bottom property, the value of the height property changes. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/geom/Rectangle.ts - * @language en_US - */ - /** - * Rectangle 对象是按其位置(由它左上角的点 (x, y) 确定)以及宽度和高度定义的区域。
- * Rectangle 类的 x、y、width 和 height 属性相互独立;更改一个属性的值不会影响其他属性。 - * 但是,right 和 bottom 属性与这四个属性是整体相关的。例如,如果更改 right 属性的值,则 width - * 属性的值将发生变化;如果更改 bottom 属性,则 height 属性的值将发生变化。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/geom/Rectangle.ts - * @language zh_CN - */ - class Rectangle extends HashObject { - /** - * Releases a rectangle instance to the object pool. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 释放一个Rectangle实例到对象池 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static release(rect: Rectangle): void; - /** - * get a rectangle instance from the object pool or create a new one. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从对象池中取出或创建一个新的Rectangle对象。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static create(): Rectangle; - /** - * Creates a new Rectangle object with the top-left corner specified by the x and y parameters and with the specified - * width and height parameters. - * @param x The x coordinate of the top-left corner of the rectangle. - * @param y The y coordinate of the top-left corner of the rectangle. - * @param width The width of the rectangle, in pixels. - * @param height The height of the rectangle, in pixels. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个新 Rectangle 对象,其左上角由 x 和 y 参数指定,并具有指定的 width 和 height 参数。 - * @param x 矩形左上角的 x 坐标。 - * @param y 矩形左上角的 y 坐标。 - * @param width 矩形的宽度(以像素为单位)。 - * @param height 矩形的高度(以像素为单位)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(x?: number, y?: number, width?: number, height?: number); - /** - * The x coordinate of the top-left corner of the rectangle. - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 矩形左上角的 x 坐标。 - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - x: number; - /** - * The y coordinate of the top-left corner of the rectangle. - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 矩形左上角的 y 坐标。 - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - y: number; - /** - * The width of the rectangle, in pixels. - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 矩形的宽度(以像素为单位)。 - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - width: number; - /** - * 矩形的高度(以像素为单位)。 - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * The height of the rectangle, in pixels. - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - height: number; - /** - * The sum of the x and width properties. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * x 和 width 属性的和。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - right: number; - /** - * The sum of the y and height properties. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * y 和 height 属性的和。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - bottom: number; - /** - * The x coordinate of the top-left corner of the rectangle. Changing the left property of a Rectangle object has - * no effect on the y and height properties. However it does affect the width property, whereas changing the x value - * does not affect the width property. - * The value of the left property is equal to the value of the x property. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 矩形左上角的 x 坐标。更改 Rectangle 对象的 left 属性对 y 和 height 属性没有影响。但是,它会影响 width 属性,而更改 x 值不会影响 width 属性。 - * left 属性的值等于 x 属性的值。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - left: number; - /** - * The y coordinate of the top-left corner of the rectangle. Changing the top property of a Rectangle object has - * no effect on the x and width properties. However it does affect the height property, whereas changing the y - * value does not affect the height property.
- * The value of the top property is equal to the value of the y property. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 矩形左上角的 y 坐标。更改 Rectangle 对象的 top 属性对 x 和 width 属性没有影响。但是,它会影响 height 属性,而更改 y 值不会影响 height 属性。
- * top 属性的值等于 y 属性的值。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - top: number; - /** - * The location of the Rectangle object's top-left corner, determined by the x and y coordinates of the point. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 由该点的 x 和 y 坐标确定的 Rectangle 对象左上角的位置。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - topLeft: Point; - /** - * The location of the Rectangle object's bottom-right corner, determined by the values of the right and bottom properties. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 由 right 和 bottom 属性的值确定的 Rectangle 对象的右下角的位置。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - bottomRight: Point; - /** - * Copies all of rectangle data from the source Rectangle object into the calling Rectangle object. - * @param sourceRect The Rectangle object from which to copy the data. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将源 Rectangle 对象中的所有矩形数据复制到调用方 Rectangle 对象中。 - * @param sourceRect 要从中复制数据的 Rectangle 对象。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - copyFrom(sourceRect: Rectangle): Rectangle; - /** - * Sets the members of Rectangle to the specified values - * @param x The x coordinate of the top-left corner of the rectangle. - * @param y The y coordinate of the top-left corner of the rectangle. - * @param width The width of the rectangle, in pixels. - * @param height The height of the rectangle, in pixels. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将 Rectangle 的成员设置为指定值 - * @param x 矩形左上角的 x 坐标。 - * @param y 矩形左上角的 y 坐标。 - * @param width 矩形的宽度(以像素为单位)。 - * @param height 矩形的高度(以像素为单位)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - setTo(x: number, y: number, width: number, height: number): Rectangle; - /** - * Determines whether the specified point is contained within the rectangular region defined by this Rectangle object. - * @param x The x coordinate (horizontal position) of the point. - * @param y The y coordinate (vertical position) of the point. - * @returns A value of true if the Rectangle object contains the specified point; otherwise false. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 确定由此 Rectangle 对象定义的矩形区域内是否包含指定的点。 - * @param x 检测点的x轴 - * @param y 检测点的y轴 - * @returns 如果检测点位于矩形内,返回true,否则,返回false - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - contains(x: number, y: number): boolean; - /** - * If the Rectangle object specified in the toIntersect parameter intersects with this Rectangle object, returns - * the area of intersection as a Rectangle object. If the rectangles do not intersect, this method returns an empty - * Rectangle object with its properties set to 0. - * @param toIntersect The Rectangle object to compare against to see if it intersects with this Rectangle object. - * @returns A Rectangle object that equals the area of intersection. If the rectangles do not intersect, this method - * returns an empty Rectangle object; that is, a rectangle with its x, y, width, and height properties set to 0. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 如果在 toIntersect 参数中指定的 Rectangle 对象与此 Rectangle 对象相交,则返回交集区域作为 Rectangle 对象。如果矩形不相交, - * 则此方法返回一个空的 Rectangle 对象,其属性设置为 0。 - * @param toIntersect 要对照比较以查看其是否与此 Rectangle 对象相交的 Rectangle 对象。 - * @returns 等于交集区域的 Rectangle 对象。如果该矩形不相交,则此方法返回一个空的 Rectangle 对象;即,其 x、y、width 和 - * height 属性均设置为 0 的矩形。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - intersection(toIntersect: Rectangle): Rectangle; - /** - * Increases the size of the Rectangle object by the specified amounts, in pixels. - * The center point of the Rectangle object stays the same, and its size increases to the left and right by the dx value, and to the top and the bottom by the dy value. - * @param dx The value to be added to the left and the right of the Rectangle object. - * @param dy The value to be added to the top and the bottom of the Rectangle. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 按指定量增加 Rectangle 对象的大小(以像素为单位) - * 保持 Rectangle 对象的中心点不变,使用 dx 值横向增加它的大小,使用 dy 值纵向增加它的大小。 - * @param dx Rectangle 对象横向增加的值。 - * @param dy Rectangle 对象纵向增加的值。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - inflate(dx: number, dy: number): void; - /** - * @private - */ - $intersectInPlace(clipRect: Rectangle): Rectangle; - /** - * Determines whether the object specified in the toIntersect parameter intersects with this Rectangle object. - * This method checks the x, y, width, and height properties of the specified Rectangle object to see if it - * intersects with this Rectangle object. - * @param toIntersect The Rectangle object to compare against this Rectangle object. - * @returns A value of true if the specified object intersects with this Rectangle object; otherwise false. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 确定在 toIntersect 参数中指定的对象是否与此 Rectangle 对象相交。此方法检查指定的 Rectangle - * 对象的 x、y、width 和 height 属性,以查看它是否与此 Rectangle 对象相交。 - * @param toIntersect 要与此 Rectangle 对象比较的 Rectangle 对象。 - * @returns 如果两个矩形相交,返回true,否则返回false - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - intersects(toIntersect: Rectangle): boolean; - /** - * Determines whether or not this Rectangle object is empty. - * @returns A value of true if the Rectangle object's width or height is less than or equal to 0; otherwise false. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 确定此 Rectangle 对象是否为空。 - * @returns 如果 Rectangle 对象的宽度或高度小于等于 0,则返回 true 值,否则返回 false。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - isEmpty(): boolean; - /** - * Sets all of the Rectangle object's properties to 0. A Rectangle object is empty if its width or height is less than or equal to 0. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将 Rectangle 对象的所有属性设置为 0。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - setEmpty(): void; - /** - * Returns a new Rectangle object with the same values for the x, y, width, and height properties as the original Rectangle object. - * @returns A new Rectangle object with the same values for the x, y, width, and height properties as the original Rectangle object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 返回一个新的 Rectangle 对象,其 x、y、width 和 height 属性的值与原始 Rectangle 对象的对应值相同。 - * @returns 新的 Rectangle 对象,其 x、y、width 和 height 属性的值与原始 Rectangle 对象的对应值相同。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - clone(): Rectangle; - /** - * Determines whether the specified point is contained within the rectangular region defined by this Rectangle object. - * This method is similar to the Rectangle.contains() method, except that it takes a Point object as a parameter. - * @param point The point, as represented by its x and y coordinates. - * @returns A value of true if the Rectangle object contains the specified point; otherwise false. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 确定由此 Rectangle 对象定义的矩形区域内是否包含指定的点。 - * 此方法与 Rectangle.contains() 方法类似,只不过它采用 Point 对象作为参数。 - * @param point 包含点对象 - * @returns 如果包含,返回true,否则返回false - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - containsPoint(point: Point): boolean; - /** - * Determines whether the Rectangle object specified by the rect parameter is contained within this Rectangle object. - * A Rectangle object is said to contain another if the second Rectangle object falls entirely within the boundaries of the first. - * @param rect The Rectangle object being checked. - * @returns A value of true if the Rectangle object that you specify is contained by this Rectangle object; otherwise false. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 确定此 Rectangle 对象内是否包含由 rect 参数指定的 Rectangle 对象。 - * 如果一个 Rectangle 对象完全在另一个 Rectangle 的边界内,我们说第二个 Rectangle 包含第一个 Rectangle。 - * @param rect 所检查的 Rectangle 对象 - * @returns 如果此 Rectangle 对象包含您指定的 Rectangle 对象,则返回 true 值,否则返回 false。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - containsRect(rect: egret.Rectangle): boolean; - /** - * Determines whether the object specified in the toCompare parameter is equal to this Rectangle object. - * This method compares the x, y, width, and height properties of an object against the same properties of this Rectangle object. - * @param The rectangle to compare to this Rectangle object. - * @returns A value of true if the object has exactly the same values for the x, y, width, and height properties as this Rectangle object; otherwise false. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 确定在 toCompare 参数中指定的对象是否等于此 Rectangle 对象。 - * 此方法将某个对象的 x、y、width 和 height 属性与此 Rectangle 对象所对应的相同属性进行比较。 - * @param toCompare 要与此 Rectangle 对象进行比较的矩形。 - * @returns 如果对象具有与此 Rectangle 对象完全相同的 x、y、width 和 height 属性值,则返回 true 值,否则返回 false。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - equals(toCompare: Rectangle): boolean; - /** - * Increases the size of the Rectangle object. This method is similar to the Rectangle.inflate() method except it takes a Point object as a parameter. - * @param point 此 Point 对象的 x 属性用于增加 Rectangle 对象的水平尺寸。y 属性用于增加 Rectangle 对象的垂直尺寸。 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 增加 Rectangle 对象的大小。此方法与 Rectangle.inflate() 方法类似,只不过它采用 Point 对象作为参数。 - * @param point The x property of this Point object is used to increase the horizontal dimension of the Rectangle object. The y property is used to increase the vertical dimension of the Rectangle object. - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - inflatePoint(point: Point): void; - /** - * Adjusts the location of the Rectangle object, as determined by its top-left corner, by the specified amounts. - * @param dx Moves the x value of the Rectangle object by this amount. - * @param dy Moves the y value of the Rectangle object by this amount. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 按指定量调整 Rectangle 对象的位置(由其左上角确定)。 - * @param dx 将 Rectangle 对象的 x 值移动此数量。 - * @param dy 将 Rectangle 对象的 t 值移动此数量。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - offset(dx: number, dy: number): void; - /** - * Adjusts the location of the Rectangle object using a Point object as a parameter. This method is similar to the Rectangle.offset() method, except that it takes a Point object as a parameter. - * @param point A Point object to use to offset this Rectangle object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将 Point 对象用作参数来调整 Rectangle 对象的位置。此方法与 Rectangle.offset() 方法类似,只不过它采用 Point 对象作为参数。 - * @param point 要用于偏移此 Rectangle 对象的 Point 对象。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - offsetPoint(point: Point): void; - /** - * Builds and returns a string that lists the horizontal and vertical positions and the width and height of the Rectangle object. - * @returns A string listing the value of each of the following properties of the Rectangle object: x, y, width, and height. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 生成并返回一个字符串,该字符串列出 Rectangle 对象的水平位置和垂直位置以及高度和宽度。 - * @returns 一个字符串,它列出了 Rectangle 对象的下列各个属性的值:x、y、width 和 height。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - toString(): string; - /** - * Adds two rectangles together to create a new Rectangle object, by filling in the horizontal and vertical space between the two rectangles. - * @param toUnion A Rectangle object to add to this Rectangle object. - * @returns A new Rectangle object that is the union of the two rectangles. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 通过填充两个矩形之间的水平和垂直空间,将这两个矩形组合在一起以创建一个新的 Rectangle 对象。 - * @param toUnion 要添加到此 Rectangle 对象的 Rectangle 对象。 - * @returns 充当两个矩形的联合的新 Rectangle 对象。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - union(toUnion: Rectangle): Rectangle; - /** - * @private - */ - $getBaseWidth(angle: number): number; - /** - * @private - */ - $getBaseHeight(angle: number): number; - } - /** - * @private - * 仅供框架内复用,要防止暴露引用到外部。 - */ - let $TempRectangle: Rectangle; -} -declare namespace egret { -} -declare namespace egret { - /** - * The JointStyle class is an enumeration of constant values that specify the joint style to use in drawing lines. - * These constants are provided for use as values in the joints parameter of the egret.Graphics.lineStyle() method. - * @see egret.Graphics#lineStyle() - * @version Egret 2.5 - * @platform Web,Native - * @language en_US - */ - /** - * JointStyle 类是指定要在绘制线条中使用的联接点样式的常量值枚举。提供的这些常量用作 egret.Graphics.lineStyle() 方法的 joints 参数中的值。 - * @see egret.Graphics#lineStyle() - * @version Egret 2.5 - * @platform Web,Native - * @language zh_CN - */ - const JointStyle: { - BEVEL: string; - MITER: string; - ROUND: string; - }; -} -declare namespace egret { -} -/** - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/localStorage/localStorage.ts - */ -declare namespace egret.localStorage { - /** - * Read data - * @param key {string} Name of the key to be read - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 读取数据 - * @param key {string} 要读取的键名称 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - let getItem: (key: string) => string; - /** - * Save data - * @param key {string} Name of the key to be saved - * @param value {string} Value to be saved - * @returns {boolean} Whether data is saved successfully - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 保存数据 - * @param key {string} 要保存的键名称 - * @param value {string} 要保存的值 - * @returns {boolean} 数据保存是否成功 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - let setItem: (key: string, value: string) => boolean; - /** - * Delete data - * @param key {string} Name of the key to be deleted - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 删除数据 - * @param key {string} 要删除的键名称 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - let removeItem: (key: string) => void; - /** - * Clear all data - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将所有数据清空 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - let clear: () => void; -} -declare namespace egret.sys { - /** - * @private - * @param channel - */ - function $pushSoundChannel(channel: SoundChannel): void; - /** - * @private - * @param channel - */ - function $popSoundChannel(channel: SoundChannel): boolean; -} -declare namespace egret { - /** - * The Sound class lets you work with sound in an application. - * The Sound class lets you create a Sound object, load and play an external audio file into that object. - * More detailed control of the sound is performed through the SoundChannel - * - * @event egret.Event.COMPLETE Dispatch when the audio resource is loaded and ready to play - * @event egret.IOErrorEvent.IO_ERROR Dispatch when the audio resource is failed to load - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/media/Sound.ts - * @language en_US - */ - /** - * Sound 允许您在应用程序中使用声音。使用 Sound 类可以创建 Sound 对象、将外部音频文件加载到该对象并播放该文件。 - * 可通过 SoundChannel 对声音执行更精细的控制,如控制音量和监控播放进度。 - * @see http://edn.egret.com/cn/docs/page/156 音频系统 - * - * @event egret.Event.COMPLETE 音频加载完成时抛出 - * @event egret.IOErrorEvent.IO_ERROR 音频加载失败时抛出 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/media/Sound.ts - * @language zh_CN - */ - interface Sound extends EventDispatcher { - /** - * Initiates loading of an external audio file from the specified URL. - * @param url Audio file URL - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 启动从指定 URL 加载外部音频文件的过程。 - * @param url 需要加载的音频文件URL - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - load(url: string): void; - /** - * Generates a new SoundChannel object to play back the sound. - * @param startTime The initial position in seconds at which playback should start, (default = 0) - * @param loops Plays, the default value is 0. Greater than 0 to the number of plays, such as 1 to play 1, less than or equal to 0, to loop. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 生成一个新的 SoundChannel 对象来播放该声音。此方法返回 SoundChannel 对象,访问该对象可停止声音调整音量。 - * @param startTime 应开始播放的初始位置(以秒为单位),默认值是 0 - * @param loops 播放次数,默认值是 0,循环播放。 大于 0 为播放次数,如 1 为播放 1 次;小于等于 0,为循环播放。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - play(startTime?: number, loops?: number): SoundChannel; - /** - * Closes the stream, causing any download of data to cease - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 关闭该流,从而停止所有数据的下载。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - close(): void; - /** - * Type, default is egret.Sound.EFFECT. - * In the native and runtime environment, while only play a background music, sound length so as not to be too long. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 类型,默认为 egret.Sound.EFFECT。 - * 在 native 和 runtime 环境下,背景音乐同时只能播放一个,音效长度尽量不要太长。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - type: string; - /** - * Length of the current sound (in seconds). - * @version Egret 2.4 - * @platform Web,Native - * @readOnly - * @language en_US - */ - /** - * 当前声音的长度(以秒为单位)。 - * @version Egret 2.4 - * @platform Web,Native - * @readOnly - * @language zh_CN - */ - length: number; - } - /** - * @copy egret.Sound - */ - let Sound: { - /** - * Create Sound object, load an external audio file and play - * @param url Audio file URL, Sound will start to load the media if url is not empty - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建 Sound 对象、将外部音频文件加载到该对象并播放该文件 - * @param url 需要加载的音频文件URL,如果指定了 url, Sound会立即开始加载指定的媒体文件 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - new (): Sound; - /** - * Background music - * @default "music" - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 背景音乐 - * @default "music" - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - MUSIC: string; - /** - * EFFECT - * @default "effect" - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 音效 - * @default "effect" - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - EFFECT: string; - }; -} -declare namespace egret { - /** - * The SoundChannel class controls a sound in an application. - * Every sound is assigned to a sound channel, and the application - * can have multiple sound channels that are mixed together. - * The SoundChannel class contains a stop() method, properties for - * set the volume of the channel - * - * @event egret.Event.SOUND_COMPLETE Dispatch when a sound has finished playing at last time - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/media/Sound.ts - * @language en_US - */ - /** - * SoundChannel 类控制应用程序中的声音。每个声音均分配给一个声道,而且应用程序可以具有混合在一起的多个声道。 - * SoundChannel 类包含 stop() 方法、用于设置音量和监视播放进度的属性。 - * - * @event egret.Event.SOUND_COMPLETE 音频最后一次播放完成时抛出 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/media/Sound.ts - * @language zh_CN - */ - interface SoundChannel extends IEventDispatcher { - /** - * The volume, ranging from 0 (silent) to 1 (full volume). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 音量范围从 0(静音)至 1(最大音量)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - volume: number; - /** - * When the sound is playing, the position property indicates - * in seconds the current point that is being played in the sound file. - * @version Egret 2.4 - * @platform Web,Native - * @readOnly - * @language en_US - */ - /** - * 当播放声音时,position 属性表示声音文件中当前播放的位置(以秒为单位) - * @version Egret 2.4 - * @platform Web,Native - * @readOnly - * @language zh_CN - */ - position: number; - /** - * Stops the sound playing in the channel. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 停止在该声道中播放声音。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - stop(): void; - } -} -declare namespace egret { - /** - * The Video class lets you work with video in an application. - * The Video class lets you create a Video object, load and play an external video file into that object. - * Note: On most mobile device, the video is playback in the full screen mode.
- * - * @param url URL of the media to play, Video will start to load if the url is not empty - * - * @event egret.Event.COMPLETE Dispatch when the video resource is loaded and ready to play - * @event egret.Event.ENDED Dispatch when the video playback ended - * @event egret.IOErrorEvent.IO_ERROR when the video is failed to load - * @version Egret 2.4 - * @platform Web - * @includeExample egret/media/Video.ts - * @language en_US - */ - /** - * Video 允许您在应用程序中使用视频。使用 Video 类可以创建 Video 对象、将外部视频文件加载到该对象并播放该文件。
- * 注意: 在大多数移动设备中,视频是强制全屏播放的,所以你可以直接调用 play() 方法全屏播放视频,不用将它绘制在Stage中。 - * @see http://edn.egret.com/cn/docs/page/657 视频系统 - * - * @param url 要播放的视频的URL,如果url不为空,Video会立即加载这个视频 - * - * @event egret.Event.COMPLETE 视频加载完成时抛出 - * @event egret.Event.ENDED 视频播放完成时抛出 - * @event egret.IOErrorEvent.IO_ERROR 视频加载失败时触发 - * @version Egret 2.4 - * @platform Web - * @includeExample egret/media/Video.ts - * @language zh_CN - */ - interface Video extends DisplayObject { - /** - * Initiates loading of an external video file from the specified URL. - * @param url Audio file URL - * * @param cache Should cache the video,only used in Native - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 启动从指定 URL 加载外部视频文件的过程。 - * @param url 需要加载的视频文件URL - * @param cache 是否需要缓存到本地,只在 Native 上使用 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - load(url: string, cache?: boolean): void; - /** - * Play back the video. - * @param startTime The initial position in seconds at which playback should start, (default = 0) - * @param loop Defines should play the video again when the video is ended. (default = false) - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 播放该视频 - * @param startTime 应开始播放的初始位置(以秒为单位),默认值是视频上次结束的位置 - * @param loop 是否需要循环播放,默认值是 false - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - play(startTime?: number, loop?: boolean): any; - /** - * Closes the stream, causing any download of data to cease - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 关闭该流,从而停止所有数据的下载。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - close(): void; - /** - * The URL of the video you want to play. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 想要播放的视频的URL - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - src: string; - /** - * The URL of an image you want to display before the video is loaded or video cannot been draw on the canvas on some mobile device. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 视频加载前,或者在不支持将 video 画在 canvas 的设备上,想要显示的视频截图地址。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - poster: string; - /** - * Should play the video in fullscreen mode (default = true). - * Currently only supports full-screen mobile terminal web. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 是否全屏播放这个视频(默认值是 true)。 - * 目前移动端 web 只支持全屏。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - fullscreen: boolean; - /** - * The volume, ranging from 0 (silent) to 1 (full volume). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 音量范围从 0(静音)至 1(最大音量)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - volume: number; - /** - * When the video is playing, the position property indicates - * in seconds the current point that is being played in the video file. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 当播放视频时,position 属性表示视频文件中当前播放的位置(以秒为单位) - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - position: number; - /** - * Pause the video playing. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 暂停播放。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - pause(): void; - /** - * Get bitmapData of the video file, you can use the video as bitmapData on the stage. - * Note: On most mobile device, the video is playback in the full screen mode. - * So you can just use the play() method instead of draw it on the Stage - * @version Egret 2.4 - * @platform Web - * @language en_US - */ - /** - * 获取视频的 bitmapData, 你可以将视频绘制到舞台上。 - * 注意: 在大多数移动设备中,视频是全屏播放的,所以你可以直接调用 play() 方法全屏播放视频,不用将它绘制在Stage中。 - * @version Egret 2.4 - * @platform Web - * @language zh_CN - */ - bitmapData?: BitmapData; - /** - * Whether current video is paused. - * @version Egret 2.4 - * @platform Web,Native - * @readOnly - * @language en_US - */ - /** - * 当前视频是否在暂停状态。 - * @version Egret 2.4 - * @platform Web,Native - * @readOnly - * @language zh_CN - */ - paused: boolean; - /** - * Length of the current video (in seconds). - * @version Egret 3.0.8 - * @platform Web,Native - * @readOnly - * @language en_US - */ - /** - * 当前视频的长度(以秒为单位)。 - * @version Egret 3.0.8 - * @platform Web,Native - * @readOnly - * @language zh_CN - */ - length: number; - } - /** - * @copy egret.Video - */ - let Video: { - new (url?: string, cache?: boolean): Video; - }; -} -declare namespace egret { - /** - * The HttpMethod class provides values that specify whether the HttpRequest object should use the POST method - * or the GET method when sending data to a server. - * @see egret.HttpRequest - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * HttpRequestMethod 类提供了一些值,这些值可指定在将数据发送到服务器时, - * HttpRequest 对象应使用 POST 方法还是 GET 方法。 - * @see egret.HttpRequest - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - namespace HttpMethod { - /** - * Specifies that the HttpRequest object is a GET. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示 HttpRequest 对象是一个 GET。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - const GET = "GET"; - /** - * Specifies that the HttpRequest object is a POST. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示 HttpRequest 对象是一个 POST。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - const POST = "POST"; - } -} -declare namespace egret { - /** - * The HttpRequest class downloads data from a URL as text or binary data. It is useful for downloading text files, - * XML, or other information to be used in a dynamic, data-driven application. A HttpRequest object downloads all - * of the data from a URL before making it available to code in the applications. It sends out notifications about - * the progress of the download, which you can monitor through the bytesLoaded and bytesTotal properties, - * as well as through dispatched events. - * @event egret.Event.COMPLETE Dispatched when the net request is complete. - * @event egret.Event.IO_ERROR Dispatched when the net request is failed. - * @event egret.ProgressEvent.PROGRESS Dispatched when data is received as the download operation progresses. - * @see egret.HttpMethod - * @see egret.HttpResponseType - * @includeExample egret/net/HttpRequestExample.ts - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * HttpRequest 类以文本或二进制数据的形式从 URL 下载数据。 - * HttpRequest 对象会先从 URL 中下载所有数据,然后才将数据用于应用程序中的代码。它会发出有关下载进度的通知, - * 通过 bytesLoaded 和 bytesTotal 属性以及已调度的事件,可以监视下载进度。 - * @event egret.Event.COMPLETE 加载完成 - * @event egret.Event.IO_ERROR 加载失败 - * @event egret.ProgressEvent.PROGRESS 加载进度,可通过event.bytesLoaded和event.bytesTotal统计进度信息。 - * @see egret.HttpMethod - * @see egret.HttpResponseType - * @includeExample egret/net/HttpRequestExample.ts - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - interface HttpRequest extends EventDispatcher { - /** - * The data received from the load operation. The format of the data depends on the setting of the responseType property. - * @readOnly - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 本次请求返回的数据,数据类型根据 responseType 设置的值确定。 - * @readOnly - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - response: any; - /** - * Controls whether the downloaded data is received as text (HttpResponseType.TEXT) or raw binary data (HttpResponseType.ArrayBuffer)
- * Note:If you attempt to set this property to an invalid value, Egret runtime set the value to HttpResponseType.TEXT. - * @default egret.HttpResponseType.TEXT - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 设置返回的数据格式为文本(HttpResponseType.TEXT)还是二进制数据(HttpResponseType.ArrayBuffer)
- * 注意:若尝试设置此属性为一个非法的值,运行时将使用HttpResponseType.TEXT。 - * @default egret.HttpResponseType.TEXT - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - responseType: string; - /** - * Can be set to a time in milliseconds.When set to a non-zero value will cause fetching to terminate after the given time has passed. - * @default egret.HttpResponseType.TEXT - * @version Egret 5.2.15 - * @platform Web,Native - * @language en_US - */ - /** - * 代表着一个请求在被自动终止前所消耗的毫秒数。默认值为 0,意味着没有超时。 - * @default egret.HttpResponseType.TEXT - * @version Egret 5.2.15 - * @platform Web,Native - * @language zh_CN - */ - timeout: number; - /** - * indicates whether or not cross-site Access-Control requests should be made using credentials such as cookies - * or authorization headers. (This never affects same-site requests.) - * @default false - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表明在进行跨站(cross-site)的访问控制(Access-Control)请求时,是否使用认证信息(例如cookie或授权的header)。(这个标志不会影响同站的请求) - * @default false - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - withCredentials: boolean; - /** - * Initializes a request.
- * Note: Calling this method for an already active request (one for which open() or openRequest() has already been - * called) is the equivalent of calling abort(). - * @param url The URL to send the request to. - * @param method The HTTP method to use, please use the const value in the HttpMethod class. - * @see egret.HttpMethod - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 初始化一个请求.
- * 注意: 若在已经发出请求的对象上调用此方法,相当于立即调用abort(). - * @param url 该请求所要访问的URL该请求所要访问的URL - * @param method 请求所使用的HTTP方法, 请使用 HttpMethod 定义的枚举值. - * @see egret.HttpMethod - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - open(url: string, method?: string): void; - /** - * Sends the request. - * @param data the data to send. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 发送请求. - * @param data 需要发送的数据 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - send(data?: any): void; - /** - * Aborts the request if it has already been sent. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 如果请求已经被发送,则立刻中止请求. - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - abort(): void; - /** - * Returns all the response headers as a string, or null if no response has been received. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 返回所有响应头信息(响应头名和值), 如果响应头还没接受,则返回"". - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - getAllResponseHeaders(): string; - /** - * Sets the value of an HTTP request header. You must call setRequestHeader() after open(). - * @param header The name of the header whose value is to be set. - * @param value The value to set as the body of the header. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 给指定的HTTP请求头赋值.在这之前,您必须确认已经调用 open() 方法打开了一个url. - * @param header 将要被赋值的请求头名称. - * @param value 给指定的请求头赋的值. - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - setRequestHeader(header: string, value: string): void; - /** - * Returns the string containing the text of the specified header, or null if either the response has not yet been - * received or the header doesn't exist in the response. - * @param header The name of the header whose value is to be get. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 返回指定的响应头的值, 如果响应头还没被接受,或该响应头不存在,则返回"". - * @param header 要返回的响应头名称 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - getResponseHeader(header: string): string; - } - /** - * Creates a HttpRequest object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 HttpRequest 实例。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - let HttpRequest: { - new (): HttpRequest; - }; -} -declare namespace egret { - /** - * The HttpResponseType class provides values that specify how downloaded data is received. - * @see egret.HttpRequest - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * URLLoaderDataFormat 类提供了一些用于指定如何接收已下载数据的值。 - * @see egret.HttpRequest - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - class HttpResponseType { - /** - * Specifies that downloaded data is received as text. This is the default value of HttpRequest.responseType - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 返回字符串。HttpRequest.responseType属性的默认值。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static TEXT: string; - /** - * Specifies that downloaded data is received as raw binary data. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 返回二进制的ArrayBuffer对象。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static ARRAY_BUFFER: string; - } -} -declare namespace egret { - /** - * The Loader class is used to load image (JPG, PNG, or GIF) files. Use the load() method to initiate loading. - * The loaded image data is in the data property of ImageLoader. - * @event egret.Event.COMPLETE Dispatched when the net request is complete. - * @event egret.IOErrorEvent.IO_ERROR Dispatched when the net request is failed. - * @see egret.HttpRequest - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/net/ImageLoaderExample.ts - * @see http://edn.egret.com/cn/docs/page/590 加载位图文件 - * @language en_US - */ - /** - * ImageLoader 类可用于加载图像(JPG、PNG 或 GIF)文件。使用 load() 方法来启动加载。被加载的图像对象数据将存储在 ImageLoader.data 属性上 。 - * @event egret.Event.COMPLETE 加载完成 - * @event egret.IOErrorEvent.IO_ERROR 加载失败 - * @see egret.HttpRequest - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/net/ImageLoaderExample.ts - * @see http://edn.egret.com/cn/docs/page/590 加载位图文件 - * @language zh_CN - */ - interface ImageLoader extends EventDispatcher { - /** - * The data received from the load operation. - * @default null - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 使用 load() 方法加载成功的 BitmapData 图像数据。 - * @default null - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - data: BitmapData; - /** - * Specifies whether or not cross-site Access-Control requests should be made when loading a image from foreign origins.
- * possible values are:"anonymous","use-credentials" or null. - * @default null - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 当从其他站点加载一个图片时,指定是否启用跨域资源共享(CORS),默认值为null。
- * 可以设置为"anonymous","use-credentials"或null,设置为其他值将等同于"anonymous"。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - crossOrigin: string; - /** - * start a load operation。
- * Note: Calling this method for an already active request (one for which load() has already been - * called) will abort the last load operation immediately. - * @param url 要加载的图像文件的地址。 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 启动一次图像加载。
- * 注意:若之前已经调用过加载请求,重新调用 load() 将终止先前的请求,并开始新的加载。 - * @param url 要加载的图像文件的地址。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - load(url: string): void; - } - /** - * Creates a ImageLoader object - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 ImageLoader 实例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - let ImageLoader: { - /** - * constructor - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 构造函数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - new (): ImageLoader; - /** - * Specifies whether to enable cross-origin resource sharing, If ImageLoader instance has been set crossOrigin property will be used to set the property. - * @version Egret 2.5.7 - * @platform Web,Native - * @language en_US - */ - /** - * 指定是否启用跨域资源共享,如果ImageLoader实例有设置过crossOrigin属性将使用设置的属性 - * @version Egret 2.5.7 - * @platform Web,Native - * @language zh_CN - */ - crossOrigin: string; - }; -} -declare namespace egret.sys { - /** - * @private - * 显示列表 - */ - class DisplayList extends HashObject { - /** - * 创建一个DisplayList对象,若内存不足或无法创建RenderBuffer,将会返回null。 - */ - static create(target: DisplayObject): DisplayList; - /** - * @private - * 创建一个DisplayList对象 - */ - constructor(root: DisplayObject); - private isStage; - /** - * 位图渲染节点 - */ - $renderNode: RenderNode; - /** - * @private - * 获取渲染节点 - */ - $getRenderNode(): sys.RenderNode; - /** - * @private - */ - renderBuffer: RenderBuffer; - /** - * @private - */ - offsetX: number; - /** - * @private - */ - offsetY: number; - /** - * @private - */ - private offsetMatrix; - /** - * @private - * 显示列表根节点 - */ - root: DisplayObject; - /** - * @private - * 设置剪裁边界,不再绘制完整目标对象,画布尺寸由外部决定,超过边界的节点将跳过绘制。 - */ - setClipRect(width: number, height: number): void; - $canvasScaleX: number; - $canvasScaleY: number; - /** - * @private - * 绘制根节点显示对象到目标画布,返回draw的次数。 - */ - drawToSurface(): number; - private bitmapData; - /** - * @private - * 改变画布的尺寸,由于画布尺寸修改会清空原始画布。所以这里将原始画布绘制到一个新画布上,再与原始画布交换。 - */ - changeSurfaceSize(): void; - static $canvasScaleFactor: number; - /** - * @private - */ - static $canvasScaleX: number; - static $canvasScaleY: number; - /** - * @private - */ - static $setCanvasScale(x: number, y: number): void; - } -} -declare namespace egret { - type runEgretOptions = { - renderMode?: string; - audioType?: number; - screenAdapter?: sys.IScreenAdapter; - antialias?: boolean; - canvasScaleFactor?: number; - calculateCanvasScaleFactor?: (context: CanvasRenderingContext2D) => number; - /** - * 以下目前仅供小游戏使用 - * The following are for mini-games only - */ - entryClassName?: string; - scaleMode?: string; - frameRate?: number; - contentWidth?: number; - contentHeight?: number; - orientation?: string; - maxTouches?: number; - showFPS?: boolean; - showLog?: boolean; - fpsStyles?: string; - }; - /** - * egret project entry function - * @param options An object containing the initialization properties for egret engine. - * @language en_US - */ - /** - * egret工程入口函数 - * @param options 一个可选对象,包含初始化Egret引擎需要的参数。 - * @language zh_CN - */ - function runEgret(options?: runEgretOptions): void; - /** - * Refresh the screen display - * @language en_US - */ - /** - * 刷新屏幕显示 - * @language zh_CN - */ - function updateAllScreens(): void; -} -declare namespace egret { - /** - * @private - */ - interface FPSDisplay { - /** - * 更新FPS信息 - */ - update(datas: FPSData): void; - /** - * 插入一条log信息 - */ - updateInfo(info: string): void; - /** - * 插入一条warn信息 - */ - updateWarn(info: string): void; - /** - * 插入一条error信息 - */ - updateError(info: string): void; - } - /** - * @private - */ - let FPSDisplay: { - new (stage: Stage, showFPS: boolean, showLog: boolean, logFilter: string, styles: Object): FPSDisplay; - }; -} -/** - * @private - */ -interface FPSData extends Object { - fps: number; - draw: number; - costTicker: number; - costRender: number; -} -declare namespace egret.sys { - let $TempStage: egret.Stage; - /** - * @private - * Egret播放器 - */ - class Player extends HashObject { - /** - * @private - * 实例化一个播放器对象。 - */ - constructor(buffer: RenderBuffer, stage: Stage, entryClassName: string); - /** - * @private - */ - private createDisplayList(stage, buffer); - /** - * @private - */ - private screenDisplayList; - /** - * @private - * 入口类的完整类名 - */ - private entryClassName; - /** - * @private - * 舞台引用 - */ - stage: Stage; - /** - * @private - * 入口类实例 - */ - private root; - /** - * @private - */ - private isPlaying; - /** - * @private - * 启动播放器 - */ - start(): void; - /** - * @private - */ - private initialize(); - /** - * @private - * 停止播放器,停止后将不能重新启动。 - */ - stop(): void; - /** - * @private - * 暂停播放器,后续可以通过调用start()重新启动播放器。 - */ - pause(): void; - /** - * @private - * 渲染屏幕 - */ - $render(triggerByFrame: boolean, costTicker: number): void; - /** - * @private - * 更新舞台尺寸 - * @param stageWidth 舞台宽度(以像素为单位) - * @param stageHeight 舞台高度(以像素为单位) - */ - updateStageSize(stageWidth: number, stageHeight: number): void; - /** - * @private - * 显示FPS。 - */ - displayFPS(showFPS: boolean, showLog: boolean, logFilter: string, styles: Object): void; - /** - * @private - */ - private showFPS; - /** - * @private - */ - private showLog; - /** - * @private - */ - private stageDisplayList; - } - /** - * @private - */ - let $logToFPS: (info: string) => void; - /** - * @private - */ - let $warnToFPS: (info: string) => void; - /** - * @private - */ - let $errorToFPS: (info: string) => void; -} -/** - * @private - */ -declare module egret { - /** - * @private - */ - var nativeRender: boolean; -} -declare namespace egret { - /** !!!!!!!!inspired by Babylon.js!!!!!!!!!!!!! - * for description see https://www.khronos.org/opengles/sdk/tools/KTX/ - * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/ - * Current families are astc, dxt, pvrtc, etc2, & etc1. - * @returns The extension selected. - */ - class KTXContainer { - /** contents of the KTX container file */ arrayBuffer: any; - private static readonly HEADER_LEN; - private static readonly COMPRESSED_2D; - private static readonly COMPRESSED_3D; - private static readonly TEX_2D; - private static readonly TEX_3D; - /** - * Gets the openGL type - */ - glType: number; - /** - * Gets the openGL type size - */ - glTypeSize: number; - /** - * Gets the openGL format - */ - glFormat: number; - /** - * Gets the openGL internal format - */ - glInternalFormat: number; - /** - * Gets the base internal format - */ - glBaseInternalFormat: number; - /** - * Gets image width in pixel - */ - pixelWidth: number; - /** - * Gets image height in pixel - */ - pixelHeight: number; - /** - * Gets image depth in pixels - */ - pixelDepth: number; - /** - * Gets the number of array elements - */ - numberOfArrayElements: number; - /** - * Gets the number of faces - */ - numberOfFaces: number; - /** - * Gets the number of mipmap levels - */ - numberOfMipmapLevels: number; - /** - * Gets the bytes of key value data - */ - bytesOfKeyValueData: number; - /** - * Gets the load type - */ - loadType: number; - /** - * If the container has been made invalid (eg. constructor failed to correctly load array buffer) - */ - isInvalid: boolean; - /** - * Creates a new KhronosTextureContainer - * @param arrayBuffer contents of the KTX container file - * @param facesExpected should be either 1 or 6, based whether a cube texture or or - * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented - * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented - */ - constructor(/** contents of the KTX container file */ arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean); - /** - * Uploads KTX content to a Babylon Texture. - * It is assumed that the texture has already been created & is currently bound - * @hidden - */ - uploadLevels(bitmapData: egret.BitmapData, loadMipmaps: boolean): void; - private _upload2DCompressedLevels(bitmapData, loadMipmaps); - } -} -declare namespace egret.sys { - /** - * @private - * 共享的用于碰撞检测的渲染缓冲 - */ - let customHitTestBuffer: sys.RenderBuffer; - /** - * @private - * 共享的用于canvas碰撞检测的渲染缓冲 - */ - let canvasHitTestBuffer: sys.RenderBuffer; - /** - * @private - * 渲染缓冲 - */ - interface RenderBuffer { - /** - * 呈现最终绘图结果的画布。 - * @readOnly - */ - surface: any; - /** - * 渲染上下文。 - * @readOnly - */ - context: any; - /** - * 渲染缓冲的宽度,以像素为单位。 - * @readOnly - */ - width: number; - /** - * 渲染缓冲的高度,以像素为单位。 - * @readOnly - */ - height: number; - /** - * 改变渲染缓冲的大小并清空缓冲区 - * @param width 改变后的宽 - * @param height 改变后的高 - * @param useMaxSize 若传入true,则将改变后的尺寸与已有尺寸对比,保留较大的尺寸。 - */ - resize(width: number, height: number, useMaxSize?: boolean): void; - /** - * 获取指定区域的像素 - */ - getPixels(x: number, y: number, width?: number, height?: number): number[]; - /** - * 转换成base64字符串,如果图片(或者包含的图片)跨域,则返回null - * @param type 转换的类型,如: "image/png","image/jpeg" - */ - toDataURL(type?: string, ...args: any[]): string; - /** - * 清空缓冲区数据 - */ - clear(): void; - /** - * 销毁渲染缓冲 - */ - destroy(): void; - } - /** - * @private - */ - let RenderBuffer: { - /** - * 创建一个RenderTarget。 - * 注意:若内存不足或创建缓冲区失败,将会抛出错误异常。 - * @param width 渲染缓冲的初始宽 - * @param height 渲染缓冲的初始高 - * @param root 是否为舞台buffer - */ - new (width?: number, height?: number, root?: boolean): RenderBuffer; - }; - /** - * @private - */ - let CanvasRenderBuffer: { - /** - * 创建一个CanvasRenderBuffer。 - * 注意:若内存不足或创建缓冲区失败,将会抛出错误异常。 - * @param width 渲染缓冲的初始宽 - * @param height 渲染缓冲的初始高 - */ - new (width?: number, height?: number): RenderBuffer; - }; -} -declare namespace egret.sys { - /** - * @private - * 设备屏幕 - */ - interface Screen { - /** - * @private - * 更新屏幕视口尺寸 - */ - updateScreenSize(): any; - /** - * @private - * 更新触摸数量 - */ - updateMaxTouches(): any; - /** - * @private - * 设置分辨率尺寸 - */ - setContentSize(width: number, height: number): any; - } -} -declare namespace egret.sys { - /** - * @private - * 屏幕适配器接口,当播放器视口尺寸改变时,屏幕适配器将被用于计算当前对应的舞台显示尺寸。 - */ - interface IScreenAdapter { - /** - * @private - * 计算舞台显示尺寸 - * @param scaleMode 当前的缩放模式 - * @param screenWidth 播放器视口宽度 - * @param screenHeight 播放器视口高度 - * @param contentWidth 初始化内容宽度 - * @param contentHeight 初始化内容高度 - */ - calculateStageSize(scaleMode: string, screenWidth: number, screenHeight: number, contentWidth: number, contentHeight: number): StageDisplaySize; - } - /** - * @private - * 舞台显示尺寸数据 - */ - interface StageDisplaySize { - /** - * @private - * 舞台宽度 - */ - stageWidth: number; - /** - * @private - * 舞台高度 - */ - stageHeight: number; - /** - * @private - * 显示宽度,若跟舞台宽度不同,将会产生缩放。 - */ - displayWidth: number; - /** - * @private - * 显示高度,若跟舞台高度不同,将会产生缩放。 - */ - displayHeight: number; - } - /** - * @private - * 屏幕适配器实例,开发者可以通过给这个变量赋值实现了IScreenAdapter接口的实例,从而注入自定义的屏幕适配器。 - */ - let screenAdapter: IScreenAdapter; - /** - * @private - * 屏幕适配器默认实现,开发者可以实现自定义规则的屏幕适配器。并在初始化加载时将适配器的实例赋值给egret.sys.screenAdapter上,从而替换掉默认适配器。 - */ - class DefaultScreenAdapter extends HashObject implements IScreenAdapter { - /** - * @private - */ - constructor(); - /** - * @private - * 计算舞台显示尺寸 - * @param scaleMode 当前的缩放模式 - * @param screenWidth 播放器视口宽度 - * @param screenHeight 播放器视口高度 - * @param contentWidth 初始化内容宽度 - * @param contentHeight 初始化内容高度 - */ - calculateStageSize(scaleMode: string, screenWidth: number, screenHeight: number, contentWidth: number, contentHeight: number): StageDisplaySize; - } -} -declare namespace egret { - /** - * StageScaleMode class provides values for the stage zoom mode. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/player/StageScaleMode.ts - * @language en_US - */ - /** - * StageScaleMode 类为舞台缩放模式提供值。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/player/StageScaleMode.ts - * @language zh_CN - */ - class StageScaleMode { - /** - * Do not scale application content. Even when you change the player viewport size, it remains unchanged. If the player is smaller than the viewport content, possibly with some cropping.
- * In this mode, the stage size (Stage.stageWidth, Stage.stageHeight) always with the player viewport size consistent. - * @language en_US - */ - /** - * 不缩放应用程序内容。即使在更改播放器视口大小时,它仍然保持不变。如果播放器视口比内容小,则可能进行一些裁切。
- * 在此模式下,舞台尺寸(Stage.stageWidth,Stage.stageHeight)始终跟播放器视口大小保持一致。 - * @language zh_CN - */ - static NO_SCALE: string; - /** - * Keep the original aspect ratio scaling application content, after scaling a wide directions application content to fill the viewport players on both sides in the other direction may not be wide enough and left black bars.
- * In this mode, the stage size (Stage.stageWidth, Stage.stageHeight) is always equal to the initialization incoming external application content size. - * @language en_US - */ - /** - * 保持原始宽高比缩放应用程序内容,缩放后应用程序内容的较宽方向填满播放器视口,另一个方向的两侧可能会不够宽而留有黑边。
- * 在此模式下,舞台尺寸(Stage.stageWidth,Stage.stageHeight)始终等于初始化时外部传入的应用程序内容尺寸。 - * @language zh_CN - */ - static SHOW_ALL: string; - /** - * Keep the original aspect ratio scaling application content, after scaling a narrow direction of application content to fill the viewport players on both sides in the other direction may exceed the viewport and the player is cut.
- * In this mode, the stage size (Stage.stageWidth, Stage.stageHeight) is always equal to the initialization incoming external application content size. - * @language en_US - */ - /** - * 保持原始宽高比缩放应用程序内容,缩放后应用程序内容的较窄方向填满播放器视口,另一个方向的两侧可能会超出播放器视口而被裁切。
- * 在此模式下,舞台尺寸(Stage.stageWidth,Stage.stageHeight)始终等于初始化时外部传入的应用程序内容尺寸。 - * @language zh_CN - */ - static NO_BORDER: string; - /** - * Do not keep the original aspect ratio scaling application content, after scaling application content just fill the player viewport.
- * In this mode, the stage size (Stage.stageWidth, Stage.stageHeight) is always equal to the initialization incoming external application content size. - * @language en_US - */ - /** - * 不保持原始宽高比缩放应用程序内容,缩放后应用程序内容正好填满播放器视口。
- * 在此模式下,舞台尺寸(Stage.stageWidth,Stage.stageHeight)始终等于初始化时外部传入的应用程序内容尺寸。 - * @language zh_CN - */ - static EXACT_FIT: string; - /** - * Keep the original aspect ratio scaling application content, after scaling application content in the horizontal and vertical directions to fill the viewport player, but only to keep the contents of the original application constant width, height may change.
- * In this mode, the stage width (Stage.stageWidth) is always equal to initialize external incoming application content width. Stage height (Stage.stageHeight) by the current scale with the player viewport height decision. - * @language en_US - */ - /** - * 保持原始宽高比缩放应用程序内容,缩放后应用程序内容在水平和垂直方向都填满播放器视口,但只保持应用程序内容的原始宽度不变,高度可能会改变。
- * 在此模式下,舞台宽度(Stage.stageWidth)始终等于初始化时外部传入的应用程序内容宽度。舞台高度(Stage.stageHeight)由当前的缩放比例与播放器视口高度决定。 - * @language zh_CN - */ - static FIXED_WIDTH: string; - /** - * Keep the original aspect ratio scaling application content, after scaling application content in the horizontal and vertical directions to fill the viewport player, but only to keep the contents of the original application constant height, width may change.
- * In this mode, the stage height (Stage.stageHeight) is always equal to initialize external incoming application content height. Stage width (Stage.stageWidth) by the current scale with the player viewport width decision. - * @language en_US - */ - /** - * 保持原始宽高比缩放应用程序内容,缩放后应用程序内容在水平和垂直方向都填满播放器视口,但只保持应用程序内容的原始高度不变,宽度可能会改变。
- * 在此模式下,舞台高度(Stage.stageHeight)始终等于初始化时外部传入的应用程序内容高度。舞台宽度(Stage.stageWidth)由当前的缩放比例与播放器视口宽度决定。 - * @language zh_CN - */ - static FIXED_HEIGHT: string; - /** - * Keep the original aspect ratio scaling application content, after scaling application content in the horizontal and vertical directions to fill the viewport player,a narrow direction may not be wide enough and fill.
- * In this mode, the stage height (Stage.stageHeight) and the stage width (Stage.stageWidth) by the current scale with the player viewport size. - * @language en_US - */ - /** - * 保持原始宽高比缩放应用程序内容,缩放后应用程序内容在水平和垂直方向都填满播放器视口,应用程序内容的较窄方向可能会不够宽而填充。
- * 在此模式下,舞台高度(Stage.stageHeight)和舞台宽度(Stage.stageWidth)由当前的缩放比例与播放器视口宽高决定。 - * @language zh_CN - */ - static FIXED_NARROW: string; - /** - * Keep the original aspect ratio scaling application content, after scaling application content in the horizontal and vertical directions to fill the viewport player, a wide direction may exceed the viewport and the player is cut.
- * In this mode, the stage height (Stage.stageHeight) and the stage width (Stage.stageWidth) by the current scale with the player viewport size. - * @language en_US - */ - /** - * 保持原始宽高比缩放应用程序内容,缩放后应用程序内容在水平和垂直方向都填满播放器视口,应用程序内容的较宽方向的两侧可能会超出播放器视口而被裁切。
- * 在此模式下,舞台高度(Stage.stageHeight)和舞台宽度(Stage.stageWidth)由当前的缩放比例与播放器视口宽高决定。 - * @language zh_CN - */ - static FIXED_WIDE: string; - } -} -declare namespace egret.sys { - /** - * @private - */ - let systemRenderer: SystemRenderer; - /** - * @private - * 用于碰撞检测绘制 - */ - let canvasRenderer: SystemRenderer; - /** - * @private - * 显示渲染器接口 - */ - interface SystemRenderer { - /** - * 渲染一个显示对象 - * @param displayObject 要渲染的显示对象 - * @param buffer 渲染缓冲 - * @param matrix 要叠加的矩阵 - * @param forRenderTexture 绘制目标是RenderTexture的标志 - * @returns drawCall触发绘制的次数 - */ - render(displayObject: DisplayObject, buffer: RenderBuffer, matrix: Matrix, forRenderTexture?: boolean): number; - /** - * 将一个RenderNode对象绘制到渲染缓冲 - * @param node 要绘制的节点 - * @param buffer 渲染缓冲 - * @param matrix 要叠加的矩阵 - * @param forHitTest 绘制结果是用于碰撞检测。若为true,当渲染GraphicsNode时,会忽略透明度样式设置,全都绘制为不透明的。 - */ - drawNodeToBuffer(node: sys.RenderNode, buffer: RenderBuffer, matrix: Matrix, forHitTest?: boolean): void; - } - /** - * - */ - interface RenderContext { - } - /** - * 创建一个canvas。 - */ - function mainCanvas(width?: number, height?: number): HTMLCanvasElement; - function createCanvas(width?: number, height?: number): HTMLCanvasElement; - /** - * 重新设置主canvas的大小 - */ - function resizeContext(renderContext: RenderContext, width: number, height: number, useMaxSize?: boolean): void; - /** - * 获得系统的渲染运行时 - */ - function getContextWebGL(surface: HTMLCanvasElement): WebGLRenderingContext; - function getContext2d(surface: HTMLCanvasElement): CanvasRenderingContext2D; - /** - * 仅通过bitmapData创建纹理 - */ - function createTexture(renderContext: RenderContext, bitmapData: BitmapData | HTMLCanvasElement): WebGLTexture; - /** - * 通过 width, height, data创建纹理 - */ - function _createTexture(renderContext: RenderContext, width: number, height: number, data: any): WebGLTexture; - /** - * 画texture - **/ - function drawTextureElements(renderContext: RenderContext, data: any, offset: number): number; - /** - * 测量文本的宽度 - * @param context - * @param text - */ - function measureTextWith(context: CanvasRenderingContext2D, text: string): number; - /** - * 为CanvasRenderBuffer创建一个canvas - * @param defaultFunc - * @param width - * @param height - * @param root - */ - function createCanvasRenderBufferSurface(defaultFunc: (width?: number, height?: number) => HTMLCanvasElement, width?: number, height?: number, root?: boolean): HTMLCanvasElement; - /** - * 改变渲染缓冲的大小并清空缓冲区 - * @param renderContext - * @param width - * @param height - * @param useMaxSize - */ - function resizeCanvasRenderBuffer(renderContext: RenderContext, width: number, height: number, useMaxSize?: boolean): void; -} -declare namespace egret.sys { - /** - * @private - */ - let $START_TIME: number; - /** - * @private - * 是否要广播Event.RENDER事件的标志。 - */ - let $invalidateRenderFlag: boolean; - /** - * @private - * 需要立即刷新屏幕的标志 - */ - let $requestRenderingFlag: boolean; - /** - * Egret心跳计时器 - */ - class SystemTicker { - /** - * @private - */ - constructor(); - /** - * @private - */ - private playerList; - /** - * @private - * 注册一个播放器实例并运行 - */ - $addPlayer(player: Player): void; - /** - * @private - * 停止一个播放器实例的运行。 - */ - $removePlayer(player: Player): void; - /** - * @private - */ - private callBackList; - /** - * @private - */ - private thisObjectList; - /** - * @private - */ - $startTick(callBack: (timeStamp: number) => boolean, thisObject: any): void; - /** - * @private - */ - $stopTick(callBack: (timeStamp: number) => boolean, thisObject: any): void; - /** - * @private - */ - private getTickIndex(callBack, thisObject); - /** - * @private - * - */ - private concatTick(); - /** - * @private - * 全局帧率 - */ - $frameRate: number; - /** - * @private - */ - private frameInterval; - /** - * @private - */ - private frameDeltaTime; - /** - * @private - */ - private lastTimeStamp; - /** - * @private - * 设置全局帧率 - */ - $setFrameRate(value: number): boolean; - /** - * @private - */ - private lastCount; - /** - * @private - * ticker 花销的时间 - */ - private costEnterFrame; - /** - * @private - * 是否被暂停 - */ - private isPaused; - /** - * Pause the ticker. - * @version Egret 5.0.2 - * @platform Web,Native - * @language en_US - */ - /** - * 暂停心跳 - * @version Egret 5.0.2 - * @platform Web,Native - * @language zh_CN - */ - pause(): void; - /** - * Resume the ticker. - * @version Egret 5.0.2 - * @platform Web,Native - * @language en_US - */ - /** - * 恢复心跳 - * @version Egret 5.0.2 - * @platform Web,Native - * @language zh_CN - */ - resume(): void; - /** - * @private - * 执行一次刷新 - */ - update(forceUpdate?: boolean): void; - /** - * @private - * 执行一次屏幕渲染 - */ - private render(triggerByFrame, costTicker); - /** - * @private - * 广播EnterFrame事件。 - */ - private broadcastEnterFrame(); - /** - * @private - * 广播Render事件。 - */ - private broadcastRender(); - /** - * @private - */ - private callLaters(); - /** - * @private - */ - private callLaterAsyncs(); - } -} -declare module egret { - namespace lifecycle { - type LifecyclePlugin = (context: LifecycleContext) => void; - /** - * @private - */ - let stage: egret.Stage; - /** - * @private - */ - let contexts: LifecycleContext[]; - class LifecycleContext { - pause(): void; - resume(): void; - onUpdate?: () => void; - } - let onResume: () => void; - let onPause: () => void; - function addLifecycleListener(plugin: LifecyclePlugin): void; - } - /** - * 心跳计时器单例 - */ - let ticker: sys.SystemTicker; -} -/** - * @private - */ -declare let egret_stages: egret.Stage[]; -declare namespace egret.sys { - /** - * @private - * 用户交互操作管理器 - */ - class TouchHandler extends HashObject { - private maxTouches; - private useTouchesCount; - /** - * @private - */ - constructor(stage: Stage); - /** - * @private - * 设置同时触摸数量 - */ - $initMaxTouches(): void; - /** - * @private - */ - private stage; - /** - * @private - */ - private touchDownTarget; - /** - * @private - * 触摸开始(按下) - * @param x 事件发生处相对于舞台的坐标x - * @param y 事件发生处相对于舞台的坐标y - * @param touchPointID 分配给触摸点的唯一标识号 - */ - onTouchBegin(x: number, y: number, touchPointID: number): void; - /** - * @private - */ - private lastTouchX; - /** - * @private - */ - private lastTouchY; - /** - * @private - * 触摸移动 - * @param x 事件发生处相对于舞台的坐标x - * @param y 事件发生处相对于舞台的坐标y - * @param touchPointID 分配给触摸点的唯一标识号 - */ - onTouchMove(x: number, y: number, touchPointID: number): void; - /** - * @private - * 触摸结束(弹起) - * @param x 事件发生处相对于舞台的坐标x - * @param y 事件发生处相对于舞台的坐标y - * @param touchPointID 分配给触摸点的唯一标识号 - */ - onTouchEnd(x: number, y: number, touchPointID: number): void; - /** - * @private - * 获取舞台坐标下的触摸对象 - */ - private findTarget(stageX, stageY); - } -} -declare namespace egret.sys { - /** - * @private - * 位图渲染节点 - */ - class BitmapNode extends RenderNode { - constructor(); - /** - * 要绘制的位图 - */ - image: BitmapData; - /** - * 控制在缩放时是否对位图进行平滑处理。 - */ - smoothing: boolean; - /** - * 相对偏移矩阵。 - */ - matrix: egret.Matrix; - /** - * 图片宽度。WebGL渲染使用 - */ - imageWidth: number; - /** - * 图片高度。WebGL渲染使用 - */ - imageHeight: number; - /** - * 使用的混合模式 - */ - blendMode: number; - /** - * 相对透明度 - */ - alpha: number; - /** - * 颜色变换滤镜 - */ - filter: ColorMatrixFilter; - /** - * 翻转 - */ - rotated: boolean; - /** - * 绘制一次位图 - */ - drawImage(sourceX: number, sourceY: number, sourceW: number, sourceH: number, drawX: number, drawY: number, drawW: number, drawH: number): void; - /** - * 在显示对象的$updateRenderNode()方法被调用前,自动清空自身的drawData数据。 - */ - cleanBeforeRender(): void; - static $updateTextureData(node: sys.NormalBitmapNode, image: BitmapData, bitmapX: number, bitmapY: number, bitmapWidth: number, bitmapHeight: number, offsetX: number, offsetY: number, textureWidth: number, textureHeight: number, destW: number, destH: number, sourceWidth: number, sourceHeight: number, fillMode: string, smoothing: boolean): void; - /** - * @private - * 绘制九宫格位图 - */ - static $updateTextureDataWithScale9Grid(node: sys.NormalBitmapNode, image: BitmapData, scale9Grid: egret.Rectangle, bitmapX: number, bitmapY: number, bitmapWidth: number, bitmapHeight: number, offsetX: number, offsetY: number, textureWidth: number, textureHeight: number, destW: number, destH: number, sourceWidth: number, sourceHeight: number, smoothing: boolean): void; - /** - * @private - */ - private static drawClipImage(node, scale, bitmapX, bitmapY, scaledBitmapW, scaledBitmapH, offsetX, offsetY, destW, destH, startX?, startY?); - } -} -declare namespace egret.sys { - /** - * @private - * 矢量渲染节点 - */ - class GraphicsNode extends RenderNode { - constructor(); - /** - * 指定一种简单的单一颜色填充,在绘制时该填充将在随后对其他 Graphics 方法(如 lineTo() 或 drawCircle())的调用中使用。 - * @param color 填充的颜色 - * @param alpha 填充的 Alpha 值 - * @param beforePath 插入在指定的路径命令之前绘制,通常是插入到当前正在绘制的线条路径之前,以确保线条总在填充的上方。 - */ - beginFill(color: number, alpha?: number, beforePath?: Path2D): Path2D; - /** - * 指定一种简单的单一颜色填充,在绘制时该填充将在随后对其他 Graphics 方法(如 lineTo() 或 drawCircle())的调用中使用。 - * 调用 clear() 方法会清除填充。 - * @param type 用于指定要使用哪种渐变类型的 GradientType 类的值:GradientType.LINEAR 或 GradientType.RADIAL。 - * @param colors 渐变中使用的 RGB 十六进制颜色值的数组(例如,红色为 0xFF0000,蓝色为 0x0000FF,等等)。对于每种颜色,请在 alphas 和 ratios 参数中指定对应值。 - * @param alphas colors 数组中对应颜色的 alpha 值数组。 - * @param ratios 颜色分布比率的数组。有效值为 0 到 255。 - * @param matrix 一个由 egret.Matrix 类定义的转换矩阵。egret.Matrix 类包括 createGradientBox() 方法,通过该方法可以方便地设置矩阵,以便与 beginGradientFill() 方法一起使用 - * @param beforePath 插入在指定的路径命令之前绘制,通常是插入到当前正在绘制的线条路径之前,以确保线条总在填充的上方。 - */ - beginGradientFill(type: string, colors: number[], alphas: number[], ratios: number[], matrix?: egret.Matrix, beforePath?: Path2D): Path2D; - /** - * 指定一种线条样式以用于随后对 lineTo() 或 drawCircle() 等 Graphics 方法的调用。 - * @param thickness 一个整数,以点为单位表示线条的粗细,有效值为 0 到 255。如果未指定数字,或者未定义该参数,则不绘制线条。如果传递的值小于 0,则默认值为 0。值 0 表示极细的粗细;最大粗细为 255。如果传递的值大于 255,则默认值为 255。 - * @param color 线条的十六进制颜色值(例如,红色为 0xFF0000,蓝色为 0x0000FF 等)。如果未指明值,则默认值为 0x000000(黑色)。可选。 - * @param alpha 表示线条颜色的 Alpha 值的数字;有效值为 0 到 1。如果未指明值,则默认值为 1(纯色)。如果值小于 0,则默认值为 0。如果值大于 1,则默认值为 1。 - * @param caps 用于指定线条末端处端点类型的 CapsStyle 类的值。默认值:CapsStyle.ROUND - * @param joints 指定用于拐角的连接外观的类型。默认值:JointStyle.ROUND - * @param miterLimit 用于表示剪切斜接的极限值的数字。 - */ - lineStyle(thickness?: number, color?: number, alpha?: number, caps?: string, joints?: string, miterLimit?: number, lineDash?: number[]): StrokePath; - /** - * 清空所有缓存的绘制数据 - */ - clear(): void; - /** - * 覆盖父类方法,不自动清空缓存的绘图数据,改为手动调用clear()方法清空。 - */ - cleanBeforeRender(): void; - /** - * 绘制x偏移 - */ - x: number; - /** - * 绘制y偏移 - */ - y: number; - /** - * 绘制宽度 - */ - width: number; - /** - * 绘制高度 - */ - height: number; - /** - * 脏渲染标记 - * 暂时调用lineStyle,beginFill,beginGradientFill标记,实际应该draw时候标记在Path2D - */ - dirtyRender: boolean; - $texture: WebGLTexture; - $textureWidth: number; - $textureHeight: number; - $canvasScaleX: number; - $canvasScaleY: number; - /** - * 清除非绘制的缓存数据 - */ - clean(): void; - } -} -declare namespace egret.sys { - /** - * @private - * 组渲染节点,用于组合多个渲染节点 - */ - class GroupNode extends RenderNode { - /** - * 相对偏移矩阵。 - */ - matrix: egret.Matrix; - constructor(); - addNode(node: RenderNode): void; - /** - * 覆盖父类方法,不自动清空缓存的绘图数据,改为手动调用clear()方法清空。 - * 这里只是想清空绘制命令,因此不调用super - */ - cleanBeforeRender(): void; - $getRenderCount(): number; - } -} -declare namespace egret.sys { - /** - * @private - * Mesh 渲染节点 - */ - class MeshNode extends RenderNode { - constructor(); - /** - * 要绘制的位图 - */ - image: BitmapData; - /** - * 控制在缩放时是否对位图进行平滑处理。 - */ - smoothing: boolean; - /** - * 图片宽度。WebGL渲染使用 - */ - imageWidth: number; - /** - * 图片高度。WebGL渲染使用 - */ - imageHeight: number; - /** - * 相对偏移矩阵。 - */ - matrix: egret.Matrix; - /** - * UV 坐标。 - */ - uvs: number[]; - /** - * 顶点坐标。 - */ - vertices: number[]; - /** - * 顶点索引。 - */ - indices: number[]; - /** - * 顶点索引。 - */ - bounds: Rectangle; - /** - * 使用的混合模式 - */ - blendMode: number; - /** - * 相对透明度 - */ - alpha: number; - /** - * 颜色变换滤镜 - */ - filter: ColorMatrixFilter; - /** - * 翻转 - */ - rotated: boolean; - /** - * 绘制一次位图 - */ - drawMesh(sourceX: number, sourceY: number, sourceW: number, sourceH: number, drawX: number, drawY: number, drawW: number, drawH: number): void; - /** - * 在显示对象的$updateRenderNode()方法被调用前,自动清空自身的drawData数据。 - */ - cleanBeforeRender(): void; - } -} -declare namespace egret.sys { - /** - * @private - * 位图渲染节点 - */ - class NormalBitmapNode extends RenderNode { - constructor(); - /** - * 要绘制的位图 - */ - image: BitmapData; - /** - * 控制在缩放时是否对位图进行平滑处理。 - */ - smoothing: boolean; - /** - * 图片宽度。WebGL渲染使用 - */ - imageWidth: number; - /** - * 图片高度。WebGL渲染使用 - */ - imageHeight: number; - /** - * 翻转 - */ - rotated: boolean; - sourceX: number; - sourceY: number; - sourceW: number; - sourceH: number; - drawX: number; - drawY: number; - drawW: number; - drawH: number; - /** - * 绘制一次位图 - */ - drawImage(sourceX: number, sourceY: number, sourceW: number, sourceH: number, drawX: number, drawY: number, drawW: number, drawH: number): void; - /** - * 在显示对象的$updateRenderNode()方法被调用前,自动清空自身的drawData数据。 - */ - cleanBeforeRender(): void; - } -} -declare namespace egret { - /** - * @private - */ - class Mesh extends Bitmap { - constructor(value?: Texture); - protected createNativeDisplayObject(): void; - /** - * @private - */ - protected setBitmapDataToWasm(data?: Texture): void; - /** - * @private - */ - $updateRenderNode(): void; - /** - * @private - */ - private _verticesDirty; - private _bounds; - /** - * @private - */ - $updateVertices(): void; - /** - * @private - */ - $measureContentBounds(bounds: Rectangle): void; - } -} -declare namespace egret.sys { - /** - * @private - * 文本格式 - */ - interface TextFormat { - /** - * 颜色值 - */ - textColor?: number; - /** - * 描边颜色值 - */ - strokeColor?: number; - /** - * 字号 - */ - size?: number; - /** - * 描边大小 - */ - stroke?: number; - /** - * 是否加粗 - */ - bold?: boolean; - /** - * 是否倾斜 - */ - italic?: boolean; - /** - * 字体名称 - */ - fontFamily?: string; - } -} -declare namespace egret.sys { - /** - * @private - * 文本渲染节点 - */ - class TextNode extends RenderNode { - constructor(); - /** - * 颜色值 - */ - textColor: number; - /** - * 描边颜色值 - */ - strokeColor: number; - /** - * 字号 - */ - size: number; - /** - * 描边大小 - */ - stroke: number; - /** - * 是否加粗 - */ - bold: boolean; - /** - * 是否倾斜 - */ - italic: boolean; - /** - * 字体名称 - */ - fontFamily: string; - /** - * 绘制一行文本 - */ - drawText(x: number, y: number, text: string, format: TextFormat): void; - /** - * 绘制x偏移 - */ - x: number; - /** - * 绘制y偏移 - */ - y: number; - /** - * 绘制宽度 - */ - width: number; - /** - * 绘制高度 - */ - height: number; - /** - * 脏渲染标记 - */ - dirtyRender: boolean; - $texture: WebGLTexture; - $textureWidth: number; - $textureHeight: number; - $canvasScaleX: number; - $canvasScaleY: number; - /** - * 清除非绘制的缓存数据 - */ - clean(): void; - /** - * 在显示对象的$updateRenderNode()方法被调用前,自动清空自身的drawData数据。 - */ - cleanBeforeRender(): void; - } -} -declare namespace egret.sys { - /** - * @private - * 填充路径 - */ - class FillPath extends Path2D { - constructor(); - /** - * 填充颜色 - */ - fillColor: number; - /** - * 填充透明度 - */ - fillAlpha: number; - } -} -declare namespace egret.sys { - /** - * @private - * 渐变填充路径 - */ - class GradientFillPath extends Path2D { - constructor(); - gradientType: string; - colors: number[]; - alphas: number[]; - ratios: number[]; - matrix: Matrix; - } -} -declare namespace egret { - /** - * OrientationMode 类为舞台初始旋转模式提供值。 - */ - const OrientationMode: { - AUTO: string; - PORTRAIT: string; - LANDSCAPE: string; - LANDSCAPE_FLIPPED: string; - }; -} -declare namespace egret.sys { - /** - * @private - * 线条路径。 - * 注意:当线条宽度(lineWidth)为1或3像素时,需要特殊处理,往右下角偏移0.5像素,以显示清晰锐利的线条。 - */ - class StrokePath extends Path2D { - constructor(); - /** - * 线条宽度。 - * 注意:绘制时对1像素和3像素要特殊处理,整体向右下角偏移0.5像素,以显示清晰锐利的线条。 - */ - lineWidth: number; - /** - * 线条颜色 - */ - lineColor: number; - /** - * 线条透明度 - */ - lineAlpha: number; - /** - * 端点样式,"none":无端点,"round":圆头端点,"square":方头端点 - */ - caps: string; - /** - * 联接点样式,"bevel":斜角连接,"miter":尖角连接,"round":圆角连接 - */ - joints: string; - /** - * 用于表示剪切斜接的极限值的数字。 - */ - miterLimit: number; - /** - * 描述交替绘制线段和间距(坐标空间单位)长度的数字。 - */ - lineDash: number[]; - } -} -/** - * @private - */ -interface CanvasRenderingContext2D { - imageSmoothingEnabled: boolean; - $imageSmoothingEnabled: boolean; - $offsetX: number; - $offsetY: number; -} -declare namespace egret { - class CanvasRenderer { - private nestLevel; - render(displayObject: DisplayObject, buffer: sys.RenderBuffer, matrix: Matrix, forRenderTexture?: boolean): number; - /** - * @private - * 绘制一个显示对象 - */ - private drawDisplayObject(displayObject, context, offsetX, offsetY, isStage?); - private drawWithFilter(displayObject, context, offsetX, offsetY); - private drawWithClip(displayObject, context, offsetX, offsetY); - private drawWithScrollRect(displayObject, context, offsetX, offsetY); - drawNodeToBuffer(node: sys.RenderNode, buffer: sys.RenderBuffer, matrix: Matrix, forHitTest?: boolean): void; - /** - * 将一个DisplayObject绘制到渲染缓冲,用于RenderTexture绘制 - * @param displayObject 要绘制的显示对象 - * @param buffer 渲染缓冲 - * @param matrix 要叠加的矩阵 - */ - drawDisplayToBuffer(displayObject: DisplayObject, buffer: sys.RenderBuffer, matrix: Matrix): number; - private renderNode(node, context, forHitTest?); - private renderNormalBitmap(node, context); - private renderBitmap(node, context); - private renderMesh(node, context); - renderText(node: sys.TextNode, context: CanvasRenderingContext2D): void; - private renderingMask; - /** - * @private - */ - renderGraphics(node: sys.GraphicsNode, context: CanvasRenderingContext2D, forHitTest?: boolean): number; - private renderPath(path, context); - private renderGroup(groupNode, context); - private createRenderBuffer(width, height, useForFilters?); - } - /** - * @private - * 获取字体字符串 - */ - function getFontString(node: sys.TextNode, format: sys.TextFormat): string; - /** - * @private - * 获取RGBA字符串 - */ - function getRGBAString(color: number, alpha: number): string; -} -declare namespace egret { - /** - * Orientation monitor the orientation of the device, send CHANGE event when the orientation is changed - * - * @event egret.Event.CHANGE device's orientation is changed - * @version Egret 2.4 - * @platform Web - * @includeExample egret/sensor/DeviceOrientation.ts - * @see http://edn.egret.com/cn/docs/page/661 获取设备旋转角度 - * @language en_US - */ - /** - * Orientation 监听设备方向的变化,当方向变化时派发 CHANGE 事件 - * @event egret.Event.CHANGE 设备方向改变时派发 - * @version Egret 2.4 - * @platform Web - * @includeExample egret/sensor/DeviceOrientation.ts - * @see http://edn.egret.com/cn/docs/page/661 获取设备旋转角度 - * @language zh_CN - */ - interface DeviceOrientation extends EventDispatcher { - /** - * Start to monitor the device's orientation - * @version Egret 2.4 - * @platform Web - * @language en_US - */ - /** - * 开始监听设备方向变化 - * @version Egret 2.4 - * @platform Web - * @language zh_CN - */ - start(): void; - /** - * Stop monitor the device's orientation - * @version Egret 2.4 - * @platform Web - * @language en_US - */ - /** - * 停止监听设备方向变化 - * @version Egret 2.4 - * @platform Web - * @language zh_CN - */ - stop(): void; - } - /** - * @copy egret.Orientation - */ - let DeviceOrientation: { - new (): DeviceOrientation; - }; -} -declare namespace egret { - /** - * The Geolocation able to obtain the position of the device. - * Geolocation will emit CHANGE event when the device's location is changed. - * It will emit IO_ERROR event if the location request is denied - * or there is no location service on the device. - * - * @event egret.Event.CHANGE The device's location is changed - * @event egret.Event.IO_ERROR Error occurred while getting the location - * @version Egret 2.4 - * @platform Web - * @includeExample egret/sensor/Geolocation.ts - * @language en_US - */ - /** - * Geolocation 能够从设备的定位服务获取设备的当前位置。 - * 当设备的位置发生改变时 Geolocation 会派发 CHANGE 事件。 - * 当定位请求被拒绝或该设备没有定位服务时 Geolocation 会派发 IO_ERROR 事件。 - * - * @event egret.Event.CHANGE 设备位置发生改变 - * @event egret.Event.IO_ERROR 获取设备位置时发生错误 - * @version Egret 2.4 - * @platform Web - * @includeExample egret/sensor/Geolocation.ts - * @language zh_CN - */ - interface Geolocation extends EventDispatcher { - /** - * Start to monitor the device's location - * @returns - * @version Egret 2.4 - * @platform Web - * @language en_US - */ - /** - * 开始监听设备位置信息 - * @returns - * @version Egret 2.4 - * @platform Web - * @language zh_CN - */ - start(): void; - /** - * Stop monitor the device's location - * @returns - * @version Egret 2.4 - * @platform Web - * @language en_US - */ - /** - * 停止监听设备位置信息 - * @returns - * @version Egret 2.4 - * @platform Web - * @language zh_CN - */ - stop(): void; - } - /** - * @copy egret.Geolocation - */ - let Geolocation: { - /** - * constructor - * @version Egret 2.4 - * @platform Web - * @language en_US - */ - /** - * 构造函数 - * @version Egret 2.4 - * @platform Web - * @language zh_CN - */ - new (): Geolocation; - }; -} -declare namespace egret { - /** - * @copy egret.Motion - */ - let Motion: { - new (): Motion; - }; - /** - * The Motion class emits events based on activity detected by the device's motion sensor. - * This data represents the device's movement along a 3-dimensional axis. When the device moves, - * the sensor detects this movement and emit the CHANGE event. @see egret.MotionEvent - * - * @event egret.Event.CHANGE device is moved - * @version Egret 2.4 - * @platform Web - * @includeExample egret/sensor/Motion.ts - * @language en_US - */ - /** - * Motion 类从用户设备读取运动状态信息并派发 CHANGE 事件。 - * 当设备移动时,传感器会检测到此移动并返回设备加速度,重力和旋转数据。@see egret.MotionEvent - * Motion 类提供了 start 和 stop 方法,来启动和停止运动信息检查 - * - * @event egret.Event.CHANGE 运动状态发生改变 - * @version Egret 2.4 - * @platform Web - * @includeExample egret/sensor/Motion.ts - * @language zh_CN - */ - interface Motion extends EventDispatcher { - /** - * Start to monitor device movement - * @version Egret 2.4 - * @platform Web - * @language en_US - */ - /** - * 开始监听设备运动状态 - * @version Egret 2.4 - * @platform Web - * @language zh_CN - */ - start(): void; - /** - * Stop monitor device movement - * @version Egret 2.4 - * @platform Web - * @language en_US - */ - /** - * 停止监听设备运动状态 - * @version Egret 2.4 - * @platform Web - * @language zh_CN - */ - stop(): void; - } - /** - * A DeviceRotationRate object provides information about the rate at which - * the device is rotating around all three axes. - * @version Egret 2.4 - * @platform Web - * @language en_US - */ - /** - * DeviceRotationRate 提供设备围绕三个轴旋转的角速度信息,单位是 角度/秒 - * @version Egret 2.4 - * @platform Web - * @language zh_CN - */ - interface DeviceRotationRate { - /** - * The amount of rotation around the Z axis, in degrees per second. - * @version Egret 2.4 - * @platform Web - * @language en_US - */ - /** - * 设备绕 Z 轴旋转的角速度信息,单位是 度/秒 - * @version Egret 2.4 - * @platform Web - * @language zh_CN - */ - alpha: number; - /** - * The amount of rotation around the X axis, in degrees per second. - * @version Egret 2.4 - * @platform Web - * @language en_US - */ - /** - * 设备绕 X 轴旋转的角速度信息,单位是 度/秒 - * @version Egret 2.4 - * @platform Web - * @language zh_CN - */ - beta: number; - /** - * The amount of rotation around the Y axis, in degrees per second. - * @version Egret 2.4 - * @platform Web - * @language en_US - */ - /** - * 设备绕 Y 轴旋转的角速度信息,单位是 度/秒 - * @version Egret 2.4 - * @platform Web - * @language zh_CN - */ - gamma: number; - } - /** - * A DeviceAcceleration object provides information about the amount - * of acceleration the device is experiencing along all three axes. - * Acceleration is expressed in m/s2. - * @version Egret 2.4 - * @platform Web - * @language en_US - */ - /** - * DeviceAcceleration 提供设备在三个维度的加速度信息,加速度值的单位是 m/s2 - * @version Egret 2.4 - * @platform Web - * @language zh_CN - */ - interface DeviceAcceleration { - /** - * The amount of acceleration along the X axis - * @version Egret 2.4 - * @platform Web - * @language en_US - */ - /** - * X 轴方向的加速度值 - * @version Egret 2.4 - * @platform Web - * @language zh_CN - */ - x: number; - /** - * The amount of acceleration along the Y axis - * @version Egret 2.4 - * @platform Web - * @language en_US - */ - /** - * Y 轴方向的加速度值 - * @version Egret 2.4 - * @platform Web - * @language zh_CN - */ - y: number; - /** - * The amount of acceleration along the Z axis - * @version Egret 2.4 - * @platform Web - * @language en_US - */ - /** - * Z 轴方向的加速度值 - * @version Egret 2.4 - * @platform Web - * @language zh_CN - */ - z: number; - } -} -declare namespace egret { - /** - * Type of operation. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 运行类型的类型。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - namespace RuntimeType { - /** - * Running on Web - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 运行在Web上 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - const WEB = "web"; - /** - * Running on NATIVE - * @version Egret 2.4 - * @deprecated - * @platform Web,Native - * @language en_US - */ - /** - * 运行在NATIVE上 - * @version Egret 2.4 - * @deprecated - * @platform Web,Native - * @language zh_CN - */ - const NATIVE = "native"; - /** - * Running on Runtime2.0 - * @version Egret 5.1.5 - * @platform Web,Native - * @language en_US - */ - /** - * 运行在Runtime2.0上 - * @version Egret 5.1.5 - * @platform Web,Native - * @language zh_CN - */ - const RUNTIME2 = "runtime2"; - /** - * Running on Alipay - * @version Egret 5.2.33 - * @platform All - * @language en_US - */ - /** - * 运行在支付宝小游戏上 - * @version Egret 5.2.33 - * @platform All - * @language zh_CN - */ - const MYGAME = "mygame"; - /** - * Running on WeChat mini game - * @version Egret 5.1.5 - * @platform All - * @language en_US - */ - /** - * 运行在微信小游戏上 - * @version Egret 5.1.5 - * @platform All - * @language zh_CN - */ - const WXGAME = "wxgame"; - /** - * Running on Baidu mini game - * @version Egret 5.2.13 - * @platform All - * @language en_US - */ - /** - * 运行在百度小游戏上 - * @version Egret 5.2.13 - * @platform All - * @language zh_CN - */ - const BAIDUGAME = "baidugame"; - /** - * Running on Xiaomi quick game - * @version Egret 5.2.14 - * @platform All - * @language en_US - */ - /** - * 运行在小米快游戏上 - * @version Egret 5.2.14 - * @platform All - * @language zh_CN - */ - const QGAME = "qgame"; - /** - * Running on OPPO mini game - * @version Egret 5.2.14 - * @platform All - * @language en_US - */ - /** - * 运行在 Oppo 小游戏上 - * @version Egret 5.2.14 - * @platform All - * @language zh_CN - */ - const OPPOGAME = "oppogame"; - /** - * Running on QQ mini game - * @version Egret 5.2.25 - * @platform All - * @language en_US - */ - /** - * 运行在 QQ 小游戏上 - * @version Egret 5.2.25 - * @platform All - * @language zh_CN - */ - const QQGAME = "qqgame"; - /** - * Running on vivo mini game - * @version Egret 5.2.23 - * @platform All - * @language en_US - */ - /** - * 运行在 vivo 小游戏上 - * @version Egret 5.2.23 - * @platform All - * @language zh_CN - */ - const VIVOGAME = "vivogame"; - } - interface SupportedCompressedTexture { - pvrtc: boolean; - etc1: boolean; - } - /** - * The Capabilities class provides properties that describe the system and runtime that are hosting the application. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/system/Capabilities.ts - * @language en_US - */ - /** - * Capabilities 类提供一些属性,这些属性描述了承载应用程序的系统和运行时。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/system/Capabilities.ts - * @language zh_CN - */ - class Capabilities { - /** - * Specifies the language code of the system on which the content is running. The language is specified as a lowercase - * two-letter language code from ISO 639-1. For Chinese, an additional uppercase two-letter country code from ISO 3166 - * distinguishes between Simplified and Traditional Chinese.
- * The following table lists the possible values,but not limited to them: - *
    - *
  • Simplified Chinese zh-CN
  • - *
  • Traditional Chinese zh-TW
  • - *
  • English en
  • - *
  • Japanese ja
  • - *
  • Korean ko
  • - *
- * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示运行内容的系统的语言代码。语言指定为 ISO 639-1 中的小写双字母语言代码。 - * 对于中文,另外使用 ISO 3166 中的大写双字母国家/地区代码,以区分简体中文和繁体中文。
- * 以下是可能但不限于的语言和值: - *
    - *
  • 简体中文 zh-CN
  • - *
  • 繁体中文 zh-TW
  • - *
  • 英语 en
  • - *
  • 日语 ja
  • - *
  • 韩语 ko
  • - *
- * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static readonly language: string; - /** - * Specifies whether the system is running in a mobile device.(such as a mobile phone or tablet) - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示程序内容是否运行在移动设备中(例如移动电话或平板电脑)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static readonly isMobile: boolean; - /** - * Specifies the current operating system. The os property can return the following strings: - *
    - *
  • iPhone "iOS"
  • - *
  • Android Phone "Android"
  • - *
  • Windows Phone "Windows Phone"
  • - *
  • Windows Desktop "Windows PC"
  • - *
  • Mac Desktop "Mac OS"
  • - *
  • Unknown OS "Unknown"
  • - *
- * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 指示当前的操作系统。os 属性返回下列字符串: - *
    - *
  • 苹果手机操作系统 "iOS"
  • - *
  • 安卓手机操作系统 "Android"
  • - *
  • 微软手机操作系统 "Windows Phone"
  • - *
  • 微软桌面操作系统 "Windows PC"
  • - *
  • 苹果桌面操作系统 "Mac OS"
  • - *
  • 未知操作系统 "Unknown"
  • - *
- * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static readonly os: string; - /** - * It indicates the current type of operation. runtimeType property returns the following string: - *
    - *
  • Run on Web egret.RuntimeType.WEB
  • - *
  • Run on Runtime2.0 egret.RuntimeType.RUNTIME2
  • - *
  • Run on WeChat mini game egret.RuntimeType.WXGAME
  • - *
- * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 指示当前的运行类型。runtimeType 属性返回下列字符串: - *
    - *
  • 运行在Web上 egret.RuntimeType.WEB
  • - *
  • 运行在Runtime2.0上 egret.RuntimeType.RUNTIME2
  • - *
  • 运行在微信小游戏上 egret.RuntimeType.WXGAME
  • - *
- * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static readonly runtimeType: string; - /*** - * version of Egret. - * @type {string} - * @version Egret 3.2.0 - * @platform Web,Native - * @language en_US - */ - /*** - * Egret 的版本号。 - * @type {string} - * @version Egret 3.2.0 - * @platform Web,Native - * @language zh_CN - */ - static readonly engineVersion: string; - /*** - * current render mode. - * @type {string} - * @version Egret 3.0.7 - * @platform Web,Native - * @language en_US - */ - /*** - * 当前渲染模式。 - * @type {string} - * @version Egret 3.0.7 - * @platform Web,Native - * @language zh_CN - */ - static readonly renderMode: string; - /*** - * Clients border width. - * The value before the document class initialization is always 0. - * This value will change after the distribution Event.RESIZE and StageOrientationEvent.ORIENTATION_CHANGE. - * @version Egret 3.1.3 - * @platform Web,Native - * @language en_US - */ - /*** - * 客户端边界宽度。 - * 该值在文档类初始化之前始终是0。 - * 该值在派发 Event.RESIZE 以及 StageOrientationEvent.ORIENTATION_CHANGE 之后会发生改变。 - * @version Egret 3.1.3 - * @platform Web,Native - * @language zh_CN - */ - static readonly boundingClientWidth: number; - /*** - * Clients border height. - * The value before the document class initialization is always 0. - * This value will change after the distribution Event.RESIZE and StageOrientationEvent.ORIENTATION_CHANGE. - * @version Egret 3.1.3 - * @platform Web,Native - * @language en_US - */ - /*** - * 客户端边界高度。 - * 该值在文档类初始化之前始终是0。 - * 该值在派发 Event.RESIZE 以及 StageOrientationEvent.ORIENTATION_CHANGE 之后会发生改变。 - * @version Egret 3.1.3 - * @platform Web,Native - * @language zh_CN - */ - static readonly boundingClientHeight: number; - /*** - * supported compressed texture - * @version Egret 5.2.19 - * @platform Web,Native - * @language en_US - */ - /*** - * supported compressed texture - * @version Egret 5.2.19 - * @platform Web,Native - * @language zh_CN - */ - static supportedCompressedTexture: SupportedCompressedTexture; - } -} -declare namespace egret { - /** - * RenderTexture is a dynamic texture - * @extends egret.Texture - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/RenderTexture.ts - * @language en_US - */ - /** - * RenderTexture 是动态纹理类,他实现了将显示对象及其子对象绘制成为一个纹理的功能 - * @extends egret.Texture - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/RenderTexture.ts - * @language zh_CN - */ - class RenderTexture extends egret.Texture { - constructor(); - $renderBuffer: sys.RenderBuffer; - /** - * The specified display object is drawn as a texture - * @param displayObject {egret.DisplayObject} the display to draw - * @param clipBounds {egret.Rectangle} clip rect - * @param scale {number} scale factor - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将指定显示对象绘制为一个纹理 - * @param displayObject {egret.DisplayObject} 需要绘制的显示对象 - * @param clipBounds {egret.Rectangle} 绘制矩形区域 - * @param scale {number} 缩放比例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - drawToTexture(displayObject: egret.DisplayObject, clipBounds?: Rectangle, scale?: number): boolean; - /** - * @inheritDoc - */ - getPixel32(x: number, y: number): number[]; - /** - * @inheritDoc - */ - dispose(): void; - } -} -declare namespace egret { - /** - * Adds an interface-name-to-implementation-class mapping to the registry. - * @param interfaceName the interface name to register. For example:"eui.IAssetAdapter","eui.Theme" - * @param instance the instance to register. - * @version Egret 3.2.1 - * @platform Web,Native - * @language en_US - */ - /** - * 注册一个接口实现。 - * @param interfaceName 注入的接口名称。例如:"eui.IAssetAdapter","eui.Theme" - * @param instance 实现此接口的实例。 - * @version Egret 3.2.1 - * @platform Web,Native - * @language zh_CN - */ - function registerImplementation(interfaceName: string, instance: any): void; - /** - * Returns the singleton instance of the implementation class that was registered for the specified interface. - * This method is usually called by egret framework. - * @param interfaceName The interface name to identify. For example:"eui.IAssetAdapter","eui.Theme" - * @returns the singleton instance of the implementation class - * @version Egret 3.2.1 - * @platform Web,Native - * @language en_US - */ - /** - * 获取一个接口实现。此方法通常由框架内部调用。获取项目注入的自定义实现实例。 - * @param interfaceName 要获取的接口名称。例如:"eui.IAssetAdapter","eui.Theme" - * @returns 返回实现此接口的实例。 - * @version Egret 3.2.1 - * @platform Web,Native - * @language zh_CN - */ - function getImplementation(interfaceName: string): any; -} -declare namespace egret { - /** - * This class is used to create lightweight shapes using the drawing application program interface (API). The Shape - * class includes a graphics property, which lets you access methods from the Graphics class. - * @see egret.Graphics - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/Shape.ts - * @language en_US - */ - /** - * 此类用于使用绘图应用程序编程接口 (API) 创建简单形状。Shape 类含有 graphics 属性,通过该属性您可以访问各种矢量绘图方法。 - * @see egret.Graphics - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/Shape.ts - * @language zh_CN - */ - class Shape extends DisplayObject { - /** - * Creates a new Shape object. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 Shape 对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(); - protected createNativeDisplayObject(): void; - /** - * @private - */ - $graphics: Graphics; - /** - * Specifies the Graphics object belonging to this Shape object, where vector drawing commands can occur. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 获取 Shape 中的 Graphics 对象。可通过此对象执行矢量绘图命令。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly graphics: Graphics; - /** - * @private - */ - $measureContentBounds(bounds: Rectangle): void; - $hitTest(stageX: number, stageY: number): DisplayObject; - /** - * @private - */ - $onRemoveFromStage(): void; - } -} -declare namespace egret { - /** - * Bitmap font, texture set of a font. It is generally used as the value of the BitmapText.font attribute. - * @see http://bbs.egret-labs.org/thread-918-1-1.html TextureMerger - * @see http://bbs.egret-labs.org/forum.php?mod=viewthread&tid=251 Text(Containing the specific usage of the bitmap font ) - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/text/BitmapFont.ts - * @language en_US - */ - /** - * 位图字体,是一个字体的纹理集,通常作为BitmapText.font属性的值。 - * @see http://bbs.egret-labs.org/thread-918-1-1.html TextureMerger - * @see http://bbs.egret-labs.org/forum.php?mod=viewthread&tid=251 文本(含位图字体具体用法) - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/text/BitmapFont.ts - * @language zh_CN - */ - class BitmapFont extends SpriteSheet { - /** - * Create an egret.BitmapFont object - * @param texture {egret.Texture} Texture set that use TextureMerger create - * @param config {any} Configure data that use TextureMerger create - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 egret.BitmapFont 对象 - * @param texture {egret.Texture} 使用TextureMerger生成的纹理集 - * @param config {any} 使用TextureMerger生成的配置数据 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(texture: Texture, config: any); - /** - * @private - */ - private charList; - /** - * Obtain corresponding texture through the name attribute - * @param name {string} name Attribute - * @returns {egret.Texture} - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 通过 name 属性获取对应纹理 - * @param name {string} name属性 - * @returns {egret.Texture} - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - getTexture(name: string): Texture; - /** - * @private - */ - getConfig(name: string, key: string): number; - /** - * @private - */ - private firstCharHeight; - /** - * @private - * - * @returns - */ - _getFirstCharHeight(): number; - /** - * @private - * - * @param fntText - * @returns - */ - private parseConfig(fntText); - /** - * @private - * - * @param configText - * @param key - * @returns - */ - private getConfigByKey(configText, key); - } -} -declare namespace egret { - /** - * Bitmap font adopts the Bitmap+SpriteSheet mode to render text. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/text/BitmapText.ts - * @language en_US - */ - /** - * 位图字体采用了Bitmap+SpriteSheet的方式来渲染文字。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/text/BitmapText.ts - * @language zh_CN - */ - class BitmapText extends DisplayObject { - /** - * Create an egret.BitmapText object - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 创建一个 egret.BitmapText 对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(); - protected createNativeDisplayObject(): void; - private $smoothing; - /** - * Whether or not is smoothed when scaled. - * @default true。 - * @version Egret 3.0 - * @platform Web - * @language en_US - */ - /** - * 控制在缩放时是否进行平滑处理。 - * @default true。 - * @version Egret 3.0 - * @platform Web - * @language zh_CN - */ - smoothing: boolean; - private $text; - /** - * A string to display in the text field. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 要显示的文本内容 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - text: string; - /** - * @private - */ - $setText(value: string): boolean; - protected $textFieldWidth: number; - /** - * @private - */ - $getWidth(): number; - /** - * @private - */ - $setWidth(value: number): boolean; - private $textLinesChanged; - /** - * @private - */ - $invalidateContentBounds(): void; - protected $textFieldHeight: number; - /** - * @private - */ - $getHeight(): number; - /** - * @private - */ - $setHeight(value: number): boolean; - protected $font: BitmapFont; - protected $fontStringChanged: boolean; - /** - * The name of the font to use, or a comma-separated list of font names, the type of value must be BitmapFont. - * @default null - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 要使用的字体的名称或用逗号分隔的字体名称列表,类型必须是 BitmapFont。 - * @default null - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - font: Object; - $setFont(value: any): boolean; - private $lineSpacing; - /** - /** - * An integer representing the amount of vertical space between lines. - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 一个整数,表示行与行之间的垂直间距量 - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - lineSpacing: number; - $setLineSpacing(value: number): boolean; - private $letterSpacing; - /** - * An integer representing the amount of distance between characters. - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 一个整数,表示字符之间的距离。 - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - letterSpacing: number; - $setLetterSpacing(value: number): boolean; - private $textAlign; - /** - * Horizontal alignment of text. - * @default:egret.HorizontalAlign.LEFT - * @version Egret 2.5.6 - * @platform Web,Native - * @language en_US - */ - /** - * 文本的水平对齐方式。 - * @default:egret.HorizontalAlign.LEFT - * @version Egret 2.5.6 - * @platform Web,Native - * @language zh_CN - */ - textAlign: string; - $setTextAlign(value: string): boolean; - private $verticalAlign; - /** - * Vertical alignment of text. - * @default:egret.VerticalAlign.TOP - * @version Egret 2.5.6 - * @platform Web,Native - * @language en_US - */ - /** - * 文字的垂直对齐方式。 - * @default:egret.VerticalAlign.TOP - * @version Egret 2.5.6 - * @platform Web,Native - * @language zh_CN - */ - verticalAlign: string; - $setVerticalAlign(value: string): boolean; - /** - * A ratio of the width of the space character. This value is multiplied by the height of the first character is the space character width. - * @default 0.33 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 一个空格字符的宽度比例。这个数值乘以第一个字符的高度即为空格字符的宽。 - * @default 0.33 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static EMPTY_FACTOR: number; - /** - * @private - */ - $updateRenderNode(): void; - /** - * @private - */ - $measureContentBounds(bounds: Rectangle): void; - private $textWidth; - /** - * Get the BitmapText measured width - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 获取位图文本测量宽度 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly textWidth: number; - private $textHeight; - /** - * Get Text BitmapText height - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 获取位图文本测量高度 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly textHeight: number; - /** - * @private - */ - private $textOffsetX; - /** - * @private - */ - private $textOffsetY; - /** - * @private - */ - private $textStartX; - /** - * @private - */ - private $textStartY; - /** - * @private - */ - private textLines; - /** - * @private 每一行文字的宽度 - */ - private $textLinesWidth; - /** - * @private - */ - $lineHeights: number[]; - /** - * @private - * - * @returns - */ - $getTextLines(): string[]; - } -} -declare namespace egret { - /** - * The HorizontalAlign class defines the possible values for the horizontal alignment. - * @see egret.TextField#textAlign - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * HorizontalAlign 类为水平对齐方式定义可能的值。 - * @see egret.TextField#textAlign - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - class HorizontalAlign { - /** - * Horizontally align content to the left of the container. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将内容与容器的左侧对齐。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static LEFT: string; - /** - * Horizontally align content to the right of the container. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将内容与容器的右侧对齐。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static RIGHT: string; - /** - * Horizontally align content in the center of the container. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 在容器的水平中心对齐内容。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static CENTER: string; - /** - * Horizontal alignment with both edges. - * Note: TextFiled does not support this alignment method. - * @constant egret.HorizontalAlign.JUSTIFY - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 水平两端对齐。 - * 注意:TextFiled不支持此对齐方式。 - * @constant egret.HorizontalAlign.JUSTIFY - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static JUSTIFY: string; - /** - * Align the content of the child items, relative to the container. This operation will adjust uniformly the size of all the child items to be the Content Width \" of the container \". - * The Content Width \" of the container \" is the size of the max. child item. If the size of all child items are less than the width of the container, they will be adjusted to the width of the container. - * Note: TextFiled does not support this alignment method. - * @constant egret.HorizontalAlign.CONTENT_JUSTIFY - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 相对于容器对子项进行内容对齐。这会将所有子项的大小统一调整为容器的"内容宽度"。 - * 容器的"内容宽度"是最大子项的大小,如果所有子项都小于容器的宽度,则会将所有子项的大小调整为容器的宽度。 - * 注意:TextFiled不支持此对齐方式。 - * @constant egret.HorizontalAlign.CONTENT_JUSTIFY - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static CONTENT_JUSTIFY: string; - } -} -declare namespace egret { - /** - * Convert the text in html format to the object that can be assigned to the egret.TextField#textFlow property - * @see http://edn.egret.com/cn/docs/page/146 Text mixed in a variety of style - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/text/HtmlTextParser.ts - * @language en_US - */ - /** - * 将html格式文本转换为可赋值给 egret.TextField#textFlow 属性的对象 - * @see http://edn.egret.com/cn/docs/page/146 多种样式文本混合 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/text/HtmlTextParser.ts - * @language zh_CN - */ - class HtmlTextParser { - /** - * @version Egret 2.4 - * @platform Web,Native - */ - constructor(); - private replaceArr; - private initReplaceArr(); - /** - * @private - * - * @param value - * @returns - */ - private replaceSpecial(value); - /** - * @private - */ - private resutlArr; - /** - * Convert the text in html format to the object that can be assigned to the egret.TextField#textFlow property - * @param htmltext {string} Text in html - * @returns {Array} 可赋值给 egret.TextField#textFlow Object that can be assigned to the egret.TextField#textFlow property - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将html格式文本转换为可赋值给 egret.TextField#textFlow 属性的对象 - * @param htmltext {string} html文本 - * @returns {Array} 可赋值给 egret.TextField#textFlow 属性的对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - parse(htmltext: string): egret.ITextElement[]; - parser(htmltext: string): Array; - /** - * @private - * - * @param value - */ - private addToResultArr(value); - private changeStringToObject(str); - /** - * @private - * - * @returns - */ - private getHeadReg(); - /** - * @private - * - * @param info - * @param head - * @param value - */ - private addProperty(info, head, value); - /** - * @private - */ - private stackArray; - /** - * @private - * - * @param infoStr - */ - private addToArray(infoStr); - } -} -declare namespace egret { - /** - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - interface IHitTextElement { - /** - * @version Egret 2.4 - * @platform Web,Native - */ - lineIndex: number; - /** - * @version Egret 2.4 - * @platform Web,Native - */ - textElementIndex: number; - } - /** - * Text Style - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 文本样式 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - interface ITextStyle { - /** - * text color - * @version Egret 2.4 - * @platform Web,Native - * @see http://edn.egret.com/cn/docs/page/146 多种样式混合文本的基本结构 - * @language en_US - */ - /** - * 颜色值 - * @version Egret 2.4 - * @platform Web,Native - * @see http://edn.egret.com/cn/docs/page/146 多种样式混合文本的基本结构 - * @language zh_CN - */ - textColor?: number; - /** - * stroke color - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 描边颜色值 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - strokeColor?: number; - /** - * size - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 字号 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - size?: number; - /** - * stroke width - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 描边大小 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - stroke?: number; - /** - * whether bold - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 是否加粗 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - bold?: boolean; - /** - * whether italic - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 是否倾斜 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - italic?: boolean; - /** - * fontFamily - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 字体名称 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - fontFamily?: string; - /** - * Link events or address - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 链接事件或者地址 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - href?: string; - /** - * @private - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * @private - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - target?: string; - /** - * Is underlined - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 是否加下划线 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - underline?: boolean; - } - /** - * Used to build the basic structure of text with a variety of mixed styles, mainly for setting textFlow property - * @see http://edn.egret.com/cn/docs/page/146 Text mixed in a variety of style - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 用于建立多种样式混合文本的基本结构,主要用于设置 textFlow 属性 - * @see http://edn.egret.com/cn/docs/page/146 多种样式文本混合 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - interface ITextElement { - /** - * String Content - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 字符串内容 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - text: string; - /** - * Text Style - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 文本样式 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - style?: ITextStyle; - } - /** - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - interface IWTextElement extends ITextElement { - /** - * @version Egret 2.4 - * @platform Web,Native - */ - width: number; - } - /** - * 文本最终解析的一行数据格式 - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - interface ILineElement { - /** - * 文本占用宽度 - * @version Egret 2.4 - * @platform Web,Native - */ - width: number; - /** - * 文本占用高度 - * @version Egret 2.4 - * @platform Web,Native - */ - height: number; - /** - * 当前文本字符总数量(包括换行符) - * @version Egret 2.4 - * @platform Web,Native - */ - charNum: number; - /** - * 是否含有换行符 - * @version Egret 2.4 - * @platform Web,Native - */ - hasNextLine: boolean; - /** - * 本行文本内容 - * @version Egret 2.4 - * @platform Web,Native - */ - elements: Array; - } -} -declare namespace egret { - /** - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - class InputController extends HashObject { - /** - * @private - */ - stageText: egret.StageText; - /** - * @private - */ - private stageTextAdded; - /** - * @private - */ - private _text; - /** - * @private - */ - private _isFocus; - /** - * @version Egret 2.4 - * @platform Web,Native - */ - constructor(); - /** - * - * @param text - * @version Egret 2.4 - * @platform Web,Native - */ - init(text: TextField): void; - /** - * @private - * - */ - _addStageText(): void; - /** - * @private - * - */ - _removeStageText(): void; - /** - * @private - * - * @returns - */ - _getText(): string; - /** - * @private - * - * @param value - */ - _setText(value: string): void; - /** - * @private - */ - _setColor(value: number): void; - /** - * @private - * - * @param event - */ - private focusHandler(event); - /** - * @private - * - * @param event - */ - private blurHandler(event); - private tempStage; - private onMouseDownHandler(event); - $onFocus(): void; - private onStageDownHandler(event); - /** - * @private - * - * @param event - */ - private updateTextHandler(event); - /** - * @private - * - */ - private resetText(); - /** - * @private - * - */ - _hideInput(): void; - /** - * @private - * - */ - private updateInput(); - /** - * @private - * - */ - _updateProperties(): void; - } -} -declare namespace egret { - /** - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - interface StageText extends EventDispatcher { - /** - * @private - */ - $textfield: egret.TextField; - /** - * @private - * - * @param textfield - */ - $setTextField(textfield: egret.TextField): boolean; - /** - * @private - * - */ - $resetStageText(): void; - /** - * @private - * - * @returns - */ - $getText(): string; - /** - * @private - * - * @param value - */ - $setText(value: string): boolean; - /** - * @private - * - * @param value - */ - $setColor(value: number): boolean; - /** - * @private - * - */ - $show(): void; - /** - * @private - * - */ - $hide(): void; - /** - * @private - * - */ - $addToStage(): void; - /** - * @private - * - */ - $removeFromStage(): void; - /** - * @private - * - */ - $onBlur(): void; - } - /** - * @version Egret 2.4 - * @platform Web,Native - */ - let StageText: { - new (): StageText; - }; -} -declare namespace egret.sys { - /** - * @private - */ - const enum TextKeys { - /** - * @private - */ - fontSize = 0, - /** - * @private - */ - lineSpacing = 1, - /** - * @private - */ - textColor = 2, - /** - * @private - */ - textFieldWidth = 3, - /** - * @private - */ - textFieldHeight = 4, - /** - * @private - */ - textWidth = 5, - /** - * @private - */ - textHeight = 6, - /** - * @private - */ - textDrawWidth = 7, - /** - * @private - */ - fontFamily = 8, - /** - * @private - */ - textAlign = 9, - /** - * @private - */ - verticalAlign = 10, - /** - * @private - */ - textColorString = 11, - /** - * @private - */ - fontString = 12, - /** - * @private - */ - text = 13, - /** - * @private - */ - measuredWidths = 14, - /** - * @private - */ - bold = 15, - /** - * @private - */ - italic = 16, - /** - * @private - */ - fontStringChanged = 17, - /** - * @private - */ - textLinesChanged = 18, - /** - * @private - */ - wordWrap = 19, - /** - * @private - */ - displayAsPassword = 20, - /** - * @private - */ - maxChars = 21, - /** - * @private - */ - selectionActivePosition = 22, - /** - * @private - */ - selectionAnchorPosition = 23, - /** - * @private - */ - type = 24, - /** - * @private - */ - strokeColor = 25, - /** - * @private - */ - strokeColorString = 26, - /** - * @private - */ - stroke = 27, - /** - * @private - */ - scrollV = 28, - /** - * @private - */ - numLines = 29, - /** - * @private - */ - multiline = 30, - /** - * @private - */ - border = 31, - /** - * @private - */ - borderColor = 32, - /** - * @private - */ - background = 33, - /** - * @private - */ - backgroundColor = 34, - /** - * @private - */ - restrictAnd = 35, - /** - * @private - */ - restrictNot = 36, - /** - * @private - */ - inputType = 37, - /** - * @private - */ - textLinesChangedForNativeRender = 38, - } -} -declare namespace egret { - /** - * TextField is the text rendering class of egret. It conducts rendering by using the browser / device API. Due to different ways of font rendering in different browsers / devices, there may be differences in the rendering - * If developers expect no differences among all platforms, please use BitmapText - * @see http://edn.egret.com/cn/docs/page/141 Create Text - * - * @event egret.Event.CHANGE Dispatched when entering text user input。 - * @event egret.FocusEvent.FOCUS_IN Dispatched after the focus to enter text. - * @event egret.FocusEvent.FOCUS_OUT Enter the text loses focus after dispatch. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/text/TextField.ts - * @language en_US - */ - /** - * TextField是egret的文本渲染类,采用浏览器/设备的API进行渲染,在不同的浏览器/设备中由于字体渲染方式不一,可能会有渲染差异 - * 如果开发者希望所有平台完全无差异,请使用BitmapText - * @see http://edn.egret.com/cn/docs/page/141 创建文本 - * - * @event egret.Event.CHANGE 输入文本有用户输入时调度。 - * @event egret.FocusEvent.FOCUS_IN 聚焦输入文本后调度。 - * @event egret.FocusEvent.FOCUS_OUT 输入文本失去焦点后调度。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/text/TextField.ts - * @language zh_CN - */ - class TextField extends DisplayObject { - /** - * default fontFamily - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 默认文本字体 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static default_fontFamily: string; - /** - * default size in pixels of text - * @version Egret 3.2.1 - * @platform Web,Native - * @language en_US - */ - /** - * 默认文本字号大小 - * @version Egret 3.2.1 - * @platform Web,Native - * @language zh_CN - */ - static default_size: number; - /** - * default color of the text. - * @version Egret 3.2.1 - * @platform Web,Native - * @language en_US - */ - /** - * 默认文本颜色 - * @version Egret 3.2.1 - * @platform Web,Native - * @language zh_CN - */ - static default_textColor: number; - /** - * @version Egret 2.4 - * @platform Web,Native - */ - constructor(); - protected createNativeDisplayObject(): void; - /** - * @private - */ - $TextField: Object; - /** - * @private - */ - private isInput(); - $inputEnabled: boolean; - $setTouchEnabled(value: boolean): void; - /** - * The name of the font to use, or a comma-separated list of font names. - * @default "Arial" - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 要使用的字体的名称或用逗号分隔的字体名称列表。 - * @default "Arial" - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - fontFamily: string; - $setFontFamily(value: string): boolean; - /** - * The size in pixels of text - * @default 30 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 文本的字号大小。 - * @default 30 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - size: number; - $setSize(value: number): boolean; - /** - * Specifies whether the text is boldface. - * @default false - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 是否显示为粗体。 - * @default false - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - bold: boolean; - $setBold(value: boolean): boolean; - /** - * Determines whether the text is italic font. - * @default false - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 是否显示为斜体。 - * @default false - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - italic: boolean; - $setItalic(value: boolean): boolean; - /** - * @private - * - */ - private invalidateFontString(); - /** - * Horizontal alignment of text. - * @default:egret.HorizontalAlign.LEFT - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 文本的水平对齐方式。 - * @default:egret.HorizontalAlign.LEFT - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - textAlign: string; - $setTextAlign(value: string): boolean; - /** - * Vertical alignment of text. - * @default:egret.VerticalAlign.TOP - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 文字的垂直对齐方式。 - * @default:egret.VerticalAlign.TOP - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - verticalAlign: string; - $setVerticalAlign(value: string): boolean; - /** - * An integer representing the amount of vertical space between lines. - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 一个整数,表示行与行之间的垂直间距量 - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - lineSpacing: number; - $setLineSpacing(value: number): boolean; - /** - * Color of the text. - * @default 0x000000 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 文本颜色 - * @default 0x000000 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - textColor: number; - $setTextColor(value: number): boolean; - /** - * A Boolean value that indicates whether the text field word wrap. If the value is true, then the text field by word wrap; - * if the value is false, the text field by newline characters. - * @default false - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 一个布尔值,表示文本字段是否按单词换行。如果值为 true,则该文本字段按单词换行; - * 如果值为 false,则该文本字段按字符换行。 - * @default false - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - wordWrap: boolean; - $setWordWrap(value: boolean): void; - protected inputUtils: InputController; - /** - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * Type of the text field. - * Any one of the following TextFieldType constants: TextFieldType.DYNAMIC (specifies the dynamic text field that users can not edit), or TextFieldType.INPUT (specifies the dynamic text field that users can edit). - * @default egret.TextFieldType.DYNAMIC - * @language en_US - */ - /** - * 文本字段的类型。 - * 以下 TextFieldType 常量中的任一个:TextFieldType.DYNAMIC(指定用户无法编辑的动态文本字段),或 TextFieldType.INPUT(指定用户可以编辑的输入文本字段)。 - * @default egret.TextFieldType.DYNAMIC - * @language zh_CN - */ - type: string; - /** - * @private - * - * @param value - */ - $setType(value: string): boolean; - /** - * @version Egret 3.1.2 - * @platform Web,Native - */ - /** - * Pop-up keyboard type. - * Any of a TextFieldInputType constants. - * @language en_US - */ - /** - * 弹出键盘的类型。 - * TextFieldInputType 常量中的任一个。 - * @language zh_CN - */ - inputType: string; - /** - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * Serve as a string of the current text field in the text - * @language en_US - */ - /** - * 作为文本字段中当前文本的字符串 - * @language zh_CN - */ - text: string; - /** - * @private - * - * @returns - */ - $getText(): string; - /** - * @private - * - * @param value - */ - $setBaseText(value: string): boolean; - /** - * @private - * - * @param value - */ - $setText(value: string): boolean; - /** - * Specify whether the text field is a password text field. - * If the value of this property is true, the text field is treated as a password text field and hides the input characters using asterisks instead of the actual characters. If false, the text field is not treated as a password text field. - * @default false - * @language en_US - */ - /** - * 指定文本字段是否是密码文本字段。 - * 如果此属性的值为 true,则文本字段被视为密码文本字段,并使用星号而不是实际字符来隐藏输入的字符。如果为 false,则不会将文本字段视为密码文本字段。 - * @default false - * @language zh_CN - */ - displayAsPassword: boolean; - /** - * @private - * - * @param value - */ - $setDisplayAsPassword(value: boolean): boolean; - /** - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * Represent the stroke color of the text. - * Contain three 8-bit numbers with RGB color components; for example, 0xFF0000 is red, 0x00FF00 is green. - * @default 0x000000 - * @language en_US - */ - /** - * 表示文本的描边颜色。 - * 包含三个 8 位 RGB 颜色成分的数字;例如,0xFF0000 为红色,0x00FF00 为绿色。 - * @default 0x000000 - * @language zh_CN - */ - strokeColor: number; - /** - * @private - * - * @param value - */ - $setStrokeColor(value: number): boolean; - /** - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * Indicate the stroke width. - * 0 means no stroke. - * @default 0 - * @language en_US - */ - /** - * 表示描边宽度。 - * 0为没有描边。 - * @default 0 - * @language zh_CN - */ - stroke: number; - /** - * @private - * - * @param value - */ - $setStroke(value: number): boolean; - /** - * The maximum number of characters that the text field can contain, as entered by a user. \n A script can insert more text than maxChars allows; the maxChars property indicates only how much text a user can enter. If the value of this property is 0, a user can enter an unlimited amount of text. - * The default value is 0. - * @default 0 - * @language en_US - */ - /** - * 文本字段中最多可包含的字符数(即用户输入的字符数)。 - * 脚本可以插入比 maxChars 允许的字符数更多的文本;maxChars 属性仅表示用户可以输入多少文本。如果此属性的值为 0,则用户可以输入无限数量的文本。 - * @default 0 - * @language zh_CN - */ - maxChars: number; - /** - * @private - * - * @param value - */ - $setMaxChars(value: number): boolean; - /** - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * Vertical position of text in a text field. scrollV property helps users locate specific passages in a long article, and create scrolling text fields. - * Vertically scrolling units are lines, and horizontal scrolling unit is pixels. - * If the first displayed line is the first line in the text field, scrollV is set to 1 (instead of 0). - * @language en_US - */ - /** - * 文本在文本字段中的垂直位置。scrollV 属性可帮助用户定位到长篇文章的特定段落,还可用于创建滚动文本字段。 - * 垂直滚动的单位是行,而水平滚动的单位是像素。 - * 如果显示的第一行是文本字段中的第一行,则 scrollV 设置为 1(而非 0)。 - * @language zh_CN - */ - scrollV: number; - /** - * The maximum value of scrollV - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * scrollV 的最大值 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly maxScrollV: number; - /** - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - readonly selectionBeginIndex: number; - /** - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - readonly selectionEndIndex: number; - /** - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - readonly caretIndex: number; - /** - * @private - * - * @param beginIndex - * @param endIndex - */ - $setSelection(beginIndex: number, endIndex: number): boolean; - /** - * @private - * - * @returns - */ - $getLineHeight(): number; - /** - * Number of lines of text. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 文本行数。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly numLines: number; - /** - * Indicate whether field is a multiline text field. Note that this property is valid only when the type is TextFieldType.INPUT. - * If the value is true, the text field is multiline; if the value is false, the text field is a single-line text field. In a field of type TextFieldType.INPUT, the multiline value determines whether the Enter key creates a new line (a value of false, and the Enter key is ignored). - * @default false - * @language en_US - */ - /** - * 表示字段是否为多行文本字段。注意,此属性仅在type为TextFieldType.INPUT时才有效。 - * 如果值为 true,则文本字段为多行文本字段;如果值为 false,则文本字段为单行文本字段。在类型为 TextFieldType.INPUT 的字段中,multiline 值将确定 Enter 键是否创建新行(如果值为 false,则将忽略 Enter 键)。 - * @default false - * @language zh_CN - */ - multiline: boolean; - /** - * @private - * - * @param value - */ - $setMultiline(value: boolean): boolean; - /** - * Indicates a user can enter into the text field character set. If you restrict property is null, you can enter any character. If you restrict property is an empty string, you can not enter any character. If you restrict property is a string of characters, you can enter only characters in the string in the text field. The string is scanned from left to right. You can use a hyphen (-) to specify a range. Only restricts user interaction; a script may put any text into the text field.
- * If the string of characters caret (^) at the beginning, all characters are initially accepted, then the string are excluded from receiving ^ character. If the string does not begin with a caret (^) to, any characters are initially accepted and then a string of characters included in the set of accepted characters.
- * The following example allows only uppercase characters, spaces, and numbers in the text field:
- * My_txt.restrict = "A-Z 0-9";
- * The following example includes all characters except lowercase letters:
- * My_txt.restrict = "^ a-z";
- * If you need to enter characters \ ^, use two backslash "\\ -" "\\ ^":
- * Can be used anywhere in the string ^ to rule out including characters and switch between characters, but can only be used to exclude a ^. The following code includes only uppercase letters except uppercase Q:
- * My_txt.restrict = "A-Z ^ Q";
- * @version Egret 2.4 - * @platform Web,Native - * @default null - * @language en_US - */ - /** - * 表示用户可输入到文本字段中的字符集。如果 restrict 属性的值为 null,则可以输入任何字符。如果 restrict 属性的值为空字符串,则不能输入任何字符。如果 restrict 属性的值为一串字符,则只能在文本字段中输入该字符串中的字符。从左向右扫描该字符串。可以使用连字符 (-) 指定一个范围。只限制用户交互;脚本可将任何文本放入文本字段中。
- * 如果字符串以尖号 (^) 开头,则先接受所有字符,然后从接受字符集中排除字符串中 ^ 之后的字符。如果字符串不以尖号 (^) 开头,则最初不接受任何字符,然后将字符串中的字符包括在接受字符集中。
- * 下例仅允许在文本字段中输入大写字符、空格和数字:
- * my_txt.restrict = "A-Z 0-9";
- * 下例包含除小写字母之外的所有字符:
- * my_txt.restrict = "^a-z";
- * 如果需要输入字符 \ ^,请使用2个反斜杠 "\\-" "\\^" :
- * 可在字符串中的任何位置使用 ^,以在包含字符与排除字符之间进行切换,但是最多只能有一个 ^ 用来排除。下面的代码只包含除大写字母 Q 之外的大写字母:
- * my_txt.restrict = "A-Z^Q";
- * @version Egret 2.4 - * @platform Web,Native - * @default null - * @language zh_CN - */ - restrict: string; - /** - * @private - * - * @param value - */ - $setWidth(value: number): boolean; - /** - * @private - * - * @param value - */ - $setHeight(value: number): boolean; - /** - * @private - * 获取显示宽度 - */ - $getWidth(): number; - /** - * @private - * 获取显示宽度 - */ - $getHeight(): number; - /** - * @private - */ - private textNode; - /** - * @private - */ - $graphicsNode: sys.GraphicsNode; - /** - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * Specifies whether the text field has a border. - * If true, the text field has a border. If false, the text field has no border. - * Use borderColor property to set the border color. - * @default false - * @language en_US - */ - /** - * 指定文本字段是否具有边框。 - * 如果为 true,则文本字段具有边框。如果为 false,则文本字段没有边框。 - * 使用 borderColor 属性来设置边框颜色。 - * @default false - * @language zh_CN - */ - border: boolean; - /** - * @private - */ - $setBorder(value: boolean): void; - /** - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * The color of the text field border. - * Even currently is no border can be retrieved or set this property, but only if the text field has the border property is set to true, the color is visible. - * @default 0x000000 - * @language en_US - */ - /** - * 文本字段边框的颜色。 - * 即使当前没有边框,也可检索或设置此属性,但只有当文本字段已将 border 属性设置为 true 时,才可以看到颜色。 - * @default 0x000000 - * @language zh_CN - */ - borderColor: number; - /** - * @private - */ - $setBorderColor(value: number): void; - /** - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * Specifies whether the text field has a background fill. - * If true, the text field has a background fill. If false, the text field has no background fill. - * Use the backgroundColor property to set the background color of the text field. - * @default false - * @language en_US - */ - /** - * 指定文本字段是否具有背景填充。 - * 如果为 true,则文本字段具有背景填充。如果为 false,则文本字段没有背景填充。 - * 使用 backgroundColor 属性来设置文本字段的背景颜色。 - * @default false - * @language zh_CN - */ - background: boolean; - /** - * @private - */ - $setBackground(value: boolean): void; - /** - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * Color of the text field background. - * Even currently is no background, can be retrieved or set this property, but only if the text field has the background property set to true, the color is visible. - * @default 0xFFFFFF - * @language en_US - */ - /** - * 文本字段背景的颜色。 - * 即使当前没有背景,也可检索或设置此属性,但只有当文本字段已将 background 属性设置为 true 时,才可以看到颜色。 - * @default 0xFFFFFF - * @language zh_CN - */ - backgroundColor: number; - /** - * @private - */ - $setBackgroundColor(value: number): void; - /** - * @private - * - */ - private fillBackground(lines?); - /** - * Enter the text automatically entered into the input state, the input type is text only and may only be invoked in the user interaction. - * @version Egret 3.0.8 - * @platform Web,Native - * @language en_US - */ - /** - * 输入文本自动进入到输入状态,仅在类型是输入文本并且是在用户交互下才可以调用。 - * @version Egret 3.0.8 - * @platform Web,Native - * @language zh_CN - */ - setFocus(): void; - /** - * @private - * - */ - $onRemoveFromStage(): void; - /** - * @private - * - * @param stage - * @param nestLevel - */ - $onAddToStage(stage: Stage, nestLevel: number): void; - $invalidateTextField(): void; - $getRenderBounds(): Rectangle; - /** - * @private - */ - $measureContentBounds(bounds: Rectangle): void; - $updateRenderNode(): void; - /** - * @private - */ - private isFlow; - /** - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * Set rich text - * @language en_US - */ - /** - * 设置富文本 - * @see http://edn.egret.com/cn/index.php/article/index/id/146 - * @language zh_CN - */ - textFlow: Array; - /** - * @private - * - * @param text - * @returns - */ - private changeToPassText(text); - /** - * @private - */ - private textArr; - /** - * @private - * - * @param textArr - */ - private setMiddleStyle(textArr); - /** - * Get the text measured width - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 获取文本测量宽度 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly textWidth: number; - /** - * Get Text measuring height - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 获取文本测量高度 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly textHeight: number; - /** - * @private - * @param text - * @version Egret 2.4 - * @platform Web,Native - */ - appendText(text: string): void; - /** - * @private - * @param element - * @version Egret 2.4 - * @platform Web,Native - */ - appendElement(element: egret.ITextElement): void; - /** - * @private - */ - private linesArr; - $getLinesArr(): Array; - /** - * @private - * - * @returns - */ - $getLinesArr2(): Array; - /** - * @private - */ - $isTyping: boolean; - /** - * @private - */ - $setIsTyping(value: boolean): void; - /** - * @private - * 返回要绘制的下划线列表 - */ - private drawText(); - private addEvent(); - private removeEvent(); - private onTapHandler(e); - } - interface TextField { - addEventListener(type: "link", listener: (this: Z, e: TextEvent) => void, thisObject: Z, useCapture?: boolean, priority?: number): any; - addEventListener(type: "focusIn" | "focusOut", listener: (this: Z, e: FocusEvent) => void, thisObject: Z, useCapture?: boolean, priority?: number): any; - addEventListener(type: string, listener: Function, thisObject: any, useCapture?: boolean, priority?: number): any; - } -} -declare namespace egret { - /** - * TextFieldInputType class is an enumeration of constant value used in setting the inputType property of the TextField class. - * @version Egret 3.1.2 - * @platform Web,Native - * @language en_US - */ - /** - * TextFieldInputType 类是在设置 TextField 类的 inputType 属性时使用的常数值的枚举。 - * @version Egret 3.1.2 - * @platform Web,Native - * @language zh_CN - */ - class TextFieldInputType { - /** - * The default - * @version Egret 3.1.2 - * @platform Web,Native - * @language en_US - */ - /** - * 默认 input 类型 - * @version Egret 3.1.2 - * @platform Web,Native - * @language zh_CN - */ - static TEXT: string; - /** - * Telephone Number Inputs - * @version Egret 3.1.2 - * @platform Web,Native - * @language en_US - */ - /** - * 电话号码 input 类型 - * @version Egret 3.1.2 - * @platform Web,Native - * @language zh_CN - */ - static TEL: string; - /** - * Password Inputs - * @version Egret 3.1.2 - * @platform Web,Native - * @language en_US - */ - /** - * password 类型 - * @version Egret 3.1.2 - * @platform Web,Native - * @language zh_CN - */ - static PASSWORD: string; - } -} -declare namespace egret { - /** - * TextFieldType class is an enumeration of constant value used in setting the type property of the TextField class. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * TextFieldType 类是在设置 TextField 类的 type 属性时使用的常数值的枚举。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - class TextFieldType { - /** - * Used to specify dynamic text - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 用于指定动态文本 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static DYNAMIC: string; - /** - * Used to specify the input text - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 用于指定输入文本 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static INPUT: string; - } -} -declare namespace egret { - /** - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - class TextFieldUtils { - /** - * 获取第一个绘制的行数 - * @param textfield 文本 - * @returns {number} 行数,从0开始 - * @private - */ - static $getStartLine(textfield: egret.TextField): number; - /** - * 获取水平比例 - * @param textfield 文本 - * @returns {number} 水平比例 - * @private - */ - static $getHalign(textfield: egret.TextField): number; - /** - * @private - * - * @param textfield - * @returns - */ - static $getTextHeight(textfield: egret.TextField): number; - /** - * 获取垂直比例 - * @param textfield 文本 - * @returns {number} 垂直比例 - * @private - */ - static $getValign(textfield: egret.TextField): number; - /** - * 根据x、y获取文本项 - * @param textfield 文本 - * @param x x坐标值 - * @param y y坐标值 - * @returns 文本单项 - * @private - */ - static $getTextElement(textfield: egret.TextField, x: number, y: number): ITextElement; - /** - * 获取文本点击块 - * @param textfield 文本 - * @param x x坐标值 - * @param y y坐标值 - * @returns 文本点击块 - * @private - */ - static $getHit(textfield: egret.TextField, x: number, y: number): IHitTextElement; - /** - * 获取当前显示多少行 - * @param textfield 文本 - * @returns {number} 显示的行数 - * @private - */ - static $getScrollNum(textfield: egret.TextField): number; - } -} -/** - * @private - */ -declare namespace egret.sys { - /** - * 测量文本在指定样式下的宽度。 - * @param text 要测量的文本内容。 - * @param fontFamily 字体名称 - * @param fontSize 字体大小 - * @param bold 是否粗体 - * @param italic 是否斜体 - */ - let measureText: (text: string, fontFamily: string, fontSize: number, bold: boolean, italic: boolean) => number; -} -declare namespace egret { - /** - * The VerticalAlign class defines the possible values for the vertical alignment. - * @see egret.TextField#verticalAlign - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * VerticalAlign 类为垂直对齐方式定义可能的值。 - * @see egret.TextField#verticalAlign - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - class VerticalAlign { - /** - * Vertically align content to the top of the container. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将内容与容器的顶部对齐。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static TOP: string; - /** - * Vertically align content to the bottom of the container. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将内容与容器的底部对齐。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static BOTTOM: string; - /** - * Vertically align content in the middle of the container. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 在容器的垂直中心对齐内容。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static MIDDLE: string; - /** - * Vertical alignment with both edges - * Note: TextFiled does not support this alignment method." - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 垂直两端对齐 - * 注意:TextFiled不支持此对齐方式。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static JUSTIFY: string; - /** - * Align the content of the child items, relative to the container. This operation will adjust uniformly the size of all the child items to be the Content Height \" of the container \". - * The Content Height \" of the container \" is the size of the max. child item. If the size of all child items are less than the height of the container, they will be adjusted to the height of the container. - * Note: TextFiled does not support this alignment method. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 相对于容器对子项进行内容对齐。这会将所有子项的大小统一调整为容器的"内容高度"。 - * 容器的"内容高度"是最大子项的大小,如果所有子项都小于容器的高度,则会将所有子项的大小调整为容器的高度。 - * 注意:TextFiled不支持此对齐方式。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static CONTENT_JUSTIFY: string; - } -} -declare namespace egret { - /** - * @language en_US - * The Base64Util class provides methods for encoding and decoding base64. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/Base64Util.ts - */ - /** - * @language zh_CN - * Base64Util 类提供用于编解码base64的方法。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/Base64Util.ts - */ - class Base64Util { - /** - * @language en_US - * encode base64. - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * @language zh_CN - * 编码base64。 - * @version Egret 2.4 - * @platform Web,Native - */ - static encode(arraybuffer: ArrayBuffer): string; - /** - * @language en_US - * decode base64. - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * @language zh_CN - * 解码base64。 - * @version Egret 2.4 - * @platform Web,Native - */ - static decode(base64: string): ArrayBuffer; - } -} -/** - * @private - */ -declare let chars: string; -/** - * @private - */ -declare let lookup: Uint8Array; -declare namespace egret { - /** - * The Endian class contains values that denote the byte order used to represent multibyte numbers. - * The byte order is either bigEndian (most significant byte first) or littleEndian (least significant byte first). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * Endian 类中包含一些值,它们表示用于表示多字节数字的字节顺序。 - * 字节顺序为 bigEndian(最高有效字节位于最前)或 littleEndian(最低有效字节位于最前)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - class Endian { - /** - * Indicates the least significant byte of the multibyte number appears first in the sequence of bytes. - * The hexadecimal number 0x12345678 has 4 bytes (2 hexadecimal digits per byte). The most significant byte is 0x12. The least significant byte is 0x78. (For the equivalent decimal number, 305419896, the most significant digit is 3, and the least significant digit is 6). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示多字节数字的最低有效字节位于字节序列的最前面。 - * 十六进制数字 0x12345678 包含 4 个字节(每个字节包含 2 个十六进制数字)。最高有效字节为 0x12。最低有效字节为 0x78。(对于等效的十进制数字 305419896,最高有效数字是 3,最低有效数字是 6)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static LITTLE_ENDIAN: string; - /** - * Indicates the most significant byte of the multibyte number appears first in the sequence of bytes. - * The hexadecimal number 0x12345678 has 4 bytes (2 hexadecimal digits per byte). The most significant byte is 0x12. The least significant byte is 0x78. (For the equivalent decimal number, 305419896, the most significant digit is 3, and the least significant digit is 6). - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 表示多字节数字的最高有效字节位于字节序列的最前面。 - * 十六进制数字 0x12345678 包含 4 个字节(每个字节包含 2 个十六进制数字)。最高有效字节为 0x12。最低有效字节为 0x78。(对于等效的十进制数字 305419896,最高有效数字是 3,最低有效数字是 6)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static BIG_ENDIAN: string; - } - const enum EndianConst { - LITTLE_ENDIAN = 0, - BIG_ENDIAN = 1, - } - /** - * The ByteArray class provides methods and attributes for optimized reading and writing as well as dealing with binary data. - * Note: The ByteArray class is applied to the advanced developers who need to access data at the byte layer. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/ByteArray.ts - * @language en_US - */ - /** - * ByteArray 类提供用于优化读取、写入以及处理二进制数据的方法和属性。 - * 注意:ByteArray 类适用于需要在字节层访问数据的高级开发人员。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/ByteArray.ts - * @language zh_CN - */ - class ByteArray { - /** - * @private - */ - protected bufferExtSize: number; - protected data: DataView; - protected _bytes: Uint8Array; - /** - * @private - */ - protected _position: number; - /** - * - * 已经使用的字节偏移量 - * @protected - * @type {number} - * @memberOf ByteArray - */ - protected write_position: number; - /** - * Changes or reads the byte order; egret.EndianConst.BIG_ENDIAN or egret.EndianConst.LITTLE_EndianConst. - * @default egret.EndianConst.BIG_ENDIAN - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 更改或读取数据的字节顺序;egret.EndianConst.BIG_ENDIAN 或 egret.EndianConst.LITTLE_ENDIAN。 - * @default egret.EndianConst.BIG_ENDIAN - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - endian: string; - protected $endian: EndianConst; - /** - * @version Egret 2.4 - * @platform Web,Native - */ - constructor(buffer?: ArrayBuffer | Uint8Array, bufferExtSize?: number); - /** - * @deprecated - * @version Egret 2.4 - * @platform Web,Native - */ - setArrayBuffer(buffer: ArrayBuffer): void; - /** - * 可读的剩余字节数 - * - * @returns - * - * @memberOf ByteArray - */ - readonly readAvailable: number; - /** - * @private - */ - buffer: ArrayBuffer; - readonly rawBuffer: ArrayBuffer; - readonly bytes: Uint8Array; - /** - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * @private - */ - dataView: DataView; - /** - * @private - */ - readonly bufferOffset: number; - /** - * The current position of the file pointer (in bytes) to move or return to the ByteArray object. The next time you start reading reading method call in this position, or will start writing in this position next time call a write method. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将文件指针的当前位置(以字节为单位)移动或返回到 ByteArray 对象中。下一次调用读取方法时将在此位置开始读取,或者下一次调用写入方法时将在此位置开始写入。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - position: number; - /** - * The length of the ByteArray object (in bytes). - * If the length is set to be larger than the current length, the right-side zero padding byte array. - * If the length is set smaller than the current length, the byte array is truncated. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * ByteArray 对象的长度(以字节为单位)。 - * 如果将长度设置为大于当前长度的值,则用零填充字节数组的右侧。 - * 如果将长度设置为小于当前长度的值,将会截断该字节数组。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - length: number; - protected _validateBuffer(value: number): void; - /** - * The number of bytes that can be read from the current position of the byte array to the end of the array data. - * When you access a ByteArray object, the bytesAvailable property in conjunction with the read methods each use to make sure you are reading valid data. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 可从字节数组的当前位置到数组末尾读取的数据的字节数。 - * 每次访问 ByteArray 对象时,将 bytesAvailable 属性与读取方法结合使用,以确保读取有效的数据。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly bytesAvailable: number; - /** - * Clears the contents of the byte array and resets the length and position properties to 0. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 清除字节数组的内容,并将 length 和 position 属性重置为 0。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - clear(): void; - /** - * Read a Boolean value from the byte stream. Read a simple byte. If the byte is non-zero, it returns true; otherwise, it returns false. - * @return If the byte is non-zero, it returns true; otherwise, it returns false. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从字节流中读取布尔值。读取单个字节,如果字节非零,则返回 true,否则返回 false - * @return 如果字节不为零,则返回 true,否则返回 false - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readBoolean(): boolean; - /** - * Read signed bytes from the byte stream. - * @return An integer ranging from -128 to 127 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从字节流中读取带符号的字节 - * @return 介于 -128 和 127 之间的整数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readByte(): number; - /** - * Read data byte number specified by the length parameter from the byte stream. Starting from the position specified by offset, read bytes into the ByteArray object specified by the bytes parameter, and write bytes into the target ByteArray - * @param bytes ByteArray object that data is read into - * @param offset Offset (position) in bytes. Read data should be written from this position - * @param length Byte number to be read Default value 0 indicates reading all available data - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从字节流中读取 length 参数指定的数据字节数。从 offset 指定的位置开始,将字节读入 bytes 参数指定的 ByteArray 对象中,并将字节写入目标 ByteArray 中 - * @param bytes 要将数据读入的 ByteArray 对象 - * @param offset bytes 中的偏移(位置),应从该位置写入读取的数据 - * @param length 要读取的字节数。默认值 0 导致读取所有可用的数据 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readBytes(bytes: ByteArray, offset?: number, length?: number): void; - /** - * Read an IEEE 754 double-precision (64 bit) floating point number from the byte stream - * @return Double-precision (64 bit) floating point number - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从字节流中读取一个 IEEE 754 双精度(64 位)浮点数 - * @return 双精度(64 位)浮点数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readDouble(): number; - /** - * Read an IEEE 754 single-precision (32 bit) floating point number from the byte stream - * @return Single-precision (32 bit) floating point number - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从字节流中读取一个 IEEE 754 单精度(32 位)浮点数 - * @return 单精度(32 位)浮点数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readFloat(): number; - /** - * Read a 32-bit signed integer from the byte stream. - * @return A 32-bit signed integer ranging from -2147483648 to 2147483647 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从字节流中读取一个带符号的 32 位整数 - * @return 介于 -2147483648 和 2147483647 之间的 32 位带符号整数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readInt(): number; - /** - * Read a 16-bit signed integer from the byte stream. - * @return A 16-bit signed integer ranging from -32768 to 32767 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从字节流中读取一个带符号的 16 位整数 - * @return 介于 -32768 和 32767 之间的 16 位带符号整数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readShort(): number; - /** - * Read unsigned bytes from the byte stream. - * @return A unsigned integer ranging from 0 to 255 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从字节流中读取无符号的字节 - * @return 介于 0 和 255 之间的无符号整数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readUnsignedByte(): number; - /** - * Read a 32-bit unsigned integer from the byte stream. - * @return A 32-bit unsigned integer ranging from 0 to 4294967295 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从字节流中读取一个无符号的 32 位整数 - * @return 介于 0 和 4294967295 之间的 32 位无符号整数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readUnsignedInt(): number; - /** - * Read a 16-bit unsigned integer from the byte stream. - * @return A 16-bit unsigned integer ranging from 0 to 65535 - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从字节流中读取一个无符号的 16 位整数 - * @return 介于 0 和 65535 之间的 16 位无符号整数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readUnsignedShort(): number; - /** - * Read a UTF-8 character string from the byte stream Assume that the prefix of the character string is a short unsigned integer (use byte to express length) - * @return UTF-8 character string - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从字节流中读取一个 UTF-8 字符串。假定字符串的前缀是无符号的短整型(以字节表示长度) - * @return UTF-8 编码的字符串 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readUTF(): string; - /** - * Read a UTF-8 byte sequence specified by the length parameter from the byte stream, and then return a character string - * @param Specify a short unsigned integer of the UTF-8 byte length - * @return A character string consists of UTF-8 bytes of the specified length - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 从字节流中读取一个由 length 参数指定的 UTF-8 字节序列,并返回一个字符串 - * @param length 指明 UTF-8 字节长度的无符号短整型数 - * @return 由指定长度的 UTF-8 字节组成的字符串 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readUTFBytes(length: number): string; - /** - * Write a Boolean value. A single byte is written according to the value parameter. If the value is true, write 1; if the value is false, write 0. - * @param value A Boolean value determining which byte is written. If the value is true, write 1; if the value is false, write 0. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 写入布尔值。根据 value 参数写入单个字节。如果为 true,则写入 1,如果为 false,则写入 0 - * @param value 确定写入哪个字节的布尔值。如果该参数为 true,则该方法写入 1;如果该参数为 false,则该方法写入 0 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - writeBoolean(value: boolean): void; - /** - * Write a byte into the byte stream - * The low 8 bits of the parameter are used. The high 24 bits are ignored. - * @param value A 32-bit integer. The low 8 bits will be written into the byte stream - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 在字节流中写入一个字节 - * 使用参数的低 8 位。忽略高 24 位 - * @param value 一个 32 位整数。低 8 位将被写入字节流 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - writeByte(value: number): void; - /** - * Write the byte sequence that includes length bytes in the specified byte array, bytes, (starting at the byte specified by offset, using a zero-based index), into the byte stream - * If the length parameter is omitted, the default length value 0 is used and the entire buffer starting at offset is written. If the offset parameter is also omitted, the entire buffer is written - * If the offset or length parameter is out of range, they are clamped to the beginning and end of the bytes array. - * @param bytes ByteArray Object - * @param offset A zero-based index specifying the position into the array to begin writing - * @param length An unsigned integer specifying how far into the buffer to write - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将指定字节数组 bytes(起始偏移量为 offset,从零开始的索引)中包含 length 个字节的字节序列写入字节流 - * 如果省略 length 参数,则使用默认长度 0;该方法将从 offset 开始写入整个缓冲区。如果还省略了 offset 参数,则写入整个缓冲区 - * 如果 offset 或 length 超出范围,它们将被锁定到 bytes 数组的开头和结尾 - * @param bytes ByteArray 对象 - * @param offset 从 0 开始的索引,表示在数组中开始写入的位置 - * @param length 一个无符号整数,表示在缓冲区中的写入范围 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - writeBytes(bytes: ByteArray, offset?: number, length?: number): void; - /** - * Write an IEEE 754 double-precision (64 bit) floating point number into the byte stream - * @param value Double-precision (64 bit) floating point number - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 在字节流中写入一个 IEEE 754 双精度(64 位)浮点数 - * @param value 双精度(64 位)浮点数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - writeDouble(value: number): void; - /** - * Write an IEEE 754 single-precision (32 bit) floating point number into the byte stream - * @param value Single-precision (32 bit) floating point number - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 在字节流中写入一个 IEEE 754 单精度(32 位)浮点数 - * @param value 单精度(32 位)浮点数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - writeFloat(value: number): void; - /** - * Write a 32-bit signed integer into the byte stream - * @param value An integer to be written into the byte stream - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 在字节流中写入一个带符号的 32 位整数 - * @param value 要写入字节流的整数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - writeInt(value: number): void; - /** - * Write a 16-bit integer into the byte stream. The low 16 bits of the parameter are used. The high 16 bits are ignored. - * @param value A 32-bit integer. Its low 16 bits will be written into the byte stream - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 在字节流中写入一个 16 位整数。使用参数的低 16 位。忽略高 16 位 - * @param value 32 位整数,该整数的低 16 位将被写入字节流 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - writeShort(value: number): void; - /** - * Write a 32-bit unsigned integer into the byte stream - * @param value An unsigned integer to be written into the byte stream - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 在字节流中写入一个无符号的 32 位整数 - * @param value 要写入字节流的无符号整数 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - writeUnsignedInt(value: number): void; - /** - * Write a 16-bit unsigned integer into the byte stream - * @param value An unsigned integer to be written into the byte stream - * @version Egret 2.5 - * @platform Web,Native - * @language en_US - */ - /** - * 在字节流中写入一个无符号的 16 位整数 - * @param value 要写入字节流的无符号整数 - * @version Egret 2.5 - * @platform Web,Native - * @language zh_CN - */ - writeUnsignedShort(value: number): void; - /** - * Write a UTF-8 string into the byte stream. The length of the UTF-8 string in bytes is written first, as a 16-bit integer, followed by the bytes representing the characters of the string - * @param value Character string value to be written - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将 UTF-8 字符串写入字节流。先写入以字节表示的 UTF-8 字符串长度(作为 16 位整数),然后写入表示字符串字符的字节 - * @param value 要写入的字符串值 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - writeUTF(value: string): void; - /** - * Write a UTF-8 string into the byte stream. Similar to the writeUTF() method, but the writeUTFBytes() method does not prefix the string with a 16-bit length word - * @param value Character string value to be written - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将 UTF-8 字符串写入字节流。类似于 writeUTF() 方法,但 writeUTFBytes() 不使用 16 位长度的词为字符串添加前缀 - * @param value 要写入的字符串值 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - writeUTFBytes(value: string): void; - /** - * - * @returns - * @version Egret 2.4 - * @platform Web,Native - */ - toString(): string; - /** - * @private - * 将 Uint8Array 写入字节流 - * @param bytes 要写入的Uint8Array - * @param validateBuffer - */ - _writeUint8Array(bytes: Uint8Array | ArrayLike, validateBuffer?: boolean): void; - /** - * @param len - * @returns - * @version Egret 2.4 - * @platform Web,Native - * @private - */ - validate(len: number): boolean; - /**********************/ - /**********************/ - /** - * @private - * @param len - * @param needReplace - */ - protected validateBuffer(len: number): void; - /** - * @private - * UTF-8 Encoding/Decoding - */ - private encodeUTF8(str); - /** - * @private - * - * @param data - * @returns - */ - private decodeUTF8(data); - /** - * @private - * - * @param code_point - */ - private encoderError(code_point); - /** - * @private - * - * @param fatal - * @param opt_code_point - * @returns - */ - private decoderError(fatal, opt_code_point?); - /** - * @private - */ - private EOF_byte; - /** - * @private - */ - private EOF_code_point; - /** - * @private - * - * @param a - * @param min - * @param max - */ - private inRange(a, min, max); - /** - * @private - * - * @param n - * @param d - */ - private div(n, d); - /** - * @private - * - * @param string - */ - private stringToCodePoints(string); - } -} -declare namespace egret { - /** - * The Sprite class is a basic display list building block: a display list node that can contain children. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/Sprite.ts - * @language en_US - */ - /** - * Sprite 类是基本显示列表构造块:一个可包含子项的显示列表节点。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/Sprite.ts - * @language zh_CN - */ - class Sprite extends DisplayObjectContainer { - /** - * Creates a new Sprite instance. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 实例化一个容器 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(); - protected createNativeDisplayObject(): void; - /** - * @private - */ - $graphics: Graphics; - /** - * Specifies the Graphics object belonging to this Shape object, where vector drawing commands can occur. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 获取 Shape 中的 Graphics 对象。可通过此对象执行矢量绘图命令。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly graphics: Graphics; - $hitTest(stageX: number, stageY: number): DisplayObject; - /** - * @private - */ - $measureContentBounds(bounds: Rectangle): void; - /** - * @private - */ - $onRemoveFromStage(): void; - } -} -declare namespace egret { - /** - * Registers the runtime class information for a class.This method adds some strings which represent the class name or - * some interface names to the class definition. After the registration,you can use egret.is() method to do the type checking - * for the instance of this class.
- * Note:If you use the TypeScript programming language, the egret command line tool will automatically generate the registration code line. - * You don't need to manually call this method. - * - * @example the following code shows how to register the runtime class information for the EventDispatcher class and do the type checking: - *
-     *      egret.registerClass(egret.EventDispatcher,"egret.EventDispatcher",["egret.IEventDispatcher"]);
-     *      let dispatcher = new egret.EventDispatcher();
-     *      egret.log(egret.is(dispatcher, "egret.IEventDispatcher"));  //true。
-     *      egret.log(egret.is(dispatcher, "egret.EventDispatcher"));   //true。
-     *      egret.log(egret.is(dispatcher, "egret.Bitmap"));   //false。
-     * 
- * @param classDefinition the class definition to be registered. - * @param className a unique identification string of the specific class - * @param interfaceNames a list of unique identification string of the specific interfaces. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 为一个类定义注册运行时类信息,用此方法往类定义上注册它自身以及所有接口对应的字符串。 - * 在运行时,这个类的实例将可以使用 egret.is() 方法传入一个字符串来判断实例类型。 - * @example 以下代码演示了如何为EventDispatcher类注册运行时类信息并判断类型: - *
-     *      //为egret.EventDispatcher类注册运行时类信息,由于它实现了IEventDispatcher接口,这里应同时传入接口名对应的字符串。
-     *      egret.registerClass(egret.EventDispatcher,"egret.EventDispatcher",["egret.IEventDispatcher"]);
-     *      let dispatcher = new egret.EventDispatcher();
-     *      egret.log(egret.is(dispatcher, "egret.IEventDispatcher"));  //true。
-     *      egret.log(egret.is(dispatcher, "egret.EventDispatcher"));   //true。
-     *      egret.log(egret.is(dispatcher, "egret.Bitmap"));   //false。
-     * 
- * 注意:若您使用 TypeScript 来编写程序,egret 命令行会自动帮您生成类信息注册代码行到最终的 Javascript 文件中。因此您不需要手动调用此方法。 - * - * @param classDefinition 要注册的类定义。 - * @param className 要注册的类名。 - * @param interfaceNames 要注册的类所实现的接口名列表。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function registerClass(classDefinition: any, className: string, interfaceNames?: string[]): void; -} -declare namespace egret { - /** - * The BitmapFillMode class defines the image fill mode of Bitmap. - * The BitmapFillMode class defines a pattern enumeration for adjusting size. These patterns determine how Bitmap fill the size designated by the layout system. - * @see http://edn.egret.com/cn/docs/page/134 Texture filling way - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/BitmapFillMode.ts - * @language en_US - */ - /** - * BitmapFillMode 类定义Bitmap的图像填充方式。 - * BitmapFillMode 类定义了调整大小模式的一个枚举,这些模式确定 Bitmap 如何填充由布局系统指定的尺寸。 - * @see http://edn.egret.com/cn/docs/page/134 纹理的填充方式 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/display/BitmapFillMode.ts - * @language zh_CN - */ - const BitmapFillMode: { - REPEAT: string; - SCALE: string; - CLIP: string; - }; -} -declare namespace egret { - /** - * Logger is an entrance for the log processing namespace of the engine - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * Logger是引擎的日志处理模块入口 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - class Logger { - /** - * open all - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 全开 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static ALL: string; - /** - * level: DEBUG - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 等级为 DEBUG - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static DEBUG: string; - /** - * level: INFO - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 等级为 INFO - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static INFO: string; - /** - * level: WARN - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 等级为 WARN - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static WARN: string; - /** - * level: ERROR - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 等级为 ERROR - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static ERROR: string; - /** - * close all - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 全关 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static OFF: string; - /** - * Set the current need to open the log level. Grade level are: ALL - * This feature is only in DEBUG mode to take effect.
- *
    - *
  • Logger.ALL - all levels of log can be printed out. - *
  • Logger.DEBUG - print debug, info, log, warn, error. - *
  • Logger.INFO - print info, log, warn, error. - *
  • Logger.WARN - can print warn, error. - *
  • Logger.ERROR - You can print error. - *
  • Logger.OFF - all closed. - * - *param LogType from this level to start printing. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 设置当前需要开启的log级别。级别等级分别为:ALL < DEBUG < INFO < WARN < ERROR < OFF
    - * 此功能只在 DEBUG 模式下才生效。
    - *
      - *
    • Logger.ALL -- 所有等级的log都可以打印出来。
    • - *
    • Logger.DEBUG -- 可以打印debug、info、log、warn、error。
    • - *
    • Logger.INFO -- 可以打印info、log、warn、error。
    • - *
    • Logger.WARN -- 可以打印warn、error。
    • - *
    • Logger.ERROR -- 可以打印error。
    • - *
    • Logger.OFF -- 全部关闭。
    • - *
    - * @param logType 从这个等级开始打印。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static logLevel: string; - } -} -declare namespace egret { - /** - * @version Egret 2.4 - * @platform Web,Native - */ - class NumberUtils { - /** - * Judge whether it is a numerical value - * @param value Parameter that needs to be judged - * @returns - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 判断是否是数值 - * @param value 需要判断的参数 - * @returns - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static isNumber(value: any): boolean; - /** - * Obtain the approximate sin value of the corresponding angle value - * @param value {number} Angle value - * @returns {number} sin value - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 得到对应角度值的sin近似值 - * @param value {number} 角度值 - * @returns {number} sin值 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static sin(value: number): number; - /** - * @private - * - * @param value - * @returns - */ - private static sinInt(value); - /** - * Obtain the approximate cos value of the corresponding angle value - * @param value {number} Angle value - * @returns {number} cos value - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 得到对应角度值的cos近似值 - * @param value {number} 角度值 - * @returns {number} cos值 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static cos(value: number): number; - /** - * @private - * - * @param value - * @returns - */ - private static cosInt(value); - static convertStringToHashCode(str: string): number; - } -} -/** - * @private - */ -declare let egret_sin_map: {}; -/** - * @private - */ -declare let egret_cos_map: {}; -/** - * @private - */ -declare let DEG_TO_RAD: number; -declare namespace egret { - /** - * The Timer class is the interface to timers, which let you run code on a specified time sequence. Use the start() - * method to start a timer. Add an event listener for the timer event to set up code to be run on the timer interval.
    - * You can create Timer objects to run once or repeat at specified intervals to execute code on a schedule. Depending - * on the framerate or the runtime environment (available memory and other factors), the runtime may dispatchEvent events at - * slightly offset intervals. - * @see egret.TimerEvent - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/Timer.ts - * @language en_US - */ - /** - * Timer 类是计时器的接口,它使您能按指定的时间序列运行代码。 - * 使用 start() 方法来启动计时器。为 timer 事件添加事件侦听器,以便将代码设置为按计时器间隔运行。 - * 可以创建 Timer 对象以运行一次或按指定间隔重复运行,从而按计划执行代码。 - * 根据 Egret 的帧速率或运行时环境(可用内存和其他因素),运行时调度事件的间隔可能稍有不同。 - * @see egret.TimerEvent - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/Timer.ts - * @language zh_CN - */ - class Timer extends EventDispatcher { - /** - * Constructs a new Timer object with the specified delay and repeatCount states. - * @param delay The delay between timer events, in milliseconds. A delay lower than 20 milliseconds is not recommended. - * Timer frequency is limited to 60 frames per second, meaning a delay lower than 16.6 milliseconds causes runtime problems. - * @param repeatCount Specifies the number of repetitions. If zero, the timer repeats indefinitely.If nonzero, - * the timer runs the specified number of times and then stops. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 使用指定的 delay 和 repeatCount 状态构造新的 Timer 对象。 - * @param delay 计时器事件间的延迟(以毫秒为单位)。建议 delay 不要低于 20 毫秒。计时器频率不得超过 60 帧/秒,这意味着低于 16.6 毫秒的延迟可导致出现运行时问题。 - * @param repeatCount 指定重复次数。如果为零,则计时器将持续不断重复运行。如果不为 0,则将运行计时器,运行次数为指定的次数,然后停止。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - constructor(delay: number, repeatCount?: number); - /** - * @private - */ - private _delay; - /** - * The delay between timer events, in milliseconds. A delay lower than 20 milliseconds is not recommended.
    - * Note: Timer frequency is limited to 60 frames per second, meaning a delay lower than 16.6 milliseconds causes runtime problems. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 计时器事件间的延迟(以毫秒为单位)。如果在计时器正在运行时设置延迟间隔,则计时器将按相同的 repeatCount 迭代重新启动。
    - * 注意:建议 delay 不要低于 20 毫秒。计时器频率不得超过 60 帧/秒,这意味着低于 16.6 毫秒的延迟可导致出现运行时问题。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - delay: number; - /** - * The total number of times the timer is set to run. If the repeat count is set to 0, the timer continues indefinitely, - * until the stop() method is invoked or the program stops. If the repeat count is nonzero, the timer runs the specified - * number of times. If repeatCount is set to a total that is the same or less then currentCount the timer stops and will not fire again. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 设置的计时器运行总次数。如果重复计数设置为 0,则计时器将持续不断运行,或直至调用了 stop() 方法或节目停止。 - * 如果重复计数不为 0,则将运行计时器,运行次数为指定的次数。如果设置的 repeatCount 总数等于或小于 currentCount,则计时器将停止并且不会再次触发。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - repeatCount: number; - /** - * @private - */ - private _currentCount; - /** - * The total number of times the timer has fired since it started at zero. If the timer has been reset, only the fires since the reset are counted. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 计时器从 0 开始后触发的总次数。如果已重置了计时器,则只会计入重置后的触发次数。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly currentCount: number; - /** - * @private - */ - private _running; - /** - * The timer's current state; true if the timer is running, otherwise false. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 计时器的当前状态;如果计时器正在运行,则为 true,否则为 false。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - readonly running: boolean; - /** - * Stops the timer, if it is running, and sets the currentCount property back to 0, like the reset button of a stopwatch. - * Then, when start() is called, the timer instance runs for the specified number of repetitions, as set by the repeatCount value. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 如果计时器正在运行,则停止计时器,并将 currentCount 属性设回为 0,这类似于秒表的重置按钮。然后,在调用 start() 后,将运行计时器实例,运行次数为指定的重复次数(由 repeatCount 值设置)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - reset(): void; - /** - * Starts the timer, if it is not already running. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 如果计时器尚未运行,则启动计时器。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - start(): void; - /** - * Stops the timer. When start() is called after stop(), the timer instance runs for the remaining number of - * repetitions, as set by the repeatCount property. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 停止计时器。如果在调用 stop() 后调用 start(),则将继续运行计时器实例,运行次数为剩余的 重复次数(由 repeatCount 属性设置)。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - stop(): void; - /** - * @private - */ - private updateInterval; - /** - * @private - */ - private lastCount; - /** - * @private - */ - private lastTimeStamp; - /** - * @private - * Ticker以60FPS频率刷新此方法 - */ - $update(timeStamp: number): boolean; - } -} -declare namespace egret { - /** - * The XMLNode class is the base class for all xml node. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * XML节点基类 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - interface XMLNode { - /** - * a integer representing the type of the node, 1:XML,2:XMLAttribute,3:XMLText - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 节点类型,1:XML,2:XMLAttribute,3:XMLText - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - nodeType: number; - /** - * the parent node of this xml node. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 节点所属的父级节点 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - parent: XML; - } - /** - * The XML class contains properties for working with XML objects. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/XML.ts - * @language en_US - */ - /** - * XML 类包含用于处理 XML 对象的属性。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/XML.ts - * @language zh_CN - */ - interface XML extends XMLNode { - /** - * the attributes of this xml node. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 当前节点上的属性列表 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - attributes: any; - /** - * the children of the xml node. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 当前节点的子节点列表 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - children: XMLNode[]; - /** - * the full name of this xml node. For example,the name of is "s:Button". - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 节点完整名称。例如节点 的 name 为:"s:Button" - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - name: string; - /** - * thie namesapce prefix of this xml node.For example,the prefix of is "s". - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 节点的命名空间前缀。例如节点 的 prefix 为:s - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - prefix: string; - /** - * the local name of this xml node. For example,the local name of is "Button". - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 节点的本地名称。例如节点 的 localName 为:Button - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - localName: string; - /** - * the namesapce uri of this xml node.For example,the namespace uri of is "http://ns.egret.com/eui". - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 节点的命名空间地址。例如节点 的 namespace 为: http://ns.egret.com/eui - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - namespace: string; - } - /** - * The XMLText class represents a string node in the XML. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * XMLText 类表示在XML中的文本节点 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - interface XMLText extends XMLNode { - /** - * the text content - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 文本内容 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - text: string; - } - /** - * The XML class contains properties for working with XML objects. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * XML 类包含用于处理 XML 对象的属性。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - let XML: { - /** - * parses a text to XML instance. - * @param text the text to be parsed. - * @language en_US - */ - /** - * 解析字符串为XML对象 - * @param text 要解析的XML对象。 - * @language zh_CN - */ - parse(text: string): XML; - }; -} -declare namespace egret { - /** - * @private - */ - let $callLaterFunctionList: any[]; - /** - * @private - */ - let $callLaterThisList: any[]; - /** - * @private - */ - let $callLaterArgsList: any[]; - /** - * Delay the function to run unless screen is redrawn. - * @param method {Function} The function to be delayed to run - * @param thisObject {any} this reference of callback function - * @param ...args {any} Function parameter list - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/callLater.ts - * @language en_US - */ - /** - * 延迟函数到屏幕重绘前执行。 - * @param method {Function} 要延迟执行的函数 - * @param thisObject {any} 回调函数的this引用 - * @param ...args {any} 函数参数列表 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/callLater.ts - * @language zh_CN - */ - function callLater(method: Function, thisObject: any, ...args: any[]): void; - /** - * @private - */ - let $callAsyncFunctionList: any[]; - /** - * @private - */ - let $callAsyncThisList: any[]; - /** - * @private - */ - let $callAsyncArgsList: any[]; - /** - * 异步调用函数 - * @param method {Function} 要异步调用的函数 - * @param thisObject {any} 函数的this引用 - * @param ...args {any} 函数参数列表 - * @private - */ - function $callAsync(method: Function, thisObject: any, ...args: any[]): void; -} -declare namespace egret { - /** - * Call setter properties of the parent class, instead of the other writing languages, such as super.alpha = 1; - * @param currentClass The current class class name, non-string - * @param thisObj The current object. Always this - * @param type Setter property names need to call - * @param values Value passed to the parent class - * - * @exmaple egret.superSetter(egret.Sprite, this, "alpha", 1); - * @language en_US - */ - /** - * 调用父类的setter属性,代替其他语言的写法,如 super.alpha = 1; - * @param currentClass 当前 class 类名,非字符串 - * @param thisObj 当前对象。永远都this - * @param type 需要调用的setter属性名称 - * @param values 传给父类的值 - * - * @exmaple egret.superSetter(egret.Sprite, this, "alpha", 1); - * @language zh_CN - */ - function superSetter(currentClass: any, thisObj: any, type: string, ...values: any[]): any; - /** - * Get getter property value of the parent class. Instead of writing in other languages, such as super.alpha; - * @param currentClass The current class class name, non-string - * @param thisObj The current object. Always this - * @param type Setter property names need to call - * @returns {any} The value returned by the parent - * - * @exmaple egret.superGetter(egret.Sprite, this, "alpha"); - * @language en_US - */ - /** - * 获取父类的getter属性值。代替其他语言的写法,如 super.alpha; - * @param currentClass 当前 class 类名,非字符串 - * @param thisObj 当前对象。永远都this - * @param type 需要调用的getter属性名称 - * @returns {any} 父类返回的值 - * - * @exmaple egret.superGetter(egret.Sprite, this, "alpha"); - * @language zh_CN - */ - function superGetter(currentClass: any, thisObj: any, type: string): any; -} -declare namespace egret { - /** - * Returns a reference to the class object of the class specified by the name parameter. - * @param name The name of a class. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/getDefinitionByName.ts - * @language en_US - */ - /** - * 返回 name 参数指定的类的类对象引用。 - * @param name 类的名称。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/getDefinitionByName.ts - * @language zh_CN - */ - function getDefinitionByName(name: string): any; -} -declare namespace egret { - /** - * Get browser or Runtime parameters, returns an empty string if not set - * Get the url parameter corresponds to the browser, access to the corresponding parameter in the Runtime setOption - * @method egret.getOption - * @param key {string} Parameters key - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 获取浏览器或者Runtime参数,如果没有设置返回空字符串 - * 在浏览器中相当于获取url中参数,在Runtime获取对应setOption参数 - * @method egret.getOption - * @param key {string} 参数key - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - let getOption: (key: string) => string; -} -declare namespace egret { - /** - * Return the fully qualified class name of an object - * @param value The object for which a fully qualified class name is desired. Any JavaScript value may be passed to - * this method including all available JavaScript types, object instances, primitive types such as number, and class objects. - * @returns A string containing the fully qualified class name. - * @example - *
    -     *  egret.getQualifiedClassName(egret.DisplayObject) //return "egret.DisplayObject"
    -     * 
    - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/getQualifiedClassName.ts - * @language en_US - */ - /** - * 返回对象的完全限定类名。 - * @param value 需要完全限定类名称的对象,可以将任何 JavaScript 值传递给此方法,包括所有可用的 JavaScript 类型、对象实例、原始类型 - * (如number)和类对象 - * @returns 包含完全限定类名称的字符串。 - * @example - *
    -     *  egret.getQualifiedClassName(egret.DisplayObject) //返回 "egret.DisplayObject"
    -     * 
    - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/getQualifiedClassName.ts - * @language zh_CN - */ - function getQualifiedClassName(value: any): string; -} -declare namespace egret { - /** - * Returns the fully qualified class name of the base class of the object specified by the value parameter. - * @param value The object for which a parent class is desired. Any JavaScript value may be passed to this method including - * all available JavaScript types, object instances, primitive types such as number, and class objects. - * @returns A fully qualified base class name, or null if none exists. - * @example - *
    -     *  egret.getQualifiedSuperclassName(egret.Bitmap) //return "egret.DisplayObject"
    -     * 
    - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/getQualifiedSuperclassName.ts - * @language en_US - */ - /** - * 返回 value 参数指定的对象的基类的完全限定类名。 - * @param value 需要取得父类的对象,可以将任何 JavaScript 值传递给此方法,包括所有可用的 JavaScript 类型、对象实例、原始类型(如number)和类对象 - * @returns 完全限定的基类名称,或 null(如果不存在基类名称)。 - * @example - *
    -     *  egret.getQualifiedSuperclassName(egret.Sprite) //返回 "egret.DisplayObject"
    -     * 
    - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/getQualifiedSuperclassName.ts - * @language zh_CN - */ - function getQualifiedSuperclassName(value: any): string; -} -declare namespace egret { - /** - * Used to compute relative time.this method returns the number of milliseconds since the Egret framework was initialized - * @returns The number of milliseconds since the Egret framework was initialized - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/getTimer.ts - * @language en_US - */ - /** - * 用于计算相对时间。此方法返回自启动 Egret 框架以来经过的毫秒数。 - * @returns 启动 Egret 框架以来经过的毫秒数。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/getTimer.ts - * @language zh_CN - */ - function getTimer(): number; -} -declare namespace egret { - /** - * Check whether a public definition exists in the specified application domain. The definition can be that of a class, a naming space or a function. - * @param name {string} Name of the definition. - * @returns {boolean} Whether the public definition exists - * @example - * egret.hasDefinition("egret.DisplayObject") //return true - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/hasDefinition.ts - * @language en_US - */ - /** - * 检查指定的应用程序域之内是否存在一个公共定义。该定义可以是一个类、一个命名空间或一个函数的定义。 - * @param name {string} 定义的名称。 - * @returns {boolean} 公共定义是否存在 - * @example - * egret.hasDefinition("egret.DisplayObject") //返回 true - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/hasDefinition.ts - * @language zh_CN - */ - function hasDefinition(name: string): boolean; -} -declare namespace egret { - /** - * Indicates whether an object is a instance of the class or interface specified as the parameter.This method has better performance - * compared width the instanceOf operator,and it can indicate whether an object is a instance of the specific interface. - * @param instance the instance to be checked. - * @param typeName the string value representing a specific class or interface. - * @returns A value of true if the object is a instance of the class or interface specified as the parameter. - * @example - *
    -     *     let instance = new egret.Sprite();
    -     *     egret.log(egret.is(instance,"egret.Sprite"))  //true
    -     *     egret.log(egret.is(instance,"egret.DisplayObjectContainer"))  //true
    -     *     egret.log(egret.is(instance,"egret.Bitmap"))  //false
    -     * 
    - * @see egret.registerClass() - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 检查指定对象是否为 Egret 框架内指定接口或类或其子类的实例。此方法与使用 instanceOf 关键字相比具有更高的性能,并且能判断接口的实现。 - * @param instance 要判断的实例。 - * @param typeName 类或接口的完全名称. - * @returns 返回true表示当前对象是指定类或接口的实例。 - * @example - *
    -     *     let instance = new egret.Sprite();
    -     *     egret.log(egret.is(instance,"egret.Sprite"))  //true
    -     *     egret.log(egret.is(instance,"egret.DisplayObjectContainer"))  //true
    -     *     egret.log(egret.is(instance,"egret.Bitmap"))  //false
    -     * 
    - * @see egret.registerClass() - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function is(instance: any, typeName: string): boolean; -} -declare namespace egret { - /** - * Register and start a timer,which will notify the callback method at a rate of 60 FPS ,and pass the current time stamp as parameters.
    - * Note: After the registration,it will notify the callback method continuously,you can call the stopTick () method to stop it. - * @param callBack the call back method. the timeStamp parameter of this method represents the number of milliseconds - * since the Egret framework was initialized. If the return value of this method is true, it will force Egret runtime - * to render after processing of this method completes. - * @param thisObject the call back method's "this" - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 注册并启动一个计时器,通常会以60FPS的速率触发回调方法,并传入当前时间戳。注意:注册后将会持续触发回调方法,若要停止回调,需要手动调用stopTick()方法。 - * @param callBack 要执行的回调方法。参数 timeStamp 表示从启动Egret框架开始经过的时间(毫秒)。 - * 若回调方法返回值为true,其作用与TimerEvent.updateAfterEvent()类似,将会忽略帧频限制,在此方法处理完成后立即重绘屏幕。 - * @param thisObject 回调方法的this对象引用。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function startTick(callBack: (timeStamp: number) => boolean, thisObject: any): void; -} -declare namespace egret { - /** - * Stops the timer started by the egret.startTick() method. - * @param callBack the call back method. the timeStamp parameter of this method represents the number of milliseconds - * since the Egret framework was initialized. If the return value of this method is true, it will force Egret runtime - * to render after processing of this method completes. - * @param thisObject the call back method's "this" - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 停止之前用 startTick() 方法启动的计时器。 - * @param callBack 要执行的回调方法。参数 timeStamp 表示从启动Egret框架开始经过的时间(毫秒)。 - * 若回调方法返回值为true,其作用与TimerEvent.updateAfterEvent()类似,将会忽略帧频限制,在此方法处理完成后立即重绘屏幕。 - * @param thisObject 回调方法的this对象引用。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - function stopTick(callBack: (timeStamp: number) => boolean, thisObject: any): void; -} -declare namespace egret { - /** - * Transfer number to color character string - * @param value {number} color value ,such as 0xffffff - * @returns {string} Color character string, for example, #ffffff. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/toColorString.ts - * @language en_US - */ - /** - * 转换数字为颜色字符串 - * @param value {number} 颜色值,例如 0xffffff - * @returns {string} 颜色字符串,例如"#ffffff"。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/toColorString.ts - * @language zh_CN - */ - function toColorString(value: number): string; -} -/** - * @private - */ -interface PlayerOption { - /** - * 入口类完整类名 - */ - entryClassName?: string; - /** - * 默认帧率 - */ - frameRate?: number; - /** - * 屏幕适配模式 - */ - scaleMode?: string; - /** - * 初始内容宽度 - */ - contentWidth?: number; - /** - * 初始内容高度 - */ - contentHeight?: number; - /** - * 屏幕方向 - */ - orientation?: string; - /** - * 显示FPS - */ - showFPS?: boolean; - /** - * - */ - fpsStyles?: Object; - /** - * 显示日志 - */ - showLog?: boolean; - /** - * 过滤日志的正则表达式 - */ - logFilter?: string; - /** - * - */ - maxTouches?: number; - /** - * - */ - textureScaleFactor?: number; -} diff --git a/source/lib/tween.d.ts b/source/lib/tween.d.ts deleted file mode 100644 index 6a3093a3..00000000 --- a/source/lib/tween.d.ts +++ /dev/null @@ -1,1350 +0,0 @@ -declare namespace egret { - /** - * Easing function set. Different easing functions are used to make an animation proceed according to the corresponding equation - * @see http://edn.egret.com/cn/index.php/article/index/id/53 Easing effect Demo - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 缓动函数集合,使用不同的缓动函数使得动画按照对应的方程进行 - * @see http://edn.egret.com/cn/index.php/article/index/id/53 缓动效果演示 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - class Ease { - /** - * @version Egret 2.4 - * @platform Web,Native - */ - constructor(); - /** - * get.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * get。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static get(amount: number): (t: number) => number; - /** - * get pow in.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * get pow in。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static getPowIn(pow: number): (t: number) => number; - /** - * get pow out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * get pow out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static getPowOut(pow: number): (t: number) => number; - /** - * get pow in out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * get pow in out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static getPowInOut(pow: number): (t: number) => number; - /** - * quad in.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * quad in。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static quadIn: (t: number) => number; - /** - * quad out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * quad out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static quadOut: (t: number) => number; - /** - * quad in out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * quad in out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static quadInOut: (t: number) => number; - /** - * cubic in.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * cubic in。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static cubicIn: (t: number) => number; - /** - * cubic out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * cubic out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static cubicOut: (t: number) => number; - /** - * cubic in out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * cubic in out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static cubicInOut: (t: number) => number; - /** - * quart in.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * quart in。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static quartIn: (t: number) => number; - /** - * quart out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * quart out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static quartOut: (t: number) => number; - /** - * quart in out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * quart in out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static quartInOut: (t: number) => number; - /** - * quint in.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * quint in。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static quintIn: (t: number) => number; - /** - * quint out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * quint out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static quintOut: (t: number) => number; - /** - * quint in out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * quint in out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static quintInOut: (t: number) => number; - /** - * sine in.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * sine in。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static sineIn(t: number): number; - /** - * sine out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * sine out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static sineOut(t: number): number; - /** - * sine in out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * sine in out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static sineInOut(t: number): number; - /** - * get back in.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * get back in。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static getBackIn(amount: number): (t: number) => number; - /** - * back in.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * back in。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static backIn: (t: number) => number; - /** - * get back out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * get back out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static getBackOut(amount: number): (t: any) => number; - /** - * back out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * back out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static backOut: (t: any) => number; - /** - * get back in out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * get back in out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static getBackInOut(amount: number): (t: number) => number; - /** - * back in out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * back in out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static backInOut: (t: number) => number; - /** - * circ in.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * circ in。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static circIn(t: number): number; - /** - * circ out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * circ out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static circOut(t: number): number; - /** - * circ in out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * circ in out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static circInOut(t: number): number; - /** - * bounce in.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * bounce in。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static bounceIn(t: number): number; - /** - * bounce out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * bounce out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static bounceOut(t: number): number; - /** - * bounce in out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * bounce in out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static bounceInOut(t: number): number; - /** - * get elastic in.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * get elastic in。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static getElasticIn(amplitude: number, period: number): (t: number) => number; - /** - * elastic in.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * elastic in。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static elasticIn: (t: number) => number; - /** - * get elastic out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * get elastic out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static getElasticOut(amplitude: number, period: number): (t: number) => number; - /** - * elastic out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * elastic out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static elasticOut: (t: number) => number; - /** - * get elastic in out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * get elastic in out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static getElasticInOut(amplitude: number, period: number): (t: number) => number; - /** - * elastic in out.See example. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * elastic in out。请查看示例 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static elasticInOut: (t: number) => number; - } -} -declare namespace egret { - /** - * Tween is the animation easing class of Egret - * @see http://edn.egret.com/cn/docs/page/576 Tween ease animation - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/tween/Tween.ts - * @language en_US - */ - /** - * Tween是Egret的动画缓动类 - * @see http://edn.egret.com/cn/docs/page/576 Tween缓动动画 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample extension/tween/Tween.ts - * @language zh_CN - */ - class Tween extends EventDispatcher { - /** - * 不做特殊处理 - * @constant {number} egret.Tween.NONE - * @private - */ - private static NONE; - /** - * 循环 - * @constant {number} egret.Tween.LOOP - * @private - */ - private static LOOP; - /** - * 倒序 - * @constant {number} egret.Tween.REVERSE - * @private - */ - private static REVERSE; - /** - * @private - */ - private static _tweens; - /** - * @private - */ - private static IGNORE; - /** - * @private - */ - private static _plugins; - /** - * @private - */ - private static _inited; - /** - * @private - */ - private _target; - /** - * @private - */ - private _useTicks; - /** - * @private - */ - private ignoreGlobalPause; - /** - * @private - */ - private loop; - /** - * @private - */ - private pluginData; - /** - * @private - */ - private _curQueueProps; - /** - * @private - */ - private _initQueueProps; - /** - * @private - */ - private _steps; - /** - * @private - */ - private paused; - /** - * @private - */ - private duration; - /** - * @private - */ - private _prevPos; - /** - * @private - */ - private position; - /** - * @private - */ - private _prevPosition; - /** - * @private - */ - private _stepPosition; - /** - * @private - */ - private passive; - /** - * Activate an object and add a Tween animation to the object - * @param target {any} The object to be activated - * @param props {any} Parameters, support loop onChange onChangeObj - * @param pluginData {any} Write realized - * @param override {boolean} Whether to remove the object before adding a tween, the default value false - * Not recommended, you can use Tween.removeTweens(target) instead. - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 激活一个对象,对其添加 Tween 动画 - * @param target {any} 要激活 Tween 的对象 - * @param props {any} 参数,支持loop(循环播放) onChange(变化函数) onChangeObj(变化函数作用域) - * @param pluginData {any} 暂未实现 - * @param override {boolean} 是否移除对象之前添加的tween,默认值false。 - * 不建议使用,可使用 Tween.removeTweens(target) 代替。 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static get(target: any, props?: { - loop?: boolean; - onChange?: Function; - onChangeObj?: any; - }, pluginData?: any, override?: boolean): Tween; - /** - * Delete all Tween animations from an object - * @param target The object whose Tween to be deleted - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 删除一个对象上的全部 Tween 动画 - * @param target 需要移除 Tween 的对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static removeTweens(target: any): void; - /** - * Pause all Tween animations of a certain object - * @param target The object whose Tween to be paused - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 暂停某个对象的所有 Tween - * @param target 要暂停 Tween 的对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static pauseTweens(target: any): void; - /** - * Resume playing all easing of a certain object - * @param target The object whose Tween to be resumed - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 继续播放某个对象的所有缓动 - * @param target 要继续播放 Tween 的对象 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static resumeTweens(target: any): void; - /** - * @private - * - * @param delta - * @param paused - */ - private static tick(timeStamp, paused?); - private static _lastTime; - /** - * @private - * - * @param tween - * @param value - */ - private static _register(tween, value); - /** - * Delete all Tween - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 删除所有 Tween - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - static removeAllTweens(): void; - /** - * 创建一个 egret.Tween 对象 - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - constructor(target: any, props: any, pluginData: any); - /** - * @private - * - * @param target - * @param props - * @param pluginData - */ - private initialize(target, props, pluginData); - /** - * @private - * - * @param value - * @param actionsMode - * @returns - */ - setPosition(value: number, actionsMode?: number): boolean; - /** - * @private - * - * @param startPos - * @param endPos - * @param includeStart - */ - private _runAction(action, startPos, endPos, includeStart?); - /** - * @private - * - * @param step - * @param ratio - */ - private _updateTargetProps(step, ratio); - /** - * Whether setting is paused - * @param value {boolean} Whether to pause - * @returns Tween object itself - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 设置是否暂停 - * @param value {boolean} 是否暂停 - * @returns Tween对象本身 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - setPaused(value: boolean): Tween; - /** - * @private - * - * @param props - * @returns - */ - private _cloneProps(props); - /** - * @private - * - * @param o - * @returns - */ - private _addStep(o); - /** - * @private - * - * @param o - * @returns - */ - private _appendQueueProps(o); - /** - * @private - * - * @param o - * @returns - */ - private _addAction(o); - /** - * @private - * - * @param props - * @param o - */ - private _set(props, o); - /** - * Wait the specified milliseconds before the execution of the next animation - * @param duration {number} Waiting time, in milliseconds - * @param passive {boolean} Whether properties are updated during the waiting time - * @returns Tween object itself - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 等待指定毫秒后执行下一个动画 - * @param duration {number} 要等待的时间,以毫秒为单位 - * @param passive {boolean} 等待期间属性是否会更新 - * @returns Tween对象本身 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - wait(duration: number, passive?: boolean): Tween; - /** - * Modify the property of the specified object to a specified value - * @param props {Object} Property set of an object - * @param duration {number} Duration - * @param ease {egret.Ease} Easing algorithm - * @returns {egret.Tween} Tween object itself - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 将指定对象的属性修改为指定值 - * @param props {Object} 对象的属性集合 - * @param duration {number} 持续时间 - * @param ease {egret.Ease} 缓动算法 - * @returns {egret.Tween} Tween对象本身 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - to(props: any, duration?: number, ease?: Function): Tween; - /** - * Execute callback function - * @param callback {Function} Callback method - * @param thisObj {any} this action scope of the callback method - * @param params {any[]} Parameter of the callback method - * @returns {egret.Tween} Tween object itself - * @version Egret 2.4 - * @platform Web,Native - * @example - *
    -         *  egret.Tween.get(display).call(function (a:number, b:string) {
    -         *      console.log("a: " + a); // the first parameter passed 233
    -         *      console.log("b: " + b); // the second parameter passed “hello”
    -         *  }, this, [233, "hello"]);
    -         * 
    - * @language en_US - */ - /** - * 执行回调函数 - * @param callback {Function} 回调方法 - * @param thisObj {any} 回调方法this作用域 - * @param params {any[]} 回调方法参数 - * @returns {egret.Tween} Tween对象本身 - * @version Egret 2.4 - * @platform Web,Native - * @example - *
    -         *  egret.Tween.get(display).call(function (a:number, b:string) {
    -         *      console.log("a: " + a); //对应传入的第一个参数 233
    -         *      console.log("b: " + b); //对应传入的第二个参数 “hello”
    -         *  }, this, [233, "hello"]);
    -         * 
    - * @language zh_CN - */ - call(callback: Function, thisObj?: any, params?: any[]): Tween; - /** - * Now modify the properties of the specified object to the specified value - * @param props {Object} Property set of an object - * @param target The object whose Tween to be resumed - * @returns {egret.Tween} Tween object itself - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * 立即将指定对象的属性修改为指定值 - * @param props {Object} 对象的属性集合 - * @param target 要继续播放 Tween 的对象 - * @returns {egret.Tween} Tween对象本身 - * @version Egret 2.4 - * @platform Web,Native - */ - set(props: any, target?: any): Tween; - /** - * Execute - * @param tween {egret.Tween} The Tween object to be operated. Default: this - * @returns {egret.Tween} Tween object itself - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 执行 - * @param tween {egret.Tween} 需要操作的 Tween 对象,默认this - * @returns {egret.Tween} Tween对象本身 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - play(tween?: Tween): Tween; - /** - * Pause - * @param tween {egret.Tween} The Tween object to be operated. Default: this - * @returns {egret.Tween} Tween object itself - * @version Egret 2.4 - * @platform Web,Native - * @language en_US - */ - /** - * 暂停 - * @param tween {egret.Tween} 需要操作的 Tween 对象,默认this - * @returns {egret.Tween} Tween对象本身 - * @version Egret 2.4 - * @platform Web,Native - * @language zh_CN - */ - pause(tween?: Tween): Tween; - /** - * @method egret.Tween#tick - * @param delta {number} - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - $tick(delta: number): void; - } -} -declare namespace egret.tween { - type EaseType = 'quadIn' | 'quadOut' | 'quadOut' | 'quadInOut' | 'cubicIn' | 'cubicOut' | 'cubicInOut' | 'quartIn' | 'quartOut' | 'quartInOut' | 'quintIn' | 'quintOut' | 'quintInOut' | 'sineIn' | 'sineOut' | 'sineInOut' | 'backIn' | 'backOut' | 'backInOut' | 'circIn' | 'circOut' | 'circInOut' | 'bounceIn' | 'bounceOut' | 'bounceInOut' | 'elasticIn' | 'elasticOut' | 'elasticInOut'; - /** - * Abstract class, Indicate the base action. - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 抽象类,表示一个基本动作 - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - abstract class BasePath extends EventDispatcher { - /** - * the name of this action. - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 动作的名称 - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - name: string; - } - /** - * Indicate the to action. See Tween.to - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 表示一个to动作,参见Tween.to - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - class To extends BasePath { - /** - * Property set of an object - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 对象的属性集合 - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - props: Object; - /** - * Duration - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 持续时间 - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - duration: number; - /** - * Easing algorithm - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 缓动算法 - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - ease: EaseType | Function; - } - /** - * Indicate the wait action. See Tween.wait - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 表示一个wait动作,参见Tween.wait - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - class Wait extends BasePath { - /** - * Duration - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 持续时间 - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - duration: number; - /** - * Whether properties are updated during the waiting time - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 等待期间属性是否会更新 - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - passive: boolean; - } - /** - * Indicate the set action. See Tween.set - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 表示一个set动作,参见Tween.set - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - class Set extends BasePath { - /** - * Property set of an object - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 对象的属性集合 - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - props: Object; - } - /** - * Indicate the tick action. See Tween.tick - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 表示一个tick动作,参见Tween.tick - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - class Tick extends BasePath { - /** - * Delta time - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 增加的时间 - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - delta: number; - } - /** - * TweenItem is a wrapper for Tween, which can set the behavior of Tween by setting attributes and adding Path. - * - * @event pathComplete Dispatched when some Path has complete. - * @event complete Dispatched when all Paths has complete. - * - * @defaultProperty props - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * TweenItem是对Tween的包装器,能通过设置属性和添加Path的方式设置Tween的行为。 - * 通常用于使用在EXML中定义组件的动画。 - * - * @event pathComplete 当某个Path执行完毕时会派发此事件。 - * @event complete 当所有Path执行完毕时会派发此事件。 - * - * @defaultProperty props - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - /** - * Use in exml: - * ``` - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * ``` - */ - class TweenItem extends EventDispatcher { - private tween; - constructor(); - /** - * @private - */ - private _props; - /** - * The Tween's props. - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * Tween的props参数。 - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - props: any; - /** - * @private - */ - private _target; - /** - * The Tween's target. - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * Tween的target参数。 - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - target: any; - /** - * @private - */ - private _paths; - /** - * The Actions in Tween. - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * TweenItem中添加的行为。 - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - paths: BasePath[]; - /** - * Play the Tween - * @position The starting position, the default is from the last position to play - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 播放Tween - * @position 播放的起始位置, 默认为从上次位置继续播放 - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - play(position?: number): void; - /** - * Pause the Tween - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 暂停Tween - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - pause(): void; - private isStop; - /** - * Stop the Tween - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 停止Tween - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - stop(): void; - private createTween(position); - private applyPaths(); - private applyPath(path); - private pathComplete(path); - } - /** - * TweenGroup is a collection of TweenItem that can be played in parallel with each Item - * - * @event itemComplete Dispatched when some TweenItem has complete. - * @event complete Dispatched when all TweenItems has complete. - * - * @version Egret 3.1.8 - * @platform Web,Native - * @includeExample extension/tween/TweenWrapper.ts - * @language en_US - */ - /** - * TweenGroup是TweenItem的集合,可以并行播放每一个Item - * @version Egret 3.1.8 - * @platform Web,Native - * @includeExample extension/tween/TweenWrapper.ts - * @language zh_CN - */ - class TweenGroup extends EventDispatcher { - private completeCount; - constructor(); - /** - * @private - */ - private _items; - /** - * The Array that TweenItems in TweenGroup. - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * TweenGroup要控制的TweenItem集合。 - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - items: TweenItem[]; - private registerEvent(add); - /** - * Play the all TweenItems - * @time The starting position, the default is from the last position to play。If use 0, the group will play from the start position. - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 播放所有的TweenItem - * @time 播放的起始位置, 默认为从上次位置继续播放。如果为0,则从起始位置开始播放。 - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - play(time?: number): void; - /** - * Pause the all TweenItems - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 暂停播放所有的TweenItem - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - pause(): void; - /** - * Stop the all TweenItems - * @version Egret 3.1.8 - * @platform Web,Native - * @language en_US - */ - /** - * 停止所有的TweenItem - * @version Egret 3.1.8 - * @platform Web,Native - * @language zh_CN - */ - stop(): void; - private itemComplete(e); - } -} diff --git a/source/src/Debug/Debug.ts b/source/src/Debug/Debug.ts deleted file mode 100644 index e40721dc..00000000 --- a/source/src/Debug/Debug.ts +++ /dev/null @@ -1,40 +0,0 @@ -/// -module es { - export class Colors { - public static renderableBounds = 0xffff00; - public static renderableCenter = 0x9932CC; - public static colliderBounds = 0x555555; - public static colliderEdge = 0x8B0000; - public static colliderPosition = 0xFFFF00; - public static colliderCenter = 0xFF0000; - } - - export class Size { - public static get lineSizeMultiplier(){ - return Math.max(Math.ceil(Core.scene.x / Core.scene.width), 1); - } - } - - export class Debug { - private static _debugDrawItems: DebugDrawItem[] = []; - - public static drawHollowRect(rectanle: Rectangle, color: number, duration = 0) { - this._debugDrawItems.push(new DebugDrawItem(rectanle, color, duration)); - } - - public static render() { - if (this._debugDrawItems.length > 0) { - let debugShape = new egret.Shape(); - if (Core.scene) { - Core.scene.addChild(debugShape); - } - - for (let i = this._debugDrawItems.length - 1; i >= 0; i--) { - let item = this._debugDrawItems[i]; - if (item.draw(debugShape)) - this._debugDrawItems.removeAt(i); - } - } - } - } -} diff --git a/source/src/Debug/DebugDrawItem.ts b/source/src/Debug/DebugDrawItem.ts deleted file mode 100644 index a68619dc..00000000 --- a/source/src/Debug/DebugDrawItem.ts +++ /dev/null @@ -1,49 +0,0 @@ -module es { - export enum DebugDrawType { - line, - hollowRectangle, - pixel, - text - } - - export class DebugDrawItem { - public rectangle: Rectangle; - public color: number; - public duration: number; - public drawType: DebugDrawType; - public text: string; - public start: Vector2; - public end: Vector2; - public x: number; - public y: number; - public size: number; - - constructor(rectangle: Rectangle, color: number, duration: number) { - this.rectangle = rectangle; - this.color = color; - this.duration = duration; - this.drawType = DebugDrawType.hollowRectangle; - } - - public draw(shape: egret.Shape): boolean { - switch (this.drawType) { - case DebugDrawType.line: - // DrawUtils.drawLine(shape, this.start, this.end, this.color); - break; - case DebugDrawType.hollowRectangle: - // DrawUtils.drawHollowRect(shape, this.rectangle, this.color); - break; - case DebugDrawType.pixel: - // DrawUtils.drawPixel(shape, new Vector2(this.x, this.y), this.color, this.size); - break; - case DebugDrawType.text: - break; - } - - this.duration -= Time.deltaTime; - return this.duration < 0; - } - } -} - - diff --git a/source/src/ECS/Component.ts b/source/src/ECS/Component.ts index 800f0d03..fe7b133b 100644 --- a/source/src/ECS/Component.ts +++ b/source/src/ECS/Component.ts @@ -7,7 +7,7 @@ module es { * 删除执行顺序 * - onRemovedFromEntity */ - export abstract class Component extends egret.HashObject { + export abstract class Component { /** * 此组件附加的实体 */ @@ -16,10 +16,6 @@ module es { * 更新该组件的时间间隔。这与实体的更新间隔无关。 */ public updateInterval: number = 1; - /** - * 用于装载debug使用的显示容器 - */ - public debugDisplayObject: egret.DisplayObjectContainer = new egret.DisplayObjectContainer(); /** * 快速访问 this.entity.transform @@ -99,13 +95,7 @@ module es { */ public onDisabled() { } - - /** - * 当该组件启用时每帧进行调用 - */ - public update() { - } - + public setEnabled(isEnabled: boolean) { if (this._enabled != isEnabled) { this._enabled = isEnabled; diff --git a/source/src/ECS/Components/Camera.ts b/source/src/ECS/Components/Camera.ts deleted file mode 100644 index e1df7aa1..00000000 --- a/source/src/ECS/Components/Camera.ts +++ /dev/null @@ -1,369 +0,0 @@ -module es { - export interface CameraInset { - left: number, right: number, top: number, bottom: number - } - - export class Camera extends Component { - public _inset: CameraInset = {left: 0, right: 0, top: 0, bottom: 0}; - public _areMatrixedDirty: boolean = true; - public _areBoundsDirty: boolean = true; - public _isProjectionMatrixDirty = true; - - constructor() { - super(); - this.setZoom(0); - } - - /** - * 对entity.transform.position的快速访问 - */ - public get position() { - return this.entity.transform.position; - } - - /** - * 对entity.transform.position的快速访问 - * @param value - */ - public set position(value: Vector2) { - this.entity.transform.position = value; - } - - /** - * 对entity.transform.rotation的快速访问 - */ - public get rotation(): number { - return this.entity.transform.rotation; - } - - /** - * 对entity.transform.rotation的快速访问 - * @param value - */ - public set rotation(value: number) { - this.entity.transform.rotation = value; - } - - /** - * 原始的缩放值。这就是用于比例矩阵的精确值。默认值为1。 - */ - public get rawZoom(){ - return this._zoom; - } - - /** - * 原始的缩放值。这就是用于比例矩阵的精确值。默认值为1。 - * @param value - */ - public set rawZoom(value: number){ - if (value != this._zoom){ - this._zoom = value; - this._areMatrixedDirty = true; - } - } - - public _zoom: number = 0; - - /** - * 缩放值应该在-1和1之间、然后将该值从minimumZoom转换为maximumZoom。 - * 允许你设置适当的最小/最大值,然后使用更直观的-1到1的映射来更改缩放 - */ - public get zoom() { - if (this._zoom == 0) - return 1; - - if (this._zoom < 1) - return MathHelper.map(this._zoom, this._minimumZoom, 1, -1, 0); - - return MathHelper.map(this._zoom, 1, this._maximumZoom, 0, 1); - } - - /** - * 缩放值应该在-1和1之间、然后将该值从minimumZoom转换为maximumZoom。 - * 允许你设置适当的最小/最大值,然后使用更直观的-1到1的映射来更改缩放 - * @param value - */ - public set zoom(value: number) { - this.setZoom(value); - } - - public _minimumZoom = 0.3; - - /** - * 相机变焦可以达到的最小非缩放值(0-number.max)。默认为0.3 - */ - public get minimumZoom() { - return this._minimumZoom; - } - - /** - * 相机变焦可以达到的最小非缩放值(0-number.max)。默认为0.3 - * @param value - */ - public set minimumZoom(value: number) { - this.setMinimumZoom(value); - } - - public _maximumZoom = 3; - - /** - * 相机变焦可以达到的最大非缩放值(0-number.max)。默认为3 - */ - public get maximumZoom() { - return this._maximumZoom; - } - - /** - * 相机变焦可以达到的最大非缩放值(0-number.max)。默认为3 - * @param value - */ - public set maximumZoom(value: number) { - this.setMaximumZoom(value); - } - - public _bounds: Rectangle = new Rectangle(); - - /** - * 相机的世界-空间边界 - */ - public get bounds() { - if (this._areMatrixedDirty) - this.updateMatrixes(); - - if (this._areBoundsDirty) { - // 旋转或非旋转的边界都需要左上角和右下角 - let topLeft = this.screenToWorldPoint(new Vector2(this._inset.left, this._inset.top)); - let bottomRight = this.screenToWorldPoint(new Vector2(Core.graphicsDevice.viewport.width - this._inset.right, - Core.graphicsDevice.viewport.height - this._inset.bottom)); - - if (this.entity.transform.rotation != 0) { - // 特别注意旋转的边界。我们需要找到绝对的最小/最大值并从中创建边界 - let topRight = this.screenToWorldPoint(new Vector2(Core.graphicsDevice.viewport.width - this._inset.right, - this._inset.top)); - let bottomLeft = this.screenToWorldPoint(new Vector2(this._inset.left, - Core.graphicsDevice.viewport.height - this._inset.bottom)); - - let minX = Math.min(topLeft.x, bottomRight.x, topRight.x, bottomLeft.x); - let maxX = Math.max(topLeft.x, bottomRight.x, topRight.x, bottomLeft.x); - let minY = Math.min(topLeft.y, bottomRight.y, topRight.y, bottomLeft.y); - let maxY = Math.max(topLeft.y, bottomRight.y, topRight.y, bottomLeft.y); - - this._bounds.location = new Vector2(minX, minY); - this._bounds.width = maxX - minX; - this._bounds.height = maxY - minY; - } else { - this._bounds.location = topLeft; - this._bounds.width = bottomRight.x - topLeft.x; - this._bounds.height = bottomRight.y - topLeft.y; - } - - this._areBoundsDirty = false; - } - - return this._bounds; - } - - public _transformMatrix: Matrix2D = new Matrix2D().identity(); - - /** - * 用于从世界坐标转换到屏幕 - */ - public get transformMatrix(): Matrix2D { - if (this._areMatrixedDirty) - this.updateMatrixes(); - return this._transformMatrix; - } - - public _inverseTransformMatrix: Matrix2D = new Matrix2D().identity(); - - /** - * 用于从屏幕坐标到世界的转换 - */ - public get inverseTransformMatrix(): Matrix2D { - if (this._areMatrixedDirty) - this.updateMatrixes(); - return this._inverseTransformMatrix; - } - - public _origin: Vector2 = Vector2.zero; - - public get origin() { - return this._origin; - } - - public set origin(value: Vector2) { - if (this._origin != value) { - this._origin = value; - this._areMatrixedDirty = true; - } - } - - /** - * 设置用于从视口边缘插入摄像机边界的量 - * @param left - * @param right - * @param top - * @param bottom - */ - public setInset(left: number, right: number, top: number, bottom: number): Camera { - this._inset = {left: left, right: right, top: top, bottom: bottom}; - this._areBoundsDirty = true; - return this; - } - - /** - * 对entity.transform.setPosition快速访问 - * @param position - */ - public setPosition(position: Vector2) { - this.entity.transform.setPosition(position.x, position.y); - return this; - } - - /** - * 对entity.transform.setRotation的快速访问 - * @param rotation - */ - public setRotation(rotation: number): Camera { - this.entity.transform.setRotation(rotation); - return this; - } - - /** - * 设置缩放值,缩放值应该在-1到1之间。然后将该值从minimumZoom转换为maximumZoom - * 允许您设置适当的最小/最大值。使用更直观的-1到1的映射来更改缩放 - * @param zoom - */ - public setZoom(zoom: number): Camera { - let newZoom = MathHelper.clamp(zoom, -1, 1); - if (newZoom == 0) { - this._zoom = 1; - } else if (newZoom < 0) { - this._zoom = MathHelper.map(newZoom, -1, 0, this._minimumZoom, 1); - } else { - this._zoom = MathHelper.map(newZoom, 0, 1, 1, this._maximumZoom); - } - this._areMatrixedDirty = true; - - return this; - } - - /** - * 相机变焦可以达到的最小非缩放值(0-number.max) 默认为0.3 - * @param minZoom - */ - public setMinimumZoom(minZoom: number): Camera { - if (minZoom <= 0) { - console.error("minimumZoom must be greater than zero"); - return; - } - - if (this._zoom < minZoom) - this._zoom = this.minimumZoom; - - this._minimumZoom = minZoom; - return this; - } - - /** - * 相机变焦可以达到的最大非缩放值(0-number.max) 默认为3 - * @param maxZoom - */ - public setMaximumZoom(maxZoom: number): Camera { - if (maxZoom <= 0) { - console.error("maximumZoom must be greater than zero"); - return; - } - - if (this._zoom > maxZoom) - this._zoom = maxZoom; - - this._maximumZoom = maxZoom; - return this; - } - - public forceMatrixUpdate(){ - // 弄脏矩阵也会自动弄脏边界 - this._areMatrixedDirty = true; - } - - public onEntityTransformChanged(comp: transform.Component) { - this._areMatrixedDirty = true; - } - - public zoomIn(deltaZoom: number) { - this.zoom += deltaZoom; - } - - public zoomOut(deltaZoom: number) { - this.zoom -= deltaZoom; - } - - /** - * 将一个点从世界坐标转换到屏幕 - * @param worldPosition - */ - public worldToScreenPoint(worldPosition: Vector2): Vector2 { - this.updateMatrixes(); - Vector2Ext.transformR(worldPosition, this._transformMatrix, worldPosition); - return worldPosition; - } - - /** - * 将点从屏幕坐标转换为世界坐标 - * @param screenPosition - */ - public screenToWorldPoint(screenPosition: Vector2): Vector2 { - this.updateMatrixes(); - Vector2Ext.transformR(screenPosition, this._inverseTransformMatrix, screenPosition); - return screenPosition; - } - - /** - * 当场景渲染目标的大小发生变化时,我们会更新相机的原点并调整它的位置以保持它原来的位置 - * @param newWidth - * @param newHeight - */ - public onSceneRenderTargetSizeChanged(newWidth: number, newHeight: number){ - this._isProjectionMatrixDirty = true; - let oldOrigin = this._origin; - this.origin = new Vector2(newWidth / 2, newHeight / 2); - - this.entity.transform.position.add(Vector2.subtract(this._origin, oldOrigin)); - } - - /** - * 返回鼠标在世界空间中的位置 - */ - public mouseToWorldPoint(): Vector2 { - return this.screenToWorldPoint(Input.touchPosition); - } - - protected updateMatrixes() { - if (!this._areMatrixedDirty) - return; - - let tempMat: Matrix2D; - this._transformMatrix = Matrix2D.create().translate(-this.entity.transform.position.x, -this.entity.transform.position.y); - - if (this._zoom != 1) { - tempMat = Matrix2D.create().scale(this._zoom, this._zoom); - this._transformMatrix = this._transformMatrix.multiply(tempMat); - } - - if (this.entity.transform.rotation != 0) { - tempMat = Matrix2D.create().rotate(this.entity.transform.rotation); - this._transformMatrix = this._transformMatrix.multiply(tempMat); - } - - tempMat = Matrix2D.create().translate(Math.floor(this._origin.x), Math.floor(this._origin.y)); - this._transformMatrix = this._transformMatrix.multiply(tempMat); - - this._inverseTransformMatrix = this._transformMatrix.invert(); - - // 无论何时矩阵改变边界都是无效的 - this._areBoundsDirty = true; - this._areMatrixedDirty = false; - } - } -} diff --git a/source/src/ECS/Components/CameraShake.ts b/source/src/ECS/Components/CameraShake.ts deleted file mode 100644 index 47a0c744..00000000 --- a/source/src/ECS/Components/CameraShake.ts +++ /dev/null @@ -1,50 +0,0 @@ -module es { - export class CameraShake extends Component { - public _shakeDirection: Vector2 = Vector2.zero; - public _shakeOffset: Vector2 = Vector2.zero; - public _shakeIntensity = 0; - public _shakeDegredation = 0.95; - - /** - * 如果震动已经在运行,只有震动强度>当前shakeIntensity, 将覆盖当前值 - * 如果shake当前不是活动的,它将被启动。 - * @param shakeIntensify 震动强度 - * @param shakeDegredation 较高的值会导致更快的停止震动 - * @param shakeDirection 0只会导致x/y轴上的振动。任何其他的值将导致通过在抖动方向*强度是相机移动偏移 - */ - public shake(shakeIntensify = 15, shakeDegredation = 0.9, shakeDirection = Vector2.zero){ - this.enabled = true; - if (this._shakeIntensity < shakeIntensify) { - this._shakeDirection = shakeDirection; - this._shakeIntensity = shakeIntensify; - if (shakeDegredation < 0 || shakeDegredation >= 1){ - shakeDegredation = 0.95; - } - - this._shakeDegredation = shakeDegredation; - } - } - - public update() { - if (Math.abs(this._shakeIntensity) > 0){ - this._shakeOffset = this._shakeDirection; - if (this._shakeOffset.x != 0 || this._shakeOffset.y != 0){ - this._shakeOffset.normalize(); - }else{ - this._shakeOffset.x = this._shakeOffset.x + Math.random() - 0.5; - this._shakeOffset.y = this._shakeOffset.y + Math.random() - 0.5; - } - - // TODO: 这需要乘相机变焦 - this._shakeOffset.multiply(new Vector2(this._shakeIntensity)); - this._shakeIntensity *= -this._shakeDegredation; - if (Math.abs(this._shakeIntensity) <= 0.01){ - this._shakeIntensity = 0; - this.enabled = false; - } - } - - this.entity.scene.camera.position.add(this._shakeOffset); - } - } -} \ No newline at end of file diff --git a/source/src/ECS/Components/FollowCamera.ts b/source/src/ECS/Components/FollowCamera.ts deleted file mode 100644 index 668c9af6..00000000 --- a/source/src/ECS/Components/FollowCamera.ts +++ /dev/null @@ -1,186 +0,0 @@ -module es { - export enum CameraStyle { - lockOn, - cameraWindow, - } - - export class FollowCamera extends Component { - public camera: Camera; - - /** - * 如果相机模式为cameraWindow 则会进行缓动移动 - * 该值为移动速度 - */ - public followLerp = 0.1; - /** - * 在cameraWindow模式下,宽度/高度被用做边界框,允许在不移动相机的情况下移动 - * 在lockOn模式下,只使用deadZone的x/y值 你可以通过直接setCenteredDeadzone重写它来自定义deadZone - */ - public deadzone: Rectangle = new Rectangle(); - /** - * 相机聚焦于屏幕中心的偏移 - */ - public focusOffset: Vector2 = Vector2.zero; - /** - * 如果为true 相机位置则不会超出地图矩形(0, 0, mapwidth, mapheight) - */ - public mapLockEnabled: boolean = false; - /** - * 當前地圖映射的寬度和高度 - */ - public mapSize: Rectangle = new Rectangle(); - - public _targetEntity: Entity; - public _targetCollider: Collider; - public _desiredPositionDelta: Vector2 = new Vector2(); - public _cameraStyle: CameraStyle; - public _worldSpaceDeadZone: Rectangle = new Rectangle(); - - private rectShape: egret.Shape = new egret.Shape(); - - constructor(targetEntity: Entity = null, camera: Camera = null, cameraStyle: CameraStyle = CameraStyle.lockOn) { - super(); - - this._targetEntity = targetEntity; - this._cameraStyle = cameraStyle; - this.camera = camera; - } - - public onAddedToEntity() { - if (!this.camera) - this.camera = this.entity.scene.camera; - - this.follow(this._targetEntity, this._cameraStyle); - - Core.emitter.addObserver(CoreEvents.GraphicsDeviceReset, this.onGraphicsDeviceReset, this); - } - - public onGraphicsDeviceReset(){ - // 我们需要这个在下一帧触发 这样相机边界就会更新 - Core.schedule(0, false, this, t => { - let self = t.context as FollowCamera; - self.follow(self._targetEntity, self._cameraStyle); - }); - } - - public update() { - let halfScreen = Vector2.multiply(this.camera.bounds.size, new Vector2(0.5)); - this._worldSpaceDeadZone.x = this.camera.position.x - halfScreen.x * Core.scene.scaleX + this.deadzone.x + this.focusOffset.x; - this._worldSpaceDeadZone.y = this.camera.position.y - halfScreen.y * Core.scene.scaleY + this.deadzone.y + this.focusOffset.y; - this._worldSpaceDeadZone.width = this.deadzone.width; - this._worldSpaceDeadZone.height = this.deadzone.height; - - if (this._targetEntity) - this.updateFollow(); - - this.camera.position = Vector2.lerp(this.camera.position, Vector2.add(this.camera.position, this._desiredPositionDelta), this.followLerp); - this.entity.transform.roundPosition(); - - if (this.mapLockEnabled) { - this.camera.position = this.clampToMapSize(this.camera.position); - this.entity.transform.roundPosition(); - } - } - - public debugRender(camera: Camera) { - if (!this.rectShape) - this.debugDisplayObject.addChild(this.rectShape); - - this.rectShape.graphics.clear(); - if (this._cameraStyle == CameraStyle.lockOn){ - this.rectShape.graphics.beginFill(0x8B0000, 0); - this.rectShape.graphics.lineStyle(1, 0x8B0000); - this.rectShape.graphics.drawRect(this._worldSpaceDeadZone.x - 5 - camera.bounds.x, this._worldSpaceDeadZone.y - 5 - camera.bounds.y, - this._worldSpaceDeadZone.width, this._worldSpaceDeadZone.height); - this.rectShape.graphics.endFill(); - } else { - this.rectShape.graphics.beginFill(0x8B0000, 0); - this.rectShape.graphics.lineStyle(1, 0x8B0000); - this.rectShape.graphics.drawRect(this._worldSpaceDeadZone.x - camera.bounds.x, this._worldSpaceDeadZone.y - camera.bounds.y, - this._worldSpaceDeadZone.width, this._worldSpaceDeadZone.height); - this.rectShape.graphics.endFill(); - } - } - - - /** - * 固定相机 永远不会离开地图的可见区域 - * @param position - */ - public clampToMapSize(position: Vector2) { - let halfScreen = Vector2.multiply(this.camera.bounds.size, new Vector2(0.5)).add(new Vector2(this.mapSize.x, this.mapSize.y)); - let cameraMax = new Vector2(this.mapSize.width - halfScreen.x, this.mapSize.height - halfScreen.y); - - return Vector2.clamp(position, halfScreen, cameraMax); - } - - public follow(targetEntity: Entity, cameraStyle: CameraStyle = CameraStyle.cameraWindow) { - this._targetEntity = targetEntity; - this._cameraStyle = cameraStyle; - let cameraBounds = this.camera.bounds; - - switch (this._cameraStyle) { - case CameraStyle.cameraWindow: - let w = cameraBounds.width / 6; - let h = cameraBounds.height / 3; - this.deadzone = new Rectangle((cameraBounds.width - w) / 2, (cameraBounds.height - h) / 2, w, h); - break; - case CameraStyle.lockOn: - this.deadzone = new Rectangle(cameraBounds.width / 2, cameraBounds.height / 2, 10, 10); - break; - } - } - - public updateFollow() { - this._desiredPositionDelta.x = this._desiredPositionDelta.y = 0; - - if (this._cameraStyle == CameraStyle.lockOn) { - let targetX = this._targetEntity.transform.position.x; - let targetY = this._targetEntity.transform.position.y; - - if (this._worldSpaceDeadZone.x > targetX) - this._desiredPositionDelta.x = targetX - this._worldSpaceDeadZone.x; - else if (this._worldSpaceDeadZone.x < targetX) - this._desiredPositionDelta.x = targetX - this._worldSpaceDeadZone.x; - - if (this._worldSpaceDeadZone.y < targetY) - this._desiredPositionDelta.y = targetY - this._worldSpaceDeadZone.y; - else if (this._worldSpaceDeadZone.y > targetY) - this._desiredPositionDelta.y = targetY - this._worldSpaceDeadZone.y; - } else { - if (!this._targetCollider) { - this._targetCollider = this._targetEntity.getComponent(Collider); - if (!this._targetCollider) - return; - } - - let targetBounds = this._targetEntity.getComponent(Collider).bounds; - if (!this._worldSpaceDeadZone.containsRect(targetBounds)) { - if (this._worldSpaceDeadZone.left > targetBounds.left) - this._desiredPositionDelta.x = targetBounds.left - this._worldSpaceDeadZone.left; - else if (this._worldSpaceDeadZone.right < targetBounds.right) - this._desiredPositionDelta.x = targetBounds.right - this._worldSpaceDeadZone.right; - - if (this._worldSpaceDeadZone.bottom < targetBounds.bottom) - this._desiredPositionDelta.y = targetBounds.bottom - this._worldSpaceDeadZone.bottom; - else if (this._worldSpaceDeadZone.top > targetBounds.top) - this._desiredPositionDelta.y = targetBounds.top - this._worldSpaceDeadZone.top; - } - } - } - - /** - * 以给定的尺寸设置当前相机边界中心的死区 - * @param width - * @param height - */ - public setCenteredDeadzone(width: number, height: number) { - if (!this.camera){ - console.error("相机是null。我们不能得到它的边界。请等到该组件添加到实体之后"); - return; - } - let cameraBounds = this.camera.bounds; - this.deadzone = new Rectangle((cameraBounds.width - width) / 2, (cameraBounds.height - height) / 2, width, height); - } - } -} \ No newline at end of file diff --git a/source/src/ECS/Components/IUpdatable.ts b/source/src/ECS/Components/IUpdatable.ts index eb976408..81d29d9a 100644 --- a/source/src/ECS/Components/IUpdatable.ts +++ b/source/src/ECS/Components/IUpdatable.ts @@ -1,4 +1,7 @@ module es { + /** + * 接口,当添加到一个Component时,只要Component和实体被启用,它就会在每个框架中调用更新方法。 + */ export interface IUpdatable { enabled: boolean; updateOrder: number; @@ -9,8 +12,10 @@ module es { * 用于比较组件更新排序 */ export class IUpdatableComparer implements IComparer { - public compare(a: Component, b: Component) { + public compare(a: IUpdatable, b: IUpdatable) { return a.updateOrder - b.updateOrder; } } + + export var isIUpdatable = (props: any): props is IUpdatable => typeof (props as IUpdatable)['js'] !== 'undefined'; } \ No newline at end of file diff --git a/source/src/ECS/Components/Physics/Colliders/BoxCollider.ts b/source/src/ECS/Components/Physics/Colliders/BoxCollider.ts index 01594ed3..f4c14b03 100644 --- a/source/src/ECS/Components/Physics/Colliders/BoxCollider.ts +++ b/source/src/ECS/Components/Physics/Colliders/BoxCollider.ts @@ -1,31 +1,14 @@ /// module es { export class BoxCollider extends Collider { - public hollowShape: egret.Shape = new egret.Shape(); - public polygonShape: egret.Shape = new egret.Shape(); - public pixelShape1: egret.Shape = new egret.Shape(); - public pixelShape2: egret.Shape = new egret.Shape(); /** * 零参数构造函数要求RenderableComponent在实体上,这样碰撞器可以在实体被添加到场景时调整自身的大小。 */ - constructor(x?: number, y?: number, width?: number, height?: number) { + constructor(x: number, y: number, width: number, height: number) { super(); - if (x == undefined && y == undefined){ - if (width == undefined && height == undefined){ - // 我们在这里插入一个1x1框作为占位符,直到碰撞器在下一阵被添加到实体并可以获得更精确的自动调整大小数据 - this.shape = new Box(1, 1); - this._colliderRequiresAutoSizing = true; - }else if (width != undefined && height != undefined){ - x = -width / 2; - y = -height / 2; - this._localOffset = new Vector2(x + width / 2, y + height / 2); - this.shape = new Box(width, height); - } - }else if (x != undefined && y != undefined && width != undefined && height != undefined){ - this._localOffset = new Vector2(x + width / 2, y + height / 2); - this.shape = new Box(width, height); - } + this._localOffset = new Vector2(x + width / 2, y + height / 2); + this.shape = new Box(width, height); } public get width() { @@ -50,7 +33,6 @@ module es { * @param height */ public setSize(width: number, height: number) { - this._colliderRequiresAutoSizing = false; let box = this.shape as Box; if (width != box.width || height != box.height) { // 更新框,改变边界,如果我们需要更新物理系统中的边界 @@ -67,7 +49,6 @@ module es { * @param width */ public setWidth(width: number): BoxCollider { - this._colliderRequiresAutoSizing = false; let box = this.shape as Box; if (width != box.width) { // 更新框,改变边界,如果我们需要更新物理系统中的边界 @@ -84,7 +65,6 @@ module es { * @param height */ public setHeight(height: number) { - this._colliderRequiresAutoSizing = false; let box = this.shape as Box; if (height != box.height) { // 更新框,改变边界,如果我们需要更新物理系统中的边界 @@ -95,56 +75,6 @@ module es { } public debugRender(camera: Camera) { - let poly = this.shape as Polygon; - if (!this.hollowShape.parent) - this.debugDisplayObject.addChild(this.hollowShape); - - if (!this.polygonShape.parent) - this.debugDisplayObject.addChild(this.polygonShape); - - if (!this.pixelShape1.parent) - this.debugDisplayObject.addChild(this.pixelShape1); - - if (!this.pixelShape2.parent) - this.debugDisplayObject.addChild(this.pixelShape2); - - this.hollowShape.graphics.clear(); - this.hollowShape.graphics.beginFill(Colors.colliderBounds, 0); - this.hollowShape.graphics.lineStyle(Size.lineSizeMultiplier, Colors.colliderBounds); - this.hollowShape.graphics.drawRect(this.bounds.x - camera.bounds.x, this.bounds.y - camera.bounds.y, this.bounds.width, this.bounds.height); - this.hollowShape.graphics.endFill(); - - this.polygonShape.graphics.clear(); - if (poly.points.length >= 2){ - this.polygonShape.graphics.beginFill(Colors.colliderEdge, 0); - this.polygonShape.graphics.lineStyle(Size.lineSizeMultiplier, Colors.colliderEdge); - for (let i = 0; i < poly.points.length; i ++){ - if (i == 0){ - this.polygonShape.graphics.moveTo(poly.position.x + poly.points[i].x - camera.bounds.x, poly.position.y + poly.points[i].y - camera.bounds.y); - }else{ - this.polygonShape.graphics.lineTo(poly.position.x + poly.points[i].x - camera.bounds.x, poly.position.y + poly.points[i].y - camera.bounds.y); - } - } - - this.polygonShape.graphics.lineTo(poly.position.x + poly.points[poly.points.length - 1].x - camera.bounds.x, poly.position.y + poly.points[0].y - camera.bounds.y); - this.polygonShape.graphics.endFill(); - } - - this.pixelShape1.graphics.clear(); - this.pixelShape1.graphics.beginFill(Colors.colliderPosition, 0); - this.pixelShape1.graphics.lineStyle(4 * Size.lineSizeMultiplier, Colors.colliderPosition); - this.pixelShape1.graphics.moveTo(this.entity.transform.position.x - camera.bounds.x, this.entity.transform.position.y - camera.bounds.y); - this.pixelShape1.graphics.lineTo(this.entity.transform.position.x - camera.bounds.x, this.entity.transform.position.y - camera.bounds.y); - this.pixelShape1.graphics.endFill(); - - this.pixelShape2.graphics.clear(); - this.pixelShape2.graphics.beginFill(Colors.colliderCenter, 0); - this.pixelShape2.graphics.lineStyle(2 * Size.lineSizeMultiplier, Colors.colliderCenter); - this.pixelShape2.graphics.moveTo(this.entity.transform.position.x + this.shape.center.x - camera.bounds.x, - this.entity.transform.position.y + this.shape.center.y - camera.bounds.y); - this.pixelShape2.graphics.lineTo(this.entity.transform.position.x + this.shape.center.x - camera.bounds.x, - this.entity.transform.position.y + this.shape.center.y - camera.bounds.y); - this.pixelShape2.graphics.endFill(); } public toString() { diff --git a/source/src/ECS/Components/Physics/Colliders/CircleCollider.ts b/source/src/ECS/Components/Physics/Colliders/CircleCollider.ts index b9881042..eb8c4300 100644 --- a/source/src/ECS/Components/Physics/Colliders/CircleCollider.ts +++ b/source/src/ECS/Components/Physics/Colliders/CircleCollider.ts @@ -1,26 +1,14 @@ module es { export class CircleCollider extends Collider { - private rectShape: egret.Shape = new egret.Shape(); - private circleShape: egret.Shape = new egret.Shape(); - private pixelShape1: egret.Shape = new egret.Shape(); - private pixelShape2: egret.Shape = new egret.Shape(); - /** * 创建一个有半径的圆 * * @param radius */ - constructor(radius?: number) { + constructor(radius: number) { super(); - if (radius == undefined){ - // 我们在这里插入一个1px的圆圈作为占位符 - // 直到碰撞器被添加到实体并可以获得更精确的自动调整大小数据的下一帧 - this.shape = new Circle(1); - this._colliderRequiresAutoSizing = true; - }else{ - this.shape = new Circle(radius); - } + this.shape = new Circle(radius); } public get radius(): number { @@ -36,7 +24,6 @@ module es { * @param radius */ public setRadius(radius: number): CircleCollider { - this._colliderRequiresAutoSizing = false; let circle = this.shape as Circle; if (radius != circle.radius) { circle.radius = radius; @@ -50,43 +37,7 @@ module es { } public debugRender(camera: Camera) { - if (!this.rectShape.parent) - this.debugDisplayObject.addChild(this.rectShape); - - if (!this.circleShape.parent) - this.debugDisplayObject.addChild(this.circleShape); - - if (!this.pixelShape1.parent) - this.debugDisplayObject.addChild(this.pixelShape1); - - if (!this.pixelShape2.parent) - this.debugDisplayObject.addChild(this.pixelShape2); - - this.rectShape.graphics.clear(); - this.rectShape.graphics.beginFill(Colors.colliderBounds, 0); - this.rectShape.graphics.lineStyle(Size.lineSizeMultiplier, Colors.colliderBounds); - this.rectShape.graphics.drawRect(this.bounds.x - camera.bounds.x, this.bounds.y - camera.bounds.y, this.bounds.width, this.bounds.height); - this.rectShape.graphics.endFill(); - - this.circleShape.graphics.clear(); - this.circleShape.graphics.beginFill(Colors.colliderEdge, 0); - this.circleShape.graphics.lineStyle(Size.lineSizeMultiplier, Colors.colliderEdge); - this.circleShape.graphics.drawCircle(this.shape.position.x - camera.bounds.x, this.shape.position.y - camera.bounds.y, (this.shape as Circle).radius); - this.circleShape.graphics.endFill(); - - this.pixelShape1.graphics.clear(); - this.pixelShape1.graphics.beginFill(Colors.colliderPosition, 0); - this.pixelShape1.graphics.lineStyle(4 * Size.lineSizeMultiplier, Colors.colliderPosition); - this.pixelShape1.graphics.moveTo(this.entity.transform.position.x - camera.bounds.x, this.entity.transform.position.y - camera.bounds.y); - this.pixelShape1.graphics.lineTo(this.entity.transform.position.x - camera.bounds.y, this.entity.transform.position.y - camera.bounds.y); - this.pixelShape1.graphics.endFill(); - - this.pixelShape2.graphics.clear(); - this.pixelShape2.graphics.beginFill(Colors.colliderCenter, 0); - this.pixelShape2.graphics.lineStyle(2 * Size.lineSizeMultiplier, Colors.colliderCenter); - this.pixelShape2.graphics.moveTo(this.shape.position.x - camera.bounds.x, this.shape.position.y - camera.bounds.y); - this.pixelShape2.graphics.lineTo(this.shape.position.x - camera.bounds.x, this.shape.position.y - camera.bounds.y); - this.pixelShape2.graphics.endFill(); + } public toString() { diff --git a/source/src/ECS/Components/Physics/Colliders/Collider.ts b/source/src/ECS/Components/Physics/Colliders/Collider.ts index 7389082e..82e9bd01 100644 --- a/source/src/ECS/Components/Physics/Colliders/Collider.ts +++ b/source/src/ECS/Components/Physics/Colliders/Collider.ts @@ -29,7 +29,6 @@ module es { public _localOffsetLength: number; public _isPositionDirty: boolean = true; public _isRotationDirty: boolean = true; - protected _colliderRequiresAutoSizing; /** * 标记来跟踪我们的实体是否被添加到场景中 */ @@ -112,34 +111,6 @@ module es { } public onAddedToEntity() { - if (this._colliderRequiresAutoSizing) { - if (!(this instanceof BoxCollider || this instanceof CircleCollider)) { - console.error("Only box and circle colliders can be created automatically"); - return; - } - - let renderable = this.entity.getComponent(RenderableComponent); - if (renderable) { - let renderableBounds = renderable.bounds; - - // 这里我们需要大小*反尺度,因为当我们自动调整碰撞器的大小时,它需要没有缩放的渲染 - let width = renderableBounds.width / this.entity.transform.scale.x; - let height = renderableBounds.height / this.entity.transform.scale.y; - // 圆碰撞器需要特别注意原点 - if (this instanceof CircleCollider) { - this.radius = Math.max(width, height) * 0.5; - } else { - this.width = width; - this.height = height; - } - - // 获取渲染的中心,将其转移到本地坐标,并使用它作为碰撞器的localOffset - this.localOffset = Vector2.subtract(renderableBounds.center, this.entity.transform.position); - } else { - console.warn("碰撞器没有形状和RenderableComponent。不知道如何调整大小."); - } - } - this._isParentEntityAddedToScene = true; this.registerColliderWithPhysicsSystem(); } diff --git a/source/src/ECS/Components/Renderables/Mesh.ts b/source/src/ECS/Components/Renderables/Mesh.ts deleted file mode 100644 index a35947ab..00000000 --- a/source/src/ECS/Components/Renderables/Mesh.ts +++ /dev/null @@ -1,106 +0,0 @@ -/// -module es { - /** - * 可用于创建简单网格的基本类 - */ - export class Mesh extends RenderableComponent { - public displayObject: egret.Mesh = new egret.Mesh(); - public get bounds(){ - if (this._areBoundsDirty){ - this._bounds.calculateBounds(Vector2.add(this.entity.transform.position, this._topLeftVertPosition), Vector2.zero, - Vector2.zero, this.entity.transform.scale, this.entity.transform.rotation, this._width, this._height); - this._areBoundsDirty = false; - } - - return this._bounds; - } - - public _primitiveCount: number = 0; - public _topLeftVertPosition: Vector2; - public _width: number = 0; - public _height: number = 0; - public _triangles: number[] = []; - public _verts: VertexPositionColorTexture[] = []; - - /** - * 重新计算边界和可选地设置uv。设置uv以最适合的方式映射纹理。 - * @param recalculateUVs - */ - public recalculateBounds(recalculateUVs: boolean){ - this._topLeftVertPosition = new Vector2(Number.MAX_VALUE, Number.MAX_VALUE); - let max = new Vector2(Number.MIN_VALUE, Number.MIN_VALUE); - - for (let i = 0; i < this._verts.length; i ++){ - this._topLeftVertPosition.x = Math.min(this._topLeftVertPosition.x, this._verts[i].position.x); - this._topLeftVertPosition.y = Math.min(this._topLeftVertPosition.y, this._verts[i].position.y); - max.x = Math.max(max.x, this._verts[i].position.x); - max.y = Math.max(max.y, this._verts[i].position.y); - } - - this._width = max.x - this._topLeftVertPosition.x; - this._height = max.y - this._topLeftVertPosition.y; - - // 如果需要处理uv - if (recalculateUVs){ - for (let i = 0; i < this._verts.length; i ++){ - this._verts[i].textureCoordinate.x = (this._verts[i].position.x - this._topLeftVertPosition.x) / this._width; - this._verts[i].textureCoordinate.y = (this._verts[i].position.y - this._topLeftVertPosition.y) / this._height; - } - } - - return this; - } - - /** - * 设置纹理。传入null来取消纹理设置。 - * @param texture - */ - public setTexture(texture: egret.Texture): Mesh{ - this.displayObject.texture = texture; - return this; - } - - /** - * 设置vert位置。如果position数组与vert数组大小不匹配,则将重新创建vert数组。 - * @param positions - */ - public setVertPositions(positions: Vector2[]){ - if (this._verts == undefined || this._verts.length != positions.length){ - this._verts = new Array(positions.length); - this._verts.fill(new VertexPositionColorTexture(), 0, positions.length); - } - - for (let i = 0; i < this._verts.length; i ++){ - this._verts[i].position = positions[i]; - } - return this; - } - - /** - * 设置渲染的三角形索引 - * @param triangles - */ - public setTriangles(triangles: number[]){ - if (triangles.length % 3 != 0){ - console.error("三角形必须是3的倍数"); - return; - } - - this._primitiveCount = triangles.length / 3; - this._triangles = triangles; - return this; - } - - public render(camera: es.Camera) { - let renderNode = this.displayObject.$renderNode as egret.sys.MeshNode; - renderNode.imageWidth = this._width; - renderNode.imageHeight = this._height; - renderNode.vertices = this._triangles; - } - } - - export class VertexPositionColorTexture { - public position: Vector2; - public textureCoordinate: Vector2; - } -} \ No newline at end of file diff --git a/source/src/ECS/Components/Renderables/RenderableComponent.ts b/source/src/ECS/Components/Renderables/RenderableComponent.ts deleted file mode 100644 index 97d4c759..00000000 --- a/source/src/ECS/Components/Renderables/RenderableComponent.ts +++ /dev/null @@ -1,232 +0,0 @@ -/// -module es { - /** - * 所有可渲染组件的基类 - */ - export abstract class RenderableComponent extends Component implements IRenderable { - /** - * 用于装载egret显示对象 - */ - public displayObject: egret.DisplayObject = new egret.DisplayObject(); - public hollowShape: egret.Shape = new egret.Shape(); - public pixelShape: egret.Shape = new egret.Shape(); - /** - * 用于着色器处理精灵 - */ - public color: number = 0x000000; - protected _areBoundsDirty = true; - - /** - * renderableComponent的宽度 - * 如果你不重写bounds属性则需要实现这个 - */ - public get width() { - return this.bounds.width; - } - - /** - * renderableComponent的高度 - * 如果你不重写bounds属性则需要实现这个 - */ - public get height() { - return this.bounds.height; - } - - public debugRenderEnabled: boolean = true; - protected _localOffset: Vector2 = Vector2.zero; - - /** - * 从父实体的偏移量。用于向需要特定定位的实体 - */ - public get localOffset(): Vector2 { - return this._localOffset; - } - - /** - * 从父实体的偏移量。用于向需要特定定位的实体 - * @param value - */ - public set localOffset(value: Vector2) { - this.setLocalOffset(value); - } - - protected _renderLayer: number = 0; - - /** - * 较低的渲染层在前面,较高的在后面 - */ - public get renderLayer(): number { - return this._renderLayer; - } - - public set renderLayer(value: number) { - this.setRenderLayer(value); - } - - protected _bounds: Rectangle = new Rectangle(); - - /** - * 这个物体的AABB, 用于相机剔除 - */ - public get bounds(): Rectangle { - if (this._areBoundsDirty) { - this._bounds.calculateBounds(this.entity.transform.position, this._localOffset, Vector2.zero, - this.entity.transform.scale, this.entity.transform.rotation, this.width, this.height); - this._areBoundsDirty = false; - } - - return this._bounds; - } - - private _isVisible: boolean; - - /** - * 可渲染的可见性。状态的改变会调用onBecameVisible/onBecameInvisible方法 - */ - public get isVisible() { - return this._isVisible; - } - - /** - * 可渲染的可见性。状态的改变会调用onBecameVisible/onBecameInvisible方法 - * @param value - */ - public set isVisible(value: boolean) { - if (this._isVisible != value) { - this._isVisible = value; - - if (this._isVisible) - this.onBecameVisible(); - else - this.onBecameInvisible(); - } - } - - public onEntityTransformChanged(comp: transform.Component) { - this._areBoundsDirty = true; - } - - /** - * 由渲染器调用。可以使用摄像机进行剔除 - * @param camera - */ - public abstract render(camera: Camera); - - public debugRender(camera: Camera) { - if (!this.debugRenderEnabled) - return; - - if (!this.hollowShape.parent) - this.debugDisplayObject.addChild(this.hollowShape); - - if (!this.pixelShape.parent) - this.debugDisplayObject.addChild(this.pixelShape); - - if (!this.entity.getComponent(Collider)){ - this.hollowShape.graphics.clear(); - this.hollowShape.graphics.beginFill(Colors.renderableBounds, 0); - this.hollowShape.graphics.lineStyle(1, Colors.renderableBounds); - this.hollowShape.graphics.drawRect(this.bounds.x - camera.bounds.x, this.bounds.y - camera.bounds.y, this.bounds.width, this.bounds.height); - this.hollowShape.graphics.endFill(); - } - - let pixelPos = Vector2.add(this.entity.transform.position, this._localOffset).subtract(camera.bounds.location); - this.pixelShape.graphics.clear(); - this.pixelShape.graphics.beginFill(Colors.renderableCenter, 0); - this.pixelShape.graphics.lineStyle(4, Colors.renderableCenter); - this.pixelShape.graphics.moveTo(pixelPos.x, pixelPos.y); - this.pixelShape.graphics.lineTo(pixelPos.x, pixelPos.y); - this.pixelShape.graphics.endFill(); - } - - /** - * 如果renderableComponent的边界与camera.bounds相交 返回true - * 用于处理isVisible标志的状态开关 - * 在渲染方法中使用这个方法来决定是否渲染 - * @param camera - */ - public isVisibleFromCamera(camera: Camera): boolean { - if (!camera) - return false; - - this.isVisible = camera.bounds.intersects(this.bounds); - return this.isVisible; - } - - /** - * 较低的渲染层在前面,较高的在后面 - * @param renderLayer - */ - public setRenderLayer(renderLayer: number): RenderableComponent { - if (renderLayer != this._renderLayer) { - this.displayObject.zIndex = renderLayer; - - let oldRenderLayer = this._renderLayer; - this._renderLayer = renderLayer; - // 如果该组件拥有一个实体,那么是由ComponentList管理,需要通知它改变了渲染层 - if (this.entity && this.entity.scene) - this.entity.scene.renderableComponents.updateRenderableRenderLayer(this, oldRenderLayer, this._renderLayer); - } - - return this; - } - - /** - * 用于着色器处理精灵 - * @param color - */ - public setColor(color: number): RenderableComponent { - this.color = color; - return this; - } - - /** - * 从父实体的偏移量。用于向需要特定定位的实体 - * @param offset - */ - public setLocalOffset(offset: Vector2): RenderableComponent { - if (this._localOffset != offset) { - this._localOffset = offset; - } - - return this; - } - - /** - * 进行状态同步 - */ - public sync(camera: Camera) { - if (this.displayObject.x != this.bounds.x - camera.bounds.y) this.displayObject.x = this.bounds.x - camera.bounds.y; - if (this.displayObject.y != this.bounds.y - camera.bounds.y) this.displayObject.y = this.bounds.y - camera.bounds.y; - if (this.displayObject.scaleX != this.entity.scale.x) this.displayObject.scaleX = this.entity.scale.x; - if (this.displayObject.scaleY != this.entity.scale.y) this.displayObject.scaleY = this.entity.scale.y; - if (this.displayObject.rotation != this.entity.rotationDegrees) this.displayObject.rotation = this.entity.rotationDegrees; - } - - public compareTo(other: RenderableComponent){ - return other.renderLayer - this.renderLayer; - } - - public toString() { - return `[RenderableComponent] renderLayer: ${this.renderLayer}`; - } - - /** - * 当renderableComponent进入相机框架时调用 - * 如果渲染器不适用isVisibleFromCamera进行剔除检查 这些方法不会被调用 - */ - protected onBecameVisible() { - this.displayObject.visible = this.isVisible; - this.debugDisplayObject.visible = this.isVisible; - } - - /** - * 当renderableComponent离开相机框架时调用 - * 如果渲染器不适用isVisibleFromCamera进行剔除检查 这些方法不会被调用 - */ - protected onBecameInvisible() { - this.displayObject.visible = this.isVisible; - this.debugDisplayObject.visible = this.isVisible; - } - } -} \ No newline at end of file diff --git a/source/src/ECS/Components/Renderables/Sprites/ScrollingSpriteRenderer.ts b/source/src/ECS/Components/Renderables/Sprites/ScrollingSpriteRenderer.ts deleted file mode 100644 index 217b29b9..00000000 --- a/source/src/ECS/Components/Renderables/Sprites/ScrollingSpriteRenderer.ts +++ /dev/null @@ -1,67 +0,0 @@ -/// -module es { - import Bitmap = egret.Bitmap; - - export class ScrollingSpriteRenderer extends TiledSpriteRenderer { - /** - * x自动滚动速度(以像素/s为单位) - */ - public scrollSpeedX = 15; - /** - * 自动滚动的y速度(以像素/s为单位) - */ - public scroolSpeedY = 0; - - public get textureScale(): Vector2 { - return this._textureScale; - } - - public set textureScale(value: Vector2){ - this._textureScale = value; - - // 重新计算我们的inverseTextureScale和源矩形大小 - this._inverseTexScale = new Vector2(1 / this._textureScale.x, 1 / this._textureScale.y); - } - - public set scrollWidth(value: number){ - this._scrollWidth = value; - } - - public get scrollWidth(){ - return this._scrollWidth; - } - - public set scrollHeight(value: number){ - this._scrollHeight = value; - } - - public get scrollHeight(){ - return this._scrollHeight; - } - - private _scrollX = 0; - private _scrollY = 0; - private _scrollWidth = 0; - private _scrollHeight = 0; - - constructor(sprite: Sprite) { - super(sprite); - - this._scrollWidth = this.width; - this._scrollHeight = this.height; - } - - public update() { - if (!this.sprite) - return; - - this._scrollX += this.scrollSpeedX * Time.deltaTime; - this._scrollY += this.scroolSpeedY * Time.deltaTime; - - this._sourceRect.x = Math.floor(this._scrollX); - this._sourceRect.y = Math.floor(this._scrollY); - this._sourceRect.width = this._scrollWidth + Math.abs(this._scrollX); - this._sourceRect.height = this._scrollHeight + Math.abs(this._scrollY); - } - } -} diff --git a/source/src/ECS/Components/Renderables/Sprites/Sprite.ts b/source/src/ECS/Components/Renderables/Sprites/Sprite.ts deleted file mode 100644 index 2d4c26ec..00000000 --- a/source/src/ECS/Components/Renderables/Sprites/Sprite.ts +++ /dev/null @@ -1,62 +0,0 @@ -module es { - import RenderTexture = egret.RenderTexture; - import Bitmap = egret.Bitmap; - import SpriteSheet = egret.SpriteSheet; - - export class Sprite { - public texture2D: egret.Texture; - public readonly sourceRect: Rectangle; - public readonly center: Vector2; - public origin: Vector2; - public readonly uvs: Rectangle = new Rectangle(); - - constructor(texture: egret.Texture, - sourceRect: Rectangle = new Rectangle(0, 0, texture.textureWidth, texture.textureHeight), - origin: Vector2 = sourceRect.getHalfSize()) { - this.texture2D = texture; - this.sourceRect = sourceRect; - this.center = new Vector2(sourceRect.width * 0.5, sourceRect.height * 0.5); - this.origin = origin; - - let inverseTexW = 1 / texture.textureWidth; - let inverseTexH = 1 / texture.textureHeight; - - this.uvs.x = sourceRect.x * inverseTexW; - this.uvs.y = sourceRect.y * inverseTexH; - this.uvs.width = sourceRect.width * inverseTexW; - this.uvs.height = sourceRect.height * inverseTexH; - } - - /** - * 提供一个精灵的列/行等间隔的图集的精灵列表 - * @param texture - * @param cellWidth - * @param cellHeight - * @param cellOffset 处理时要包含的第一个单元格。基于0的索引 - * @param maxCellsToInclude 包含的最大单元 - */ - public static spritesFromAtlas(texture: egret.Texture, cellWidth: number, cellHeight: number, - cellOffset: number = 0, maxCellsToInclude: number = Number.MAX_VALUE){ - let sprites: Sprite[] = []; - let cols = texture.textureWidth / cellWidth; - let rows = texture.textureHeight / cellHeight; - let i = 0; - let spriteSheet = new SpriteSheet(texture); - - for (let y = 0; y < rows; y ++){ - for (let x = 0; x < cols; x ++) { - if (i++ < cellOffset) continue; - - let texture = spriteSheet.getTexture(`${y}_${x}`); - if (!texture) - texture = spriteSheet.createTexture(`${y}_${x}`, x * cellWidth, y * cellHeight, cellWidth, cellHeight); - sprites.push(new Sprite(texture)); - - if (sprites.length == maxCellsToInclude) return sprites; - } - } - - return sprites; - } - } -} diff --git a/source/src/ECS/Components/Renderables/Sprites/SpriteAnimation.ts b/source/src/ECS/Components/Renderables/Sprites/SpriteAnimation.ts deleted file mode 100644 index 12d38435..00000000 --- a/source/src/ECS/Components/Renderables/Sprites/SpriteAnimation.ts +++ /dev/null @@ -1,11 +0,0 @@ -module es { - export class SpriteAnimation { - public readonly sprites: Sprite[]; - public readonly frameRate: number; - - constructor(sprites: Sprite[], frameRate: number = 10) { - this.sprites = sprites; - this.frameRate = frameRate; - } - } -} diff --git a/source/src/ECS/Components/Renderables/Sprites/SpriteAnimator.ts b/source/src/ECS/Components/Renderables/Sprites/SpriteAnimator.ts deleted file mode 100644 index 41145602..00000000 --- a/source/src/ECS/Components/Renderables/Sprites/SpriteAnimator.ts +++ /dev/null @@ -1,163 +0,0 @@ -/// -module es { - export enum LoopMode { - /** 在一个循环序列[A][B][C][A][B][C][A][B][C]... */ - loop, - /** [A][B][C]然后暂停,设置时间为0 [A] */ - once, - /** [A][B][C]。当它到达终点时,它会继续播放最后一帧,并且不会停止播放 */ - clampForever, - /** 以一个乒乓循环的方式永远播放这个序列 [A][B][C][B][A][B][C][B]... */ - pingPong, - /** 将顺序向前播放一次,然后返回到开始[A][B][C][B][A],然后暂停并设置时间为0 */ - pingPongOnce, - } - - export enum State { - none, - running, - paused, - completed, - } - - export class SpriteAnimator extends SpriteRenderer { - /** - * 在动画完成时触发,包括动画名称 - */ - public onAnimationCompletedEvent: (string) => {}; - /** - * 动画播放速度 - */ - public speed = 1; - /** - * 动画的当前状态 - */ - public animationState = State.none; - /** - * 当前动画 - */ - public currentAnimation: SpriteAnimation; - /** - * 当前动画的名称 - */ - public currentAnimationName: string; - /** - * 当前动画的精灵数组中当前帧的索引 - */ - public currentFrame: number; - public _elapsedTime: number = 0; - public _loopMode: LoopMode; - - constructor(sprite?: Sprite) { - super(sprite); - } - - /** - * 检查当前动画是否正在运行 - */ - public get isRunning(): boolean { - return this.animationState == State.running; - } - - private _animations: Map = new Map(); - - /** 提供对可用动画列表的访问 */ - public get animations() { - return this._animations; - } - - public update() { - if (this.animationState != State.running || !this.currentAnimation) return; - - let animation = this.currentAnimation; - let secondsPerFrame = 1 / (animation.frameRate * this.speed); - let iterationDuration = secondsPerFrame * animation.sprites.length; - - this._elapsedTime += Time.deltaTime; - let time = Math.abs(this._elapsedTime); - - // Once和PingPongOnce完成后重置为Time = 0 - if (this._loopMode == LoopMode.once && time > iterationDuration || - this._loopMode == LoopMode.pingPongOnce && time > iterationDuration * 2) { - this.animationState = State.completed; - this._elapsedTime = 0; - this.currentFrame = 0; - (this.displayObject as egret.Bitmap).texture = animation.sprites[this.currentFrame].texture2D; - return; - } - - // 弄清楚我们在哪个坐标系上 - let i = Math.floor(time / secondsPerFrame); - let n = animation.sprites.length; - if (n > 2 && (this._loopMode == LoopMode.pingPong || this._loopMode == LoopMode.pingPongOnce)) { - // pingpong - let maxIndex = n - 1; - this.currentFrame = maxIndex - Math.abs(maxIndex - i % (maxIndex * 2)); - } else { - this.currentFrame = i % n; - } - - (this.displayObject as egret.Bitmap).texture = animation.sprites[this.currentFrame].texture2D; - } - - /** - * 添加一个SpriteAnimation - * @param name - * @param animation - */ - public addAnimation(name: string, animation: SpriteAnimation): SpriteAnimator { - // 如果我们没有精灵,使用我们找到的第一帧 - if (!this.sprite && animation.sprites.length > 0) - this.setSprite(animation.sprites[0]); - this._animations[name] = animation; - return this; - } - - /** - * 以给定的名称放置动画。如果没有指定循环模式,则默认为循环 - * @param name - * @param loopMode - */ - public play(name: string, loopMode: LoopMode = null) { - this.currentAnimation = this._animations[name]; - this.currentAnimationName = name; - this.currentFrame = 0; - this.animationState = State.running; - (this.displayObject as egret.Bitmap).texture = this.currentAnimation.sprites[0].texture2D; - this._elapsedTime = 0; - this._loopMode = loopMode ? loopMode : LoopMode.loop; - } - - /** - * 检查动画是否正在播放(即动画是活动的)。它可能仍然处于暂停状态) - * @param name - */ - public isAnimationActive(name: string): boolean { - return this.currentAnimation && this.currentAnimationName == name; - } - - /** - * 暂停动画 - */ - public pause() { - this.animationState = State.paused; - } - - /** - * 继续动画 - */ - public unPause() { - this.animationState = State.running; - } - - /** - * 停止当前动画并将其设为null - */ - public stop() { - this.currentAnimation = null; - this.currentAnimationName = null; - this.currentFrame = 0; - this.animationState = State.none; - } - } -} diff --git a/source/src/ECS/Components/Renderables/Sprites/SpriteRenderer.ts b/source/src/ECS/Components/Renderables/Sprites/SpriteRenderer.ts deleted file mode 100644 index 68c0fc0d..00000000 --- a/source/src/ECS/Components/Renderables/Sprites/SpriteRenderer.ts +++ /dev/null @@ -1,134 +0,0 @@ -module es { - import Bitmap = egret.Bitmap; - - export class SpriteRenderer extends RenderableComponent { - constructor(sprite: Sprite | egret.Texture = null) { - super(); - if (sprite instanceof Sprite) - this.setSprite(sprite); - else if (sprite instanceof egret.Texture) - this.setSprite(new Sprite(sprite)); - } - - public get bounds() { - if (this._areBoundsDirty) { - if (this._sprite) { - this._bounds.calculateBounds(this.entity.transform.position, this._localOffset, this._origin, - this.entity.transform.scale, this.entity.transform.rotation, this._sprite.sourceRect.width, - this._sprite.sourceRect.height); - this._areBoundsDirty = false; - } - } - - return this._bounds; - } - - /** - * 用归一化方法设置原点 - * x/y 均为 0-1 - */ - public get originNormalized(): Vector2 { - return new Vector2(this._origin.x / this.width * this.entity.transform.scale.x, - this._origin.y / this.height * this.entity.transform.scale.y); - } - - /** - * 用归一化方法设置原点 - * x/y 均为 0-1 - * @param value - */ - public set originNormalized(value: Vector2) { - this.setOrigin(new Vector2(value.x * this.width / this.entity.transform.scale.x, - value.y * this.height / this.entity.transform.scale.y)); - } - - protected _origin: Vector2; - - /** - * 精灵的原点。这是在设置精灵时自动设置的 - */ - public get origin(): Vector2 { - return this._origin; - } - - /** - * 精灵的原点。这是在设置精灵时自动设置的 - * @param value - */ - public set origin(value: Vector2) { - this.setOrigin(value); - } - - protected _sprite: Sprite; - - /** - * 应该由这个精灵显示的精灵 - * 当设置时,精灵的原点也被设置为精灵的origin - */ - public get sprite(): Sprite { - return this._sprite; - } - - /** - * 应该由这个精灵显示的精灵 - * 当设置时,精灵的原点也被设置为精灵的origin - * @param value - */ - public set sprite(value: Sprite) { - this.setSprite(value); - } - - /** - * 设置精灵并更新精灵的原点以匹配sprite.origin - * @param sprite - */ - public setSprite(sprite: Sprite): SpriteRenderer { - this._sprite = sprite; - if (this._sprite) { - this._origin = this._sprite.origin; - this.displayObject.anchorOffsetX = this._origin.x; - this.displayObject.anchorOffsetY = this._origin.y; - } - this.displayObject = new Bitmap(sprite.texture2D); - this.displayObject.touchEnabled = false; - - return this; - } - - /** - * 设置可渲染的原点 - * @param origin - */ - public setOrigin(origin: Vector2): SpriteRenderer { - if (!this._origin.equals(origin)) { - this._origin = origin; - this.displayObject.anchorOffsetX = this._origin.x; - this.displayObject.anchorOffsetY = this._origin.y; - this._areBoundsDirty = true; - } - - return this; - } - - /** - * 用归一化方法设置原点 - * x/y 均为 0-1 - * @param value - */ - public setOriginNormalized(value: Vector2): SpriteRenderer { - this.setOrigin(new Vector2(value.x * this.width / this.entity.transform.scale.x, - value.y * this.height / this.entity.transform.scale.y)); - return this; - } - - public render(camera: Camera) { - this.sync(camera); - - if (this.displayObject.x != this.bounds.x - camera.bounds.x + this._origin.x) this.displayObject.x = this.bounds.x - camera.bounds.x + this._origin.x * this.entity.scale.x; - if (this.displayObject.y != this.bounds.y - camera.bounds.y + this._origin.y) this.displayObject.y = this.bounds.y - camera.bounds.y + this._origin.y * this.entity.scale.y; - if (this.displayObject.anchorOffsetX != this._origin.x) this.displayObject.anchorOffsetX = this._origin.x; - if (this.displayObject.anchorOffsetY != this._origin.y) this.displayObject.anchorOffsetY = this._origin.y; - } - } -} - diff --git a/source/src/ECS/Components/Renderables/Sprites/StaticSpriteContainerRenderer.ts b/source/src/ECS/Components/Renderables/Sprites/StaticSpriteContainerRenderer.ts deleted file mode 100644 index b7e373ea..00000000 --- a/source/src/ECS/Components/Renderables/Sprites/StaticSpriteContainerRenderer.ts +++ /dev/null @@ -1,127 +0,0 @@ -module es { - import Bitmap = egret.Bitmap; - - export class StaticSpriteContainerRenderer extends RenderableComponent { - public displayObject: egret.DisplayObjectContainer = new egret.DisplayObjectContainer(); - private displayObjectCache: Map = new Map(); - - constructor(sprite: Sprite[] | egret.Texture[] = null) { - super(); - for (let s of sprite){ - if (s instanceof Sprite) - this.pushSprite(s); - else if (s instanceof egret.Texture) - this.pushSprite(new Sprite(s)); - } - - this.displayObject.cacheAsBitmap = true; - } - - public get bounds() { - if (this._areBoundsDirty) { - if (this.displayObject) { - this._bounds.calculateBounds(this.entity.transform.position, this._localOffset, this._origin, - this.entity.transform.scale, this.entity.transform.rotation, this.displayObject.width, - this.displayObject.height); - this._areBoundsDirty = false; - } - } - - return this._bounds; - } - - /** - * 用归一化方法设置原点 - * x/y 均为 0-1 - */ - public get originNormalized(): Vector2 { - return new Vector2(this._origin.x / this.width * this.entity.transform.scale.x, - this._origin.y / this.height * this.entity.transform.scale.y); - } - - /** - * 用归一化方法设置原点 - * x/y 均为 0-1 - * @param value - */ - public set originNormalized(value: Vector2) { - this.setOrigin(new Vector2(value.x * this.width / this.entity.transform.scale.x, - value.y * this.height / this.entity.transform.scale.y)); - } - - protected _origin: Vector2; - - /** - * 精灵的原点。这是在设置精灵时自动设置的 - */ - public get origin(): Vector2 { - return this._origin; - } - - /** - * 精灵的原点。这是在设置精灵时自动设置的 - * @param value - */ - public set origin(value: Vector2) { - this.setOrigin(value); - } - - /** - * 设置精灵并更新精灵的原点以匹配sprite.origin - * @param sprite - */ - public pushSprite(sprite: Sprite): StaticSpriteContainerRenderer { - if (sprite) { - this._origin = sprite.origin; - this.displayObject.anchorOffsetX = this._origin.x; - this.displayObject.anchorOffsetY = this._origin.y; - } - let bitmap = new Bitmap(sprite.texture2D); - this.displayObject.addChild(new Bitmap(sprite.texture2D)); - this.displayObjectCache.set(sprite, bitmap); - - return this; - } - - /** - * - * @param sprite - */ - public getSprite(sprite: Sprite): Bitmap{ - return this.displayObjectCache.get(sprite); - } - - /** - * 设置可渲染的原点 - * @param origin - */ - public setOrigin(origin: Vector2): StaticSpriteContainerRenderer { - if (this._origin != origin) { - this._origin = origin; - this.displayObject.anchorOffsetX = this._origin.x; - this.displayObject.anchorOffsetY = this._origin.y; - this._areBoundsDirty = true; - } - - return this; - } - - /** - * 用归一化方法设置原点 - * x/y 均为 0-1 - * @param value - */ - public setOriginNormalized(value: Vector2): StaticSpriteContainerRenderer { - this.setOrigin(new Vector2(value.x * this.width / this.entity.transform.scale.x, - value.y * this.height / this.entity.transform.scale.y)); - return this; - } - - public render(camera: Camera) { - this.sync(camera); - - if (this.displayObject.x != this.bounds.x - camera.bounds.x) this.displayObject.x = this.bounds.x - camera.bounds.x; - if (this.displayObject.y != this.bounds.y - camera.bounds.y) this.displayObject.y = this.bounds.y - camera.bounds.y; - } - } -} \ No newline at end of file diff --git a/source/src/ECS/Components/Renderables/Sprites/TiledSpriteRenderer.ts b/source/src/ECS/Components/Renderables/Sprites/TiledSpriteRenderer.ts deleted file mode 100644 index ddfe2f19..00000000 --- a/source/src/ECS/Components/Renderables/Sprites/TiledSpriteRenderer.ts +++ /dev/null @@ -1,148 +0,0 @@ -/// -module es { - import Bitmap = egret.Bitmap; - import RenderTexture = egret.RenderTexture; - - /** - * 滚动由两张图片组合而成 - */ - export class TiledSpriteRenderer extends SpriteRenderer { - public get bounds(): Rectangle { - if (this._areBoundsDirty){ - if (this._sprite){ - this._bounds.calculateBounds(this.entity.transform.position, this._localOffset, this._origin, - this.entity.transform.scale, this.entity.transform.rotation, this.width, this.height); - this._areBoundsDirty = false; - } - } - - return this._bounds; - } - - /** - * 纹理滚动的x值 - */ - public get scrollX() { - return this._sourceRect.x; - } - - /** - * 纹理滚动的x值 - * @param value - */ - public set scrollX(value: number) { - this._sourceRect.x = value; - } - - /** - * 纹理滚动的y值 - */ - public get scrollY() { - return this._sourceRect.y; - } - - /** - * 纹理滚动的y值 - * @param value - */ - public set scrollY(value: number) { - this._sourceRect.y = value; - } - - /** - * 纹理比例尺 - */ - public get textureScale(): Vector2 { - return this._textureScale; - } - - /** - * 纹理比例尺 - * @param value - */ - public set textureScale(value: Vector2) { - this._textureScale = value; - - // 重新计算我们的inverseTextureScale和源矩形大小 - this._inverseTexScale = new Vector2(1 / this._textureScale.x, 1 / this._textureScale.y); - this._sourceRect.width = Math.floor(this._sprite.sourceRect.width * this._inverseTexScale.x); - this._sourceRect.height = Math.floor(this._sprite.sourceRect.height * this._inverseTexScale.y); - } - - /** - * 覆盖宽度值,这样TiledSprite可以有一个独立于其纹理的宽度 - */ - public get width(): number{ - return this._sourceRect.width; - } - - public set width(value: number) { - this._areBoundsDirty = true; - this._sourceRect.width = value; - } - - public get height(): number { - return this._sourceRect.height; - } - - public set height(value: number) { - this._areBoundsDirty = true; - this._sourceRect.height = value; - } - - public get gapXY(): Vector2{ - return new Vector2(this._gapX, this._gapY); - } - - public set gapXY(value: Vector2){ - this._gapX = value.x; - this._gapY = value.y; - - let renderTexture = new RenderTexture(); - let newRectangle = this.sprite.sourceRect; - newRectangle.x = 0; - newRectangle.y = 0; - newRectangle.width += this._gapX; - newRectangle.height += this._gapY; - renderTexture.drawToTexture(this.displayObject, newRectangle); - - if (!this.displayObject){ - this.displayObject = new Bitmap(renderTexture); - }else{ - (this.displayObject as Bitmap).texture = renderTexture; - } - } - - protected _sourceRect: Rectangle; - protected _textureScale = Vector2.one; - protected _inverseTexScale = Vector2.one; - private _gapX = 0; - private _gapY = 0; - - constructor(sprite: Sprite) { - super(sprite); - - this._sourceRect = sprite.sourceRect; - let bitmap = this.displayObject as Bitmap; - bitmap.$fillMode = egret.BitmapFillMode.REPEAT; - } - - /** - * 设置间隔 - * @param value - */ - public setGapXY(value: Vector2): TiledSpriteRenderer { - this.gapXY = value; - return this; - } - - public render(camera: es.Camera) { - super.render(camera); - - let bitmap = this.displayObject as Bitmap; - bitmap.width = this.width; - bitmap.height = this.height; - bitmap.scrollRect = this._sourceRect; - } - } -} diff --git a/source/src/ECS/Core.ts b/source/src/ECS/Core.ts index 26ce1c67..108f7dbe 100644 --- a/source/src/ECS/Core.ts +++ b/source/src/ECS/Core.ts @@ -2,7 +2,7 @@ module es { /** * 全局核心类 */ - export class Core extends egret.DisplayObjectContainer { + export class Core { /** * 核心发射器。只发出核心级别的事件 */ @@ -11,14 +11,6 @@ module es { * 是否启用调试渲染 */ public static debugRenderEndabled = false; - /** - * 全局访问图形设备 - */ - public static graphicsDevice: GraphicsDevice; - /** - * 全局内容管理器加载任何应该停留在场景之间的资产 - */ - public static content: ContentManager; /** * 简化对内部类的全局内容实例的访问 */ @@ -29,20 +21,20 @@ module es { * 全局访问系统 */ public _globalManagers: GlobalManager[] = []; - public _coroutineManager: CoroutineManager = new CoroutineManager(); public _timerManager: TimerManager = new TimerManager(); + public width: number; + public height: number; - constructor() { - super(); + constructor(width: number, height: number) { + this.width = width; + this.height = height; Core._instance = this; Core.emitter = new Emitter(); - Core.content = new ContentManager(); - this.addEventListener(egret.Event.ADDED_TO_STAGE, this.onAddToStage, this); - - Core.registerGlobalManager(this._coroutineManager); Core.registerGlobalManager(this._timerManager); + + this.initialize(); } /** @@ -77,7 +69,6 @@ module es { } if (this._instance._scene == null) { - this._instance.addChild(value); this._instance._scene = value; this._instance._scene.begin(); Core.Instance.onSceneChanged(); @@ -130,15 +121,6 @@ module es { return null; } - /** - * 开始了一个协同程序。协程可以使用number延迟几秒,也可以使其他对startCoroutine的调用延迟几秒。 - * 返回null将使协程在下一帧中被执行。 - * @param enumerator - */ - public static startCoroutine(enumerator: Iterator){ - return this._instance._coroutineManager.startCoroutine(enumerator); - } - /** * 调度一个一次性或重复的计时器,该计时器将调用已传递的动作 * @param timeInSeconds @@ -155,8 +137,6 @@ module es { } public async draw() { - // this.startDebugDraw(Time.deltaTime); - if (this._sceneTransition) { this._sceneTransition.preRender(); @@ -176,40 +156,9 @@ module es { } else if (this._scene) { this._scene.render(); - Debug.render(); - // 如果我们没有一个活跃的场景转换,就像平常一样渲染 this._scene.postRender(); } - - // this.endDebugDraw(); - } - - public startDebugUpdate() { - TimeRuler.Instance.startFrame(); - TimeRuler.Instance.beginMark("update", 0x00FF00); - } - - public endDebugUpdate() { - TimeRuler.Instance.endMark("update"); - } - - public startDebugDraw(elapsedGameTime: number){ - TimeRuler.Instance.beginMark("draw", 0xFFD700); - - // fps 计数器 - this._frameCounter ++; - this._frameCounterElapsedTime += elapsedGameTime; - if (this._frameCounterElapsedTime >= 1){ - this._frameCounter = 0; - this._frameCounterElapsedTime -= 1; - } - } - - public endDebugDraw(){ - TimeRuler.Instance.endMark("draw"); - - TimeRuler.Instance.render(); } /** @@ -228,16 +177,9 @@ module es { } protected initialize() { - Graphics.Instance = new Graphics(); } protected async update() { - // this.startDebugUpdate(); - - // 更新我们所有的系统管理器 - Time.update(egret.getTimer()); - Input.update(); - if (this._scene) { for (let i = this._globalManagers.length - 1; i >= 0; i--) { if (this._globalManagers[i].enabled) @@ -254,7 +196,6 @@ module es { } if (this._nextScene) { - if (this._scene.parent) this._scene.parent.removeChild(this._scene); this._scene.end(); this._scene = this._nextScene; @@ -262,25 +203,10 @@ module es { this.onSceneChanged(); await this._scene.begin(); - this.addChild(this._scene); } } - // this.endDebugUpdate(); - await this.draw(); } - - private onAddToStage() { - Core.graphicsDevice = new GraphicsDevice(); - - this.addEventListener(egret.Event.RESIZE, this.onGraphicsDeviceReset, this); - this.addEventListener(egret.StageOrientationEvent.ORIENTATION_CHANGE, this.onOrientationChanged, this); - this.addEventListener(egret.Event.ENTER_FRAME, this.update, this); - - Input.initialize(); - KeyboardUtils.init(); - this.initialize(); - } } } diff --git a/source/src/ECS/Entity.ts b/source/src/ECS/Entity.ts index 7bf15a24..4b3b0be1 100644 --- a/source/src/ECS/Entity.ts +++ b/source/src/ECS/Entity.ts @@ -354,7 +354,7 @@ module es { * @param typeName * @param componentList */ - public getComponents(typeName: string | any, componentList?) { + public getComponents(typeName: any, componentList?) { return this.components.getComponents(typeName, componentList); } diff --git a/source/src/ECS/Scene.ts b/source/src/ECS/Scene.ts index 3fb0c284..86abc5ba 100644 --- a/source/src/ECS/Scene.ts +++ b/source/src/ECS/Scene.ts @@ -1,21 +1,10 @@ module es { - import Bitmap = egret.Bitmap; - /** 场景 */ - export class Scene extends egret.DisplayObjectContainer { + export class Scene { /** * 默认场景摄像机 */ public camera: Camera; - /** - * 场景特定内容管理器。使用它来加载仅由这个场景需要的任何资源。如果你有全局/多场景资源,你可以使用SceneManager.content。 - * contentManager来加载它们,因为Nez不会卸载它们。 - */ - public readonly content: ContentManager; - /** - * 全局切换后处理器 - */ - public enablePostProcessing = true; /** * 这个场景中的实体列表 */ @@ -29,22 +18,13 @@ module es { */ public readonly entityProcessors: EntityProcessorList; - public _screenshotRequestCallback: Function; - public readonly _sceneComponents: SceneComponent[] = []; public _renderers: Renderer[] = []; - public readonly _postProcessors: PostProcessor[] = []; public _didSceneBegin; - /** - * 动态合批 - */ - public dynamicBatch: boolean = false; constructor() { - super(); this.entities = new EntityList(this); this.renderableComponents = new RenderableComponentList(); - this.content = new ContentManager(); this.entityProcessors = new EntityProcessorList(); @@ -97,11 +77,6 @@ module es { console.warn("场景开始时没有渲染器 自动添加DefaultRenderer以保证能够正常渲染"); } - let cameraEntity = this.findEntity("camera"); - if (!cameraEntity) - cameraEntity = this.createEntity("camera"); - this.camera = cameraEntity.getOrCreateComponent(new Camera()); - Physics.reset(); this.updateResolutionScaler(); @@ -111,9 +86,6 @@ module es { Core.emitter.addObserver(CoreEvents.GraphicsDeviceReset,this.updateResolutionScaler, this); Core.emitter.addObserver(CoreEvents.OrientationChanged, this.updateResolutionScaler, this); - this.addEventListener(egret.Event.ACTIVATE, this.onActive, this); - this.addEventListener(egret.Event.DEACTIVATE, this.onDeactive, this); - this._didSceneBegin = true; this.onStart(); @@ -125,19 +97,11 @@ module es { Core.emitter.removeObserver(CoreEvents.GraphicsDeviceReset, this.updateResolutionScaler); Core.emitter.removeObserver(CoreEvents.OrientationChanged, this.updateResolutionScaler); - this.removeEventListener(egret.Event.DEACTIVATE, this.onDeactive, this); - this.removeEventListener(egret.Event.ACTIVATE, this.onActive, this); - for (let i = 0; i < this._renderers.length; i++) { this._renderers[i].unload(); } - for (let i = 0; i < this._postProcessors.length; i++) { - this._postProcessors[i].unload(); - } - this.entities.removeAllEntities(); - this.removeChildren(); for (let i = 0; i < this._sceneComponents.length; i++) { this._sceneComponents[i].onRemovedFromScene(); @@ -145,19 +109,15 @@ module es { this._sceneComponents.length = 0; this.camera = null; - this.content.dispose(); if (this.entityProcessors) this.entityProcessors.end(); - if (this.parent) - this.parent.removeChild(this); - this.unload(); } public updateResolutionScaler(){ - this.camera.onSceneRenderTargetSizeChanged(Core.Instance.stage.stageWidth, Core.Instance.stage.stageHeight); + } public update() { @@ -190,70 +150,16 @@ module es { } for (let i = 0; i < this._renderers.length; i++) { - this.camera.forceMatrixUpdate(); this._renderers[i].render(this); } } - /** - * 动态合批 - */ - public dynamicInBatch(){ - this.removeChildren(); - let batching = false; - let displayContainer: egret.DisplayObjectContainer; - for (let component of this.renderableComponents.buffer){ - if (component instanceof SpriteAnimator){ - // 动态 - this.addChild(component.displayObject); - this.addChild(component.debugDisplayObject); - batching = false; - displayContainer = null; - } else if (component instanceof RenderableComponent) { - // 静态 - if (!batching){ - batching = true; - displayContainer = new egret.DisplayObjectContainer(); - displayContainer.cacheAsBitmap = true; - displayContainer.touchEnabled = false; - displayContainer.touchChildren = false; - this.addChild(displayContainer); - } - - displayContainer.addChild(component.displayObject); - displayContainer.addChild(component.debugDisplayObject); - } - } - } - /** * 现在的任何后处理器都要完成它的处理 * 只有在SceneTransition请求渲染时,它才会有一个值。 */ public postRender() { - if (this.enablePostProcessing) { - for (let i = 0; i < this._postProcessors.length; i++) { - if (this._postProcessors[i].enabled) { - this._postProcessors[i].process(); - } - } - } - // 如果我们有一个屏幕截图请求处理它之前,最后渲染到backbuffer - if (this._screenshotRequestCallback){ - let tex = new egret.RenderTexture(); - tex.drawToTexture(this, new Rectangle(0, 0, this.stage.stageWidth, this.stage.stageHeight)); - this._screenshotRequestCallback(tex); - this._screenshotRequestCallback = null; - } - } - - /** - * 在下一次绘制完成后,会进行场景全屏截图 - * @param callback - */ - public requestScreenshot(callback: Function){ - this._screenshotRequestCallback = callback; } /** @@ -345,47 +251,6 @@ module es { renderer.unload(); } - /** - * 添加一个后处理器到场景。设置场景字段并调用后处理器。onAddedToScene使后处理器可以使用场景ContentManager加载资源。 - * @param postProcessor - */ - public addPostProcessor(postProcessor: T): T { - this._postProcessors.push(postProcessor); - this._postProcessors.sort(); - postProcessor.onAddedToScene(this); - - if (this._didSceneBegin) { - postProcessor.onSceneBackBufferSizeChanged(this.stage.stageWidth, this.stage.stageHeight); - } - - return postProcessor; - } - - /** - * 获取类型为T的第一个后处理器 - * @param type - */ - public getPostProcessor(type): T { - for (let i = 0; i < this._postProcessors.length; i++) { - if (this._postProcessors[i] instanceof type) - return this._postProcessors[i] as T; - } - - return null; - } - - /** - * 删除一个后处理程序。注意,在删除时不会调用unload,因此如果不再需要PostProcessor,请确保调用unload来释放资源。 - * @param postProcessor - */ - public removePostProcessor(postProcessor: PostProcessor) { - if (!this._postProcessors.contains(postProcessor)) - return; - - this._postProcessors.remove(postProcessor); - postProcessor.unload(); - } - /** * 将实体添加到此场景,并返回它 * @param name diff --git a/source/src/ECS/Transform.ts b/source/src/ECS/Transform.ts index ea3c042d..f58007d4 100644 --- a/source/src/ECS/Transform.ts +++ b/source/src/ECS/Transform.ts @@ -7,8 +7,6 @@ module transform { } module es { - import HashObject = egret.HashObject; - export enum DirtyType { clean, positionDirty, @@ -16,7 +14,7 @@ module es { rotationDirty, } - export class Transform extends HashObject { + export class Transform { /** 与此转换关联的实体 */ public readonly entity: Entity; public hierarchyDirty: DirtyType; @@ -30,18 +28,17 @@ module es { /** * 值会根据位置、旋转和比例自动重新计算 */ - public _localTransform: Matrix2D = Matrix2D.create(); + public _localTransform: Matrix2D = Matrix2D.identity; /** * 值将自动从本地和父矩阵重新计算。 */ - public _worldTransform = Matrix2D.create().identity(); - public _rotationMatrix: Matrix2D = Matrix2D.create().identity(); - public _translationMatrix: Matrix2D = Matrix2D.create().identity(); - public _scaleMatrix: Matrix2D = Matrix2D.create().identity(); + public _worldTransform = Matrix2D.identity; + public _rotationMatrix: Matrix2D = Matrix2D.identity; + public _translationMatrix: Matrix2D = Matrix2D.identity; + public _scaleMatrix: Matrix2D = Matrix2D.identity; public _children: Transform[]; constructor(entity: Entity) { - super(); this.entity = entity; this.scale = this._localScale = Vector2.one; this._children = []; @@ -106,15 +103,15 @@ module es { this.setParent(value); } - public _worldToLocalTransform = Matrix2D.create().identity(); + public _worldToLocalTransform = Matrix2D.identity; public get worldToLocalTransform(): Matrix2D { if (this._worldToLocalDirty) { if (!this.parent) { - this._worldToLocalTransform = Matrix2D.create().identity(); + this._worldToLocalTransform = Matrix2D.identity; } else { this.parent.updateTransform(); - this._worldToLocalTransform = this.parent._worldTransform.invert(); + this._worldToLocalTransform = Matrix2D.invert(this.parent._worldTransform); } this._worldToLocalDirty = false; @@ -123,12 +120,12 @@ module es { return this._worldToLocalTransform; } - public _worldInverseTransform = Matrix2D.create().identity(); + public _worldInverseTransform = Matrix2D.identity; public get worldInverseTransform(): Matrix2D { this.updateTransform(); if (this._worldInverseDirty) { - this._worldInverseTransform = this._worldTransform.invert(); + this._worldInverseTransform = Matrix2D.invert(this._worldTransform); this._worldInverseDirty = false; } @@ -267,7 +264,7 @@ module es { * @param parent */ public setParent(parent: Transform): Transform { - if (this._parent.equals(parent)) + if (this._parent == parent) return this; if (!this._parent) { @@ -411,17 +408,17 @@ module es { if (this._localDirty) { if (this._localPositionDirty) { - this._translationMatrix = Matrix2D.create().translate(this._localPosition.x, this._localPosition.y); + this._translationMatrix = Matrix2D.createTranslation(this._localPosition.x, this._localPosition.y); this._localPositionDirty = false; } if (this._localRotationDirty) { - this._rotationMatrix = Matrix2D.create().rotate(this._localRotation); + this._rotationMatrix = Matrix2D.createRotation(this._localRotation); this._localRotationDirty = false; } if (this._localScaleDirty) { - this._scaleMatrix = Matrix2D.create().scale(this._localScale.x, this._localScale.y); + this._scaleMatrix = Matrix2D.createScale(this._localScale.x, this._localScale.y); this._localScaleDirty = false; } @@ -499,9 +496,5 @@ module es { scale: ${this.scale}, localPosition: ${this._localPosition}, localRotation: ${this._localRotation}, localScale: ${this._localScale}]`; } - - public equals(other: Transform) { - return other.hashCode == this.hashCode; - } } } \ No newline at end of file diff --git a/source/src/ECS/Utils/ComponentList.ts b/source/src/ECS/Utils/ComponentList.ts index 334737db..4bb007e9 100644 --- a/source/src/ECS/Utils/ComponentList.ts +++ b/source/src/ECS/Utils/ComponentList.ts @@ -11,6 +11,10 @@ module es { * 添加到实体的组件列表 */ public _components: FastList = new FastList(); + /** + * 所有需要更新的组件列表 + */ + public _updatableComponents: FastList = new FastList(); /** * 添加到此框架的组件列表。用来对组件进行分组,这样我们就可以同时进行加工 */ @@ -67,6 +71,7 @@ module es { } this._components.clear(); + this._updatableComponents.clear(); this._componentsToAdd.length = 0; this._componentsToRemove.length = 0; } @@ -76,15 +81,10 @@ module es { let component = this._components.buffer[i]; if (!component) continue; - // 处理渲染层列表 - if (component instanceof RenderableComponent) { - if (component.displayObject.parent) - component.displayObject.parent.removeChild(component.displayObject); - this._entity.scene.renderableComponents.remove(component); - } - if (component.debugDisplayObject.parent) - component.debugDisplayObject.parent.removeChild(component.debugDisplayObject); + // 处理IUpdatable + if (isIUpdatable(component)) + this._updatableComponents.remove(component); this._entity.componentBits.set(ComponentTypeManager.getIndexFor(component), false); this._entity.scene.entityProcessors.onComponentRemoved(this._entity); @@ -95,16 +95,12 @@ module es { for (let i = 0; i < this._components.length; i++) { let component = this._components.buffer[i]; - if (component instanceof RenderableComponent) { - if (!this._entity.scene.dynamicBatch) this._entity.scene.addChild(component.displayObject); - this._entity.scene.renderableComponents.add(component); - } + if (isIUpdatable(component)) + this._updatableComponents.add(component); - if (!this._entity.scene.dynamicBatch) this._entity.scene.addChild(component.debugDisplayObject); this._entity.componentBits.set(ComponentTypeManager.getIndexFor(component)); this._entity.scene.entityProcessors.onComponentAdded(this._entity); } - if (this._entity.scene.dynamicBatch) this._entity.scene.dynamicInBatch(); } /** @@ -123,19 +119,16 @@ module es { if (this._componentsToAdd.length > 0) { for (let i = 0, count = this._componentsToAdd.length; i < count; i++) { let component = this._componentsToAdd[i]; - if (component instanceof RenderableComponent) { - if (!this._entity.scene.dynamicBatch) this._entity.scene.addChild(component.displayObject); - this._entity.scene.renderableComponents.add(component); - } - if (!this._entity.scene.dynamicBatch) this._entity.scene.addChild(component.debugDisplayObject); + if (isIUpdatable(component)) + this._updatableComponents.add(component); + this._entity.componentBits.set(ComponentTypeManager.getIndexFor(component)); this._entity.scene.entityProcessors.onComponentAdded(this._entity); this._components.add(component); this._tempBufferList.push(component); } - if (this._entity.scene.dynamicBatch) this._entity.scene.dynamicInBatch(); // 在调用onAddedToEntity之前清除,以防添加更多组件 this._componentsToAdd.length = 0; @@ -156,22 +149,17 @@ module es { } if (this._isComponentListUnsorted) { - this._components.sort(ComponentList.compareUpdatableOrder); + this._updatableComponents.sort(ComponentList.compareUpdatableOrder); this._isComponentListUnsorted = false; } } public handleRemove(component: Component) { if (!component) return; - // 处理渲染层列表 - if (component instanceof RenderableComponent) { - if (component.displayObject.parent) - component.displayObject.parent.removeChild(component.displayObject); - this._entity.scene.renderableComponents.remove(component); - } - if (component.debugDisplayObject.parent) - component.debugDisplayObject.parent.removeChild(component.debugDisplayObject); + if (isIUpdatable(component)) + this._updatableComponents.remove(component); + this._entity.componentBits.set(ComponentTypeManager.getIndexFor(component), false); this._entity.scene.entityProcessors.onComponentRemoved(this._entity); @@ -211,33 +199,22 @@ module es { * @param typeName * @param components */ - public getComponents(typeName: string | any, components?) { + public getComponents(typeName: any, components?) { if (!components) components = []; for (let i = 0; i < this._components.length; i++) { let component = this._components.buffer[i]; - if (typeof (typeName) == "string") { - if (egret.is(component, typeName)) { - components.push(component); - } - } else { - if (component instanceof typeName) { - components.push(component); - } + if (component instanceof typeName) { + components.push(component); } } + // 我们还检查了待处理的组件,以防在同一帧中调用addComponent和getComponent for (let i = 0; i < this._componentsToAdd.length; i++) { let component = this._componentsToAdd[i]; - if (typeof (typeName) == "string") { - if (egret.is(component, typeName)) { - components.push(component); - } - } else { - if (component instanceof typeName) { - components.push(component); - } + if (component instanceof typeName) { + components.push(component); } } @@ -246,13 +223,9 @@ module es { public update() { this.updateLists(); - for (let i = 0; i < this._components.length; i++) { - let updatableComponent = this._components.buffer[i]; - - if (updatableComponent.enabled && - (updatableComponent.updateInterval == 1 || - Time.frameCount % updatableComponent.updateInterval == 0)) - updatableComponent.update(); + for (let i = 0; i < this._updatableComponents.length; i++) { + if (this._updatableComponents.buffer[i].enabled) + this._updatableComponents.buffer[i].update(); } } diff --git a/source/src/ECS/Utils/ObjectUtils.ts b/source/src/ECS/Utils/ObjectUtils.ts deleted file mode 100644 index cea2ebff..00000000 --- a/source/src/ECS/Utils/ObjectUtils.ts +++ /dev/null @@ -1,34 +0,0 @@ -class ObjectUtils { - /** - * 对象深度拷贝 - * @param p any 源对象 - * @param c any 目标对象, 不传则返回新对象, 传则合并属性, 相同名字的属性则会覆盖 - */ - public static clone(p: any, c: T = null): T { - var c = c || {}; - for (let i in p) { - if (typeof p[i] === 'object') { - c[i] = p[i] instanceof Array ? [] : {}; - this.clone(p[i], c[i]); - } else { - c[i] = p[i]; - } - } - return c; - } - - public static elements(p: {}){ - let c = []; - for (let i in p){ - if (Array.isArray(p[i])){ - for (let v of p[i]){ - c.push(v); - } - }else{ - c.push(p[i]); - } - } - - return c; - } -} \ No newline at end of file diff --git a/source/src/ECS/Utils/RenderableComponentList.ts b/source/src/ECS/Utils/RenderableComponentList.ts index abbfca07..eedc1ae9 100644 --- a/source/src/ECS/Utils/RenderableComponentList.ts +++ b/source/src/ECS/Utils/RenderableComponentList.ts @@ -20,7 +20,6 @@ module es { } public set componentsNeedSort(value: boolean) { this._componentsNeedSort = value; - Core.scene.sortableChildren = value; } public get count() { diff --git a/source/src/ECS/Utils/StringUtils.ts b/source/src/ECS/Utils/StringUtils.ts index 09d5fd2a..478f5937 100644 --- a/source/src/ECS/Utils/StringUtils.ts +++ b/source/src/ECS/Utils/StringUtils.ts @@ -82,7 +82,7 @@ class StringUtils { * @return 返回执行替换后的字符串 */ public static replaceMatch(mainStr: string, targetStr: string, - replaceStr: string, caseMark: boolean = false): string { + replaceStr: string, caseMark: boolean = false): string { let len: number = mainStr.length; let tempStr: string = ""; let isMatch: boolean = false; @@ -201,7 +201,7 @@ class StringUtils { * @return 截断后的字符串 */ public static cutOff(str: string, start: number, - len: number, order: boolean = true): string { + len: number, order: boolean = true): string { start = Math.floor(start); len = Math.floor(len); let length: number = str.length; diff --git a/source/src/ECS/Utils/TextureUtils.ts b/source/src/ECS/Utils/TextureUtils.ts deleted file mode 100644 index f1a6f4f4..00000000 --- a/source/src/ECS/Utils/TextureUtils.ts +++ /dev/null @@ -1,151 +0,0 @@ -module es { - /** - * 纹理帮助类 - */ - export class TextureUtils { - public static sharedCanvas: HTMLCanvasElement; - public static sharedContext: CanvasRenderingContext2D; - - public static convertImageToCanvas(texture: egret.Texture, rect?: egret.Rectangle): HTMLCanvasElement { - if (!this.sharedCanvas) { - this.sharedCanvas = egret.sys.createCanvas(); - this.sharedContext = this.sharedCanvas.getContext("2d"); - } - - let w = texture.$getTextureWidth(); - let h = texture.$getTextureHeight(); - if (!rect) { - rect = egret.$TempRectangle; - rect.x = 0; - rect.y = 0; - rect.width = w; - rect.height = h; - } - - rect.x = Math.min(rect.x, w - 1); - rect.y = Math.min(rect.y, h - 1); - rect.width = Math.min(rect.width, w - rect.x); - rect.height = Math.min(rect.height, h - rect.y); - - let iWidth = Math.floor(rect.width); - let iHeight = Math.floor(rect.height); - let surface = this.sharedCanvas; - surface["style"]["width"] = iWidth + "px"; - surface["style"]["height"] = iHeight + "px"; - this.sharedCanvas.width = iWidth; - this.sharedCanvas.height = iHeight; - - if (egret.Capabilities.renderMode == "webgl") { - let renderTexture: egret.RenderTexture; - //webgl下非RenderTexture纹理先画到RenderTexture - if (!(texture).$renderBuffer) { - if (egret.sys.systemRenderer["renderClear"]) { - egret.sys.systemRenderer["renderClear"](); - } - renderTexture = new egret.RenderTexture(); - renderTexture.drawToTexture(new egret.Bitmap(texture)); - } else { - renderTexture = texture; - } - //从RenderTexture中读取像素数据,填入canvas - let pixels = renderTexture.$renderBuffer.getPixels(rect.x, rect.y, iWidth, iHeight); - let x = 0; - let y = 0; - for (let i = 0; i < pixels.length; i += 4) { - this.sharedContext.fillStyle = - 'rgba(' + pixels[i] - + ',' + pixels[i + 1] - + ',' + pixels[i + 2] - + ',' + (pixels[i + 3] / 255) + ')'; - this.sharedContext.fillRect(x, y, 1, 1); - x++; - if (x == iWidth) { - x = 0; - y++; - } - } - - if (!(texture).$renderBuffer) { - renderTexture.dispose(); - } - - return surface; - } else { - let bitmapData = texture; - let offsetX: number = Math.round(bitmapData.$offsetX); - let offsetY: number = Math.round(bitmapData.$offsetY); - let bitmapWidth: number = bitmapData.$bitmapWidth; - let bitmapHeight: number = bitmapData.$bitmapHeight; - let $TextureScaleFactor = Core._instance.stage.textureScaleFactor; - this.sharedContext.drawImage(bitmapData.$bitmapData.source, bitmapData.$bitmapX + rect.x / $TextureScaleFactor, bitmapData.$bitmapY + rect.y / $TextureScaleFactor, - bitmapWidth * rect.width / w, bitmapHeight * rect.height / h, offsetX, offsetY, rect.width, rect.height); - return surface; - } - } - - public static toDataURL(type: string, texture: egret.Texture, rect?: egret.Rectangle, encoderOptions?): string { - try { - let surface = this.convertImageToCanvas(texture, rect); - let result = surface.toDataURL(type, encoderOptions); - return result; - } catch (e) { - egret.$error(1033); - } - return null; - } - - /** - * 有些杀毒软件认为 saveToFile 可能是一个病毒文件 - * @param type - * @param texture - * @param filePath - * @param rect - * @param encoderOptions - */ - public static eliFoTevas(type: string, texture: egret.Texture, filePath: string, rect?: egret.Rectangle, encoderOptions?): void { - let surface = this.convertImageToCanvas(texture, rect); - let result = (surface as any).toTempFilePathSync({ - fileType: type.indexOf("png") >= 0 ? "png" : "jpg" - }); - - wx.getFileSystemManager().saveFile({ - tempFilePath: result, - filePath: `${wx.env.USER_DATA_PATH}/${filePath}`, - success: function (res) { - //todo - } - }); - - return result; - } - - public static getPixel32(texture: egret.Texture, x: number, y: number): number[] { - egret.$warn(1041, "getPixel32", "getPixels"); - return texture.getPixels(x, y); - } - - public static getPixels(texture: egret.Texture, x: number, y: number, width: number = 1, height: number = 1): number[] { - //webgl环境下不需要转换成canvas获取像素信息 - if (egret.Capabilities.renderMode == "webgl") { - let renderTexture: egret.RenderTexture; - //webgl下非RenderTexture纹理先画到RenderTexture - if (!(texture).$renderBuffer) { - renderTexture = new egret.RenderTexture(); - renderTexture.drawToTexture(new egret.Bitmap(texture)); - } else { - renderTexture = texture; - } - //从RenderTexture中读取像素数据 - let pixels = renderTexture.$renderBuffer.getPixels(x, y, width, height); - return pixels; - } - try { - let surface = this.convertImageToCanvas(texture); - let result = this.sharedContext.getImageData(x, y, width, height).data; - return result; - } catch (e) { - egret.$error(1039); - } - } - } -} diff --git a/source/src/Extension.ts b/source/src/Extension.ts index 6d0141c1..68a25944 100644 --- a/source/src/Extension.ts +++ b/source/src/Extension.ts @@ -189,11 +189,6 @@ Array.prototype.findAll = function (predicate) { Array.prototype.contains = function (value) { function contains(array, value) { for (let i = 0, len = array.length; i < len; i++) { - if (array[i] instanceof egret.HashObject && value instanceof egret.HashObject){ - if ((array[i] as egret.HashObject).hashCode == (value as egret.HashObject).hashCode) - return true; - } - if (array[i] == value) { return true; } diff --git a/source/src/Graphics/Effects/GaussianBlurEffect.ts b/source/src/Graphics/Effects/GaussianBlurEffect.ts deleted file mode 100644 index 087c0ec9..00000000 --- a/source/src/Graphics/Effects/GaussianBlurEffect.ts +++ /dev/null @@ -1,74 +0,0 @@ -module es { - export class GaussianBlurEffect extends egret.CustomFilter { - // private static blur_frag = "precision mediump float;\n" + - // "uniform vec2 blur;\n" + - // "uniform sampler2D uSampler;\n" + - // "varying vec2 vTextureCoord;\n" + - // "uniform vec2 uTextureSize;\n" + - // "void main()\n" + - // "{\n " + - // "const int sampleRadius = 5;\n" + - // "const int samples = sampleRadius * 2 + 1;\n" + - // "vec2 blurUv = blur / uTextureSize;\n" + - // "vec4 color = vec4(0, 0, 0, 0);\n" + - // "vec2 uv = vec2(0.0, 0.0);\n" + - // "blurUv /= float(sampleRadius);\n" + - - // "for (int i = -sampleRadius; i <= sampleRadius; i++) {\n" + - // "uv.x = vTextureCoord.x + float(i) * blurUv.x;\n" + - // "uv.y = vTextureCoord.y + float(i) * blurUv.y;\n" + - // "color += texture2D(uSampler, uv);\n" + - // "}\n" + - - // "color /= float(samples);\n" + - // "gl_FragColor = color;\n" + - // "}"; - - private static blur_frag = "precision mediump float;\n" + - "uniform sampler2D uSampler;\n" + - "uniform float screenWidth;\n" + - "uniform float screenHeight;\n" + - - "float normpdf(in float x, in float sigma)\n" + - "{\n" + - "return 0.39894*exp(-0.5*x*x/(sigma*sigma))/sigma;\n" + - "}\n" + - - "void main()\n" + - "{\n" + - "vec3 c = texture2D(uSampler, gl_FragCoord.xy / vec2(screenWidth, screenHeight).xy).rgb;\n" + - - "const int mSize = 11;\n" + - "const int kSize = (mSize - 1)/2;\n" + - "float kernel[mSize];\n" + - "vec3 final_colour = vec3(0.0);\n" + - - "float sigma = 7.0;\n" + - "float z = 0.0;\n" + - "for (int j = 0; j <= kSize; ++j)\n" + - "{\n" + - "kernel[kSize+j] = kernel[kSize-j] = normpdf(float(j),sigma);\n" + - "}\n" + - - "for (int j = 0; j < mSize; ++j)\n" + - "{\n" + - "z += kernel[j];\n" + - "}\n" + - - "for (int i = -kSize; i <= kSize; ++i)\n" + - "{\n" + - "for (int j = -kSize; j <= kSize; ++j)\n" + - "{\n" + - "final_colour += kernel[kSize+j]*kernel[kSize+i]*texture2D(uSampler, (gl_FragCoord.xy+vec2(float(i),float(j))) / vec2(screenWidth, screenHeight).xy).rgb;\n" + - "}\n}\n" + - "gl_FragColor = vec4(final_colour/(z*z), 1.0);\n" + - "}"; - - constructor() { - super(PostProcessor.default_vert, GaussianBlurEffect.blur_frag, { - screenWidth: Core.graphicsDevice.viewport.width, - screenHeight: Core.graphicsDevice.viewport.height - }); - } - } -} diff --git a/source/src/Graphics/Effects/PolygonLightEffect.ts b/source/src/Graphics/Effects/PolygonLightEffect.ts deleted file mode 100644 index 0b5c7377..00000000 --- a/source/src/Graphics/Effects/PolygonLightEffect.ts +++ /dev/null @@ -1,36 +0,0 @@ -module es { - export class PolygonLightEffect extends egret.CustomFilter { - private static vertSrc = "attribute vec2 aVertexPosition;\n" + - "attribute vec2 aTextureCoord;\n" + - - "uniform vec2 projectionVector;\n" + - - "varying vec2 vTextureCoord;\n" + - - "const vec2 center = vec2(-1.0, 1.0);\n" + - - "void main(void) {\n" + - " gl_Position = vec4( (aVertexPosition / projectionVector) + center , 0.0, 1.0);\n" + - " vTextureCoord = aTextureCoord;\n" + - "}"; - private static fragmentSrc = "precision lowp float;\n" + - "varying vec2 vTextureCoord;\n" + - "uniform sampler2D uSampler;\n" + - - "#define SAMPLE_COUNT 15\n" + - - "uniform vec2 _sampleOffsets[SAMPLE_COUNT];\n" + - "uniform float _sampleWeights[SAMPLE_COUNT];\n" + - - "void main(void) {\n" + - "vec4 c = vec4(0, 0, 0, 0);\n" + - "for( int i = 0; i < SAMPLE_COUNT; i++ )\n" + - " c += texture2D( uSampler, vTextureCoord + _sampleOffsets[i] ) * _sampleWeights[i];\n" + - "gl_FragColor = c;\n" + - "}"; - - constructor() { - super(PolygonLightEffect.vertSrc, PolygonLightEffect.fragmentSrc); - } - } -} diff --git a/source/src/Graphics/Graphics.ts b/source/src/Graphics/Graphics.ts deleted file mode 100644 index e0466d21..00000000 --- a/source/src/Graphics/Graphics.ts +++ /dev/null @@ -1,20 +0,0 @@ -module es { - export class Graphics { - public static Instance: Graphics; - /** - * 用于绘制矩形、线条、圆等的精灵。 - * 将在启动时生成,但你可以用你的图集中的精灵代替,以减少纹理交换。应该是一个1x1的白色像素 - */ - public pixelTexture: Sprite; - - constructor(){ - let arrayBuffer = new ArrayBuffer(1); - arrayBuffer[0] = 0xffffff; - egret.BitmapData.create("arraybuffer", arrayBuffer, bitmapData => { - let tex = new egret.Texture(); - tex.bitmapData = bitmapData; - this.pixelTexture = new Sprite(tex); - }); - } - } -} \ No newline at end of file diff --git a/source/src/Graphics/GraphicsCapabilities.ts b/source/src/Graphics/GraphicsCapabilities.ts deleted file mode 100644 index 8e1fba29..00000000 --- a/source/src/Graphics/GraphicsCapabilities.ts +++ /dev/null @@ -1,31 +0,0 @@ -module es { - export class GraphicsCapabilities extends egret.Capabilities { - - public initialize(device: GraphicsDevice) { - this.platformInitialize(device); - } - - private platformInitialize(device: GraphicsDevice) { - if (GraphicsCapabilities.runtimeType != egret.RuntimeType.WXGAME) - return; - let capabilities = this; - capabilities["isMobile"] = true; - - let systemInfo = wx.getSystemInfoSync(); - let systemStr = systemInfo.system.toLowerCase(); - if (systemStr.indexOf("ios") > -1) { - capabilities["os"] = "iOS"; - } else if (systemStr.indexOf("android") > -1) { - capabilities["os"] = "Android"; - } - - let language = systemInfo.language; - if (language.indexOf('zh') > -1) { - language = "zh-CN"; - } else { - language = "en-US"; - } - capabilities["language"] = language; - } - } -} diff --git a/source/src/Graphics/GraphicsDevice.ts b/source/src/Graphics/GraphicsDevice.ts deleted file mode 100644 index 9892b045..00000000 --- a/source/src/Graphics/GraphicsDevice.ts +++ /dev/null @@ -1,21 +0,0 @@ -module es { - export class GraphicsDevice { - public graphicsCapabilities: GraphicsCapabilities; - - constructor() { - this.setup(); - this.graphicsCapabilities = new GraphicsCapabilities(); - this.graphicsCapabilities.initialize(this); - } - - private _viewport: Viewport; - - public get viewport(): Viewport { - return this._viewport; - } - - private setup() { - this._viewport = new Viewport(0, 0, Core._instance.stage.stageWidth, Core._instance.stage.stageHeight); - } - } -} diff --git a/source/src/Graphics/PostProcessing/PostProcessor.ts b/source/src/Graphics/PostProcessing/PostProcessor.ts deleted file mode 100644 index 51f6f3c2..00000000 --- a/source/src/Graphics/PostProcessing/PostProcessor.ts +++ /dev/null @@ -1,60 +0,0 @@ -module es { - export class PostProcessor { - public static default_vert = "attribute vec2 aVertexPosition;\n" + - "attribute vec2 aTextureCoord;\n" + - "attribute vec2 aColor;\n" + - - "uniform vec2 projectionVector;\n" + - //"uniform vec2 offsetVector;\n" + - - "varying vec2 vTextureCoord;\n" + - "varying vec4 vColor;\n" + - - "const vec2 center = vec2(-1.0, 1.0);\n" + - - "void main(void) {\n" + - "gl_Position = vec4( (aVertexPosition / projectionVector) + center , 0.0, 1.0);\n" + - "vTextureCoord = aTextureCoord;\n" + - "vColor = vec4(aColor.x, aColor.x, aColor.x, aColor.x);\n" + - "}"; - public enabled: boolean; - public effect: egret.Filter; - public scene: Scene; - public shape: egret.Shape; - - constructor(effect: egret.Filter = null) { - this.enabled = true; - this.effect = effect; - } - - public onAddedToScene(scene: Scene) { - this.scene = scene; - this.shape = new egret.Shape(); - this.shape.graphics.beginFill(0xFFFFFF, 1); - this.shape.graphics.drawRect(0, 0, Core.graphicsDevice.viewport.width, Core.graphicsDevice.viewport.height); - this.shape.graphics.endFill(); - scene.addChild(this.shape); - } - - public process() { - this.drawFullscreenQuad(); - } - - public onSceneBackBufferSizeChanged(newWidth: number, newHeight: number) { - } - - public unload() { - if (this.effect) { - this.effect = null; - } - - this.scene.removeChild(this.shape); - this.scene = null; - } - - protected drawFullscreenQuad() { - this.scene.filters = [this.effect]; - // this.shape.filters = [this.effect]; - } - } -} diff --git a/source/src/Graphics/PostProcessing/PostProcessors/GaussianBlurPostProcessor.ts b/source/src/Graphics/PostProcessing/PostProcessors/GaussianBlurPostProcessor.ts deleted file mode 100644 index 04316920..00000000 --- a/source/src/Graphics/PostProcessing/PostProcessors/GaussianBlurPostProcessor.ts +++ /dev/null @@ -1,8 +0,0 @@ -module es { - export class GaussianBlurPostProcessor extends PostProcessor { - public onAddedToScene(scene: Scene) { - super.onAddedToScene(scene); - this.effect = new GaussianBlurEffect(); - } - } -} diff --git a/source/src/Graphics/Renderers/PolygonLight/PolyLight.ts b/source/src/Graphics/Renderers/PolygonLight/PolyLight.ts deleted file mode 100644 index 37a2ffa9..00000000 --- a/source/src/Graphics/Renderers/PolygonLight/PolyLight.ts +++ /dev/null @@ -1,50 +0,0 @@ -module es { - export class PolyLight extends RenderableComponent { - public power: number; - private _lightEffect; - private _indices: number[] = []; - - constructor(radius: number, color: number, power: number) { - super(); - - this.radius = radius; - this.power = power; - this.color = color; - this.computeTriangleIndices(); - } - - protected _radius: number; - - public get radius() { - return this._radius; - } - - public set radius(value: number) { - this.setRadius(value); - } - - public setRadius(radius: number) { - if (radius != this._radius) { - this._radius = radius; - this._areBoundsDirty = true; - } - } - - public render(camera: Camera) { - } - - public reset() { - - } - - private computeTriangleIndices(totalTris: number = 20) { - this._indices.length = 0; - - for (let i = 0; i < totalTris; i += 2) { - this._indices.push(0); - this._indices.push(i + 2); - this._indices.push(i + 1); - } - } - } -} diff --git a/source/src/Graphics/Renderers/RenderLayerExcludeRenderer.ts b/source/src/Graphics/Renderers/RenderLayerExcludeRenderer.ts deleted file mode 100644 index 60621363..00000000 --- a/source/src/Graphics/Renderers/RenderLayerExcludeRenderer.ts +++ /dev/null @@ -1,40 +0,0 @@ -module es { - /** - * 除了一个渲染层,只渲染所有的渲染器。 - * 当与RenderLayerRenderer一起使用时,将UI渲染与游戏的其他部分分离开来。 - */ - export class RenderLayerExcludeRenderer extends Renderer { - public excludedRenderLayers: number[]; - - constructor(renderOrder: number, ...excludedRenderLayers: number[]){ - super(renderOrder, null); - this.excludedRenderLayers = excludedRenderLayers; - } - - public render(scene: es.Scene) { - let cam = this.camera ? this.camera : scene.camera; - this.beginRender(cam); - - for (let i = 0; i < scene.renderableComponents.count; i ++) { - let renderable = scene.renderableComponents.buffer[i]; - if (!this.excludedRenderLayers.contains(renderable.renderLayer) && renderable.enabled && - renderable.isVisibleFromCamera(cam)) - this.renderAfterStateCheck(renderable, cam); - } - - if (this.shouldDebugRender && Core.debugRenderEndabled) - this.debugRender(scene, cam); - } - - protected debugRender(scene: es.Scene, cam: es.Camera) { - for (let i = 0; i < scene.renderableComponents.count; i ++){ - let renderable = scene.renderableComponents.buffer[i]; - if (!this.excludedRenderLayers.contains(renderable.renderLayer) && renderable.enabled && - renderable.isVisibleFromCamera(cam)) - renderable.debugRender(cam); - } - - super.debugRender(scene, cam); - } - } -} \ No newline at end of file diff --git a/source/src/Graphics/Renderers/Renderer.ts b/source/src/Graphics/Renderers/Renderer.ts index e0e06c1b..3b29536f 100644 --- a/source/src/Graphics/Renderers/Renderer.ts +++ b/source/src/Graphics/Renderers/Renderer.ts @@ -13,23 +13,12 @@ module es { * 指定场景调用渲染器的顺序 */ public readonly renderOrder: number = 0; - /** - * 如果renderTarget不是null,这个渲染器将渲染到渲染目标而不是屏幕 - */ - public renderTexture: egret.RenderTexture; /** * 这个渲染器的标志,决定它是否应该调试渲染。 * render方法接收一个bool (debugRenderEnabled),让渲染器知道全局调试渲染是否打开/关闭。 * 渲染器然后使用本地bool来决定它是否应该调试渲染。 */ public shouldDebugRender: boolean = true; - /** - * 如果为true,场景将使用场景渲染目标调用setRenderTarget。 - * 如果渲染器有渲染纹理,默认实现返回true - */ - public get wantsToRenderToSceneRenderTarget(): boolean{ - return !!this.renderTexture; - } protected constructor(renderOrder: number, camera: Camera = null) { this.camera = camera; diff --git a/source/src/Graphics/Renderers/ScreenSpaceRenderer.ts b/source/src/Graphics/Renderers/ScreenSpaceRenderer.ts deleted file mode 100644 index 147f4843..00000000 --- a/source/src/Graphics/Renderers/ScreenSpaceRenderer.ts +++ /dev/null @@ -1,49 +0,0 @@ -module es { - /** - * 渲染器使用自己的不移动的摄像机进行渲染。 - */ - export class ScreenSpaceRenderer extends Renderer { - public renderLayers: number[]; - - constructor(renderOrder: number, ...renderLayers: number[]){ - super(renderOrder, null); - renderLayers.sort(); - renderLayers.reverse(); - this.renderLayers = renderLayers; - } - - public render(scene: Scene) { - this.beginRender(this.camera); - - for (let i = 0; i < this.renderLayers.length; i ++){ - let renderables = scene.renderableComponents.componentsWithRenderLayer(this.renderLayers[i]); - for (let j = 0; j < renderables.length; j ++){ - let renderable = renderables[j]; - if (renderable.enabled && renderable.isVisibleFromCamera(this.camera)) - this.renderAfterStateCheck(renderable, this.camera); - } - } - - if (this.shouldDebugRender && Core.debugRenderEndabled) - this.debugRender(scene, this.camera); - } - - protected debugRender(scene: es.Scene, cam: es.Camera) { - for (let i = 0; i < this.renderLayers.length; i ++){ - let renderables = scene.renderableComponents.componentsWithRenderLayer(this.renderLayers[i]); - for (let j = 0; j < renderables.length; j ++){ - let entity = renderables[j]; - if (entity.enabled) - entity.debugRender(cam); - } - } - } - - public onSceneBackBufferSizeChanged(newWidth: number, newHeight: number) { - super.onSceneBackBufferSizeChanged(newWidth, newHeight); - - if (!this.camera) - this.camera = Core.scene.createEntity("screenspace camera").addComponent(new Camera()); - } - } -} diff --git a/source/src/Graphics/Textures/GaussianBlur.ts b/source/src/Graphics/Textures/GaussianBlur.ts deleted file mode 100644 index d345ac1d..00000000 --- a/source/src/Graphics/Textures/GaussianBlur.ts +++ /dev/null @@ -1,147 +0,0 @@ -module es { - export class GaussianBlur { - /** - * 创建一个新的纹理,它是原始纹理的高斯模糊版本 - * @param image - * @param deviation 偏差 - * @returns 模糊的纹理 - */ - public static createBlurredTexture(image: egret.Texture, deviation: number = 1) { - let pixelData = image.getPixels(0, 0, image.textureWidth, image.textureHeight); - let srcData: Color[] = new Array(image.textureWidth * image.textureHeight); - for (let i = 0; i < image.textureWidth; i++) { - for (let j = 0; j < image.textureHeight; j++) { - let width = image.textureWidth; - let r = pixelData[i * 4 + j * width]; - let g = pixelData[i * 4 + j * width + 1]; - let b = pixelData[i * 4 + j * width + 2]; - let a = pixelData[i * 4 + j * width + 3]; - srcData[i + j * width] = new Color(r, g, b, a); - } - } - - // TODO: 计算方式有问题 后面再研究研究 - let destData = this.createBlurredTextureData(srcData, image.textureWidth, image.textureHeight, deviation); - let arrayBuffer = new ArrayBuffer(destData.length); - destData.forEach((value, index) => { - arrayBuffer[index] = value.packedValue; - }); - egret.BitmapData.create("arraybuffer", arrayBuffer, (bitmapData) => { - // TODO: 生成bitmapdata - }); - } - - public static createBlurredTextureData(srcData: Color[], width: number, height: number, deviation: number = 1) { - let matrixR = new FasterDictionary<{ x: number, y: number }, number>(); - let matrixG = new FasterDictionary<{ x: number, y: number }, number>(); - let matrixB = new FasterDictionary<{ x: number, y: number }, number>(); - let matrixA = new FasterDictionary<{ x: number, y: number }, number>(); - - let destData: Color[] = new Array(width * height); - - // 首先,我们计算出灰度,并将其存储在矩阵中 - for (let i = 0; i < width; i++) { - for (let j = 0; j < height; j++) { - matrixR.add({ x: i, y: j }, srcData[i + j * width].r); - matrixG.add({ x: i, y: j }, srcData[i + j * width].g); - matrixB.add({ x: i, y: j }, srcData[i + j * width].b); - matrixA.add({ x: i, y: j }, srcData[i + j * width].a); - } - } - - matrixR = this.gaussianConvolution(matrixR, deviation); - matrixG = this.gaussianConvolution(matrixG, deviation); - matrixB = this.gaussianConvolution(matrixB, deviation); - matrixA = this.gaussianConvolution(matrixA, deviation); - - for (let i = 0; i < width; i++) { - for (let j = 0; j < height; j++) { - let r = Math.min(255, matrixR.tryGetValue({x: i, y: j})); - let g = Math.min(255, matrixG.tryGetValue({x: i, y: j})); - let b = Math.min(255, matrixB.tryGetValue({x: i, y: j})); - let a = Math.min(255, matrixA.tryGetValue({x: i, y: j})); - destData[i + j * width] = new Color(r, g, b, a); - } - } - - return destData; - } - - public static gaussianConvolution(matrix: FasterDictionary<{ x: number, y: number }, number>, deviation: number) { - let kernel = this.calculateNormalized1DSampleKernel(deviation); - let res1 = new FasterDictionary<{ x: number, y: number }, number>(); - let res2 = new FasterDictionary<{ x: number, y: number }, number>(); - - for (let i = 0; i < matrix._valuesInfo.length; i++) { - for (let j = 0; j < matrix.valuesArray.length; j++) - res1.add({ x: i, y: j }, this.processPoint(matrix, i, j, kernel, 0)); - } - - for (let i = 0; i < matrix._valuesInfo.length; i++) { - for (let j = 0; j < matrix.valuesArray.length; j++) - res2.add({ x: i, y: j }, this.processPoint(res1, i, j, kernel, 1)); - } - - return res2; - } - - public static processPoint(matrix: FasterDictionary<{ x: number, y: number }, number>, - x: number, - y: number, - kernel: FasterDictionary<{ x: number, y: number }, number>, - direction: number) { - let res = 0; - let half = kernel._valuesInfo.length / 2; - for (let i = 0; i < kernel._valuesInfo.length; i++) { - let cox = direction == 0 ? x + i - half : x; - let coy = direction == 1 ? y + i - half : y; - if (cox >= 0 && cox < matrix._valuesInfo.length && coy >= 0 && coy < matrix.valuesArray.length) - res += matrix.tryGetValue({ x: cox, y: coy }) * kernel.tryGetValue({x: i, y: 0}); - } - - return res; - } - - public static calculate1DSampleKernel(deviation: number) { - let size = Math.ceil(deviation * 3) * 3 + 1; - return this.calculate1DSampleKernelOfSize(deviation, size); - } - - public static calculate1DSampleKernelOfSize(deviation: number, size: number) { - let ret = new FasterDictionary<{ x: number, y: number }, number>(); - // let sum = 0; - - let half = (size - 1) / 2; - for (let i = 0; i < size; i++) { - ret.add({x: i, y: 0}, 1 / (Math.sqrt(2 * Math.PI) * deviation) * Math.exp(-(i - half) * (i - half) / (2 * deviation * deviation))); - // sum += ret.tryGetValue({x: i, y: 0}); - } - - return ret; - } - - public static calculateNormalized1DSampleKernel(deviation: number) { - return this.normalizeMatrix(this.calculate1DSampleKernel(deviation)); - } - - public static normalizeMatrix(matrix: FasterDictionary<{ x: number, y: number }, number>) { - let ret = new FasterDictionary<{ x: number, y: number }, number>(); - let sum = 0; - for (let i = 0; i < ret._valuesInfo.length; i++) { - for (let j = 0; j < ret.valuesArray.length; j++) { - sum += matrix.tryGetValue({x: i, y: j}); - } - } - - if (sum != 0) { - for (let i = 0; i < ret._valuesInfo.length; i++) { - for (let j = 0; j < ret.valuesArray.length; j++) { - ret.add({x: i, y: j}, matrix.tryGetValue({x: i, y: j}) / sum); - } - } - } - - return ret; - } - } -} \ No newline at end of file diff --git a/source/src/Graphics/Transitions/FadeTransition.ts b/source/src/Graphics/Transitions/FadeTransition.ts deleted file mode 100644 index 5028ebf5..00000000 --- a/source/src/Graphics/Transitions/FadeTransition.ts +++ /dev/null @@ -1,48 +0,0 @@ -/// -module es { - export class FadeTransition extends SceneTransition { - public fadeToColor: number = 0x000000; - public fadeOutDuration = 0.4; - public fadeEaseType: Function = egret.Ease.quadInOut; - public delayBeforeFadeInDuration = 0.1; - private _mask: egret.Shape; - private _alpha: number = 0; - - constructor(sceneLoadAction: Function) { - super(sceneLoadAction); - this._mask = new egret.Shape(); - } - - public async onBeginTransition() { - if (!this._mask.parent) - Core.scene.stage.addChild(this._mask); - - this._mask.graphics.beginFill(this.fadeToColor, 1); - this._mask.graphics.drawRect(0, 0, Core.graphicsDevice.viewport.width, Core.graphicsDevice.viewport.height); - this._mask.graphics.endFill(); - - egret.Tween.get(this).to({_alpha: 1}, this.fadeOutDuration * 1000, this.fadeEaseType) - .call(async () => { - await this.loadNextScene(); - }).wait(this.delayBeforeFadeInDuration).call(() => { - egret.Tween.get(this).to({_alpha: 0}, this.fadeOutDuration * 1000, this.fadeEaseType).call(() => { - this.transitionComplete(); - }); - }); - } - - protected transitionComplete(){ - super.transitionComplete(); - - if (this._mask.parent) - this._mask.parent.removeChild(this._mask); - } - - public render() { - this._mask.graphics.clear(); - this._mask.graphics.beginFill(this.fadeToColor, this._alpha); - this._mask.graphics.drawRect(0, 0, Core.graphicsDevice.viewport.width, Core.graphicsDevice.viewport.height); - this._mask.graphics.endFill(); - } - } -} diff --git a/source/src/Graphics/Transitions/SceneTransition.ts b/source/src/Graphics/Transitions/SceneTransition.ts index 6a23c0a1..c0905fb9 100644 --- a/source/src/Graphics/Transitions/SceneTransition.ts +++ b/source/src/Graphics/Transitions/SceneTransition.ts @@ -45,17 +45,6 @@ module es { this.transitionComplete(); } - public tickEffectProgressProperty(filter: egret.CustomFilter, duration: number, easeType: Function, reverseDirection = false): Promise { - return new Promise((resolve) => { - let start = reverseDirection ? 1 : 0; - let end = reverseDirection ? 0 : 1; - - egret.Tween.get(filter.uniforms).set({_progress: start}).to({_progress: end}, duration * 1000, easeType).call(() => { - resolve(); - }); - }); - } - protected transitionComplete() { Core._instance._sceneTransition = null; diff --git a/source/src/Graphics/Transitions/WindTransition.ts b/source/src/Graphics/Transitions/WindTransition.ts deleted file mode 100644 index 18e429f2..00000000 --- a/source/src/Graphics/Transitions/WindTransition.ts +++ /dev/null @@ -1,75 +0,0 @@ -module es { - export class WindTransition extends SceneTransition { - public duration = 1; - public easeType = egret.Ease.quadOut; - private _mask: egret.Shape; - private _windEffect: egret.CustomFilter; - - constructor(sceneLoadAction: Function) { - super(sceneLoadAction); - - let vertexSrc = "attribute vec2 aVertexPosition;\n" + - "attribute vec2 aTextureCoord;\n" + - - "uniform vec2 projectionVector;\n" + - - "varying vec2 vTextureCoord;\n" + - - "const vec2 center = vec2(-1.0, 1.0);\n" + - - "void main(void) {\n" + - " gl_Position = vec4( (aVertexPosition / projectionVector) + center , 0.0, 1.0);\n" + - " vTextureCoord = aTextureCoord;\n" + - "}"; - let fragmentSrc = "precision lowp float;\n" + - "varying vec2 vTextureCoord;\n" + - "uniform sampler2D uSampler;\n" + - "uniform float _progress;\n" + - "uniform float _size;\n" + - "uniform float _windSegments;\n" + - - "void main(void) {\n" + - "vec2 co = floor(vec2(0.0, vTextureCoord.y * _windSegments));\n" + - "float x = sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453;\n" + - "float r = x - floor(x);\n" + - "float m = smoothstep(0.0, -_size, vTextureCoord.x * (1.0 - _size) + _size * r - (_progress * (1.0 + _size)));\n" + - "vec4 fg = texture2D(uSampler, vTextureCoord);\n" + - "gl_FragColor = mix(fg, vec4(0, 0, 0, 0), m);\n" + - "}"; - - this._windEffect = new egret.CustomFilter(vertexSrc, fragmentSrc, { - _progress: 0, - _size: 0.3, - _windSegments: 100 - }); - - this._mask = new egret.Shape(); - this._mask.graphics.beginFill(0xFFFFFF, 1); - this._mask.graphics.drawRect(0, 0, Core.graphicsDevice.viewport.width, Core.graphicsDevice.viewport.height); - this._mask.graphics.endFill(); - this._mask.filters = [this._windEffect]; - Core.scene.stage.addChild(this._mask); - } - - public set windSegments(value: number) { - this._windEffect.uniforms._windSegments = value; - } - - public set size(value: number) { - this._windEffect.uniforms._size = value; - } - - public async onBeginTransition() { - this.loadNextScene(); - await this.tickEffectProgressProperty(this._windEffect, this.duration, this.easeType); - this.transitionComplete(); - } - - protected transitionComplete() { - super.transitionComplete(); - - if (this._mask.parent) - this._mask.parent.removeChild(this._mask); - } - } -} diff --git a/source/src/Math/Matrix2D.ts b/source/src/Math/Matrix2D.ts index 7a2b6d9d..25054f7e 100644 --- a/source/src/Math/Matrix2D.ts +++ b/source/src/Math/Matrix2D.ts @@ -1,119 +1,168 @@ module es { - export var matrixPool = []; - /** * 表示右手3 * 3的浮点矩阵,可以存储平移、缩放和旋转信息。 */ - export class Matrix2D extends egret.Matrix { - public get m11(): number { - return this.a; - } + export class Matrix2D implements IEquatable { + public m11: number = 0; // x 缩放 + public m12: number = 0; - public set m11(value: number) { - this.a = value; - } + public m21: number = 0; + public m22: number = 0; - public get m12(): number { - return this.b; - } + public m31: number = 0; + public m32: number = 0; - public set m12(value: number) { - this.b = value; - } - - public get m21(): number { - return this.c; - } - - public set m21(value: number) { - this.c = value; - } - - public get m22(): number { - return this.d; - } - - public set m22(value: number) { - this.d = value; - } - - public get m31(): number { - return this.tx; - } - - public set m31(value: number) { - this.tx = value; - } - - public get m32(): number { - return this.ty; - } - - public set m32(value: number) { - this.ty = value; + /** + * 返回标识矩阵 + */ + public static get identity(): Matrix2D { + return this._identity; } /** - * 从对象池中取出或创建一个新的Matrix对象。 + * 储存在该矩阵中的位置 */ - public static create(): Matrix2D { - let matrix = matrixPool.pop(); - if (!matrix) - matrix = new Matrix2D(); - return matrix; + public get translation(): Vector2 { + return new Vector2(this.m31, this.m32); } - public identity(): Matrix2D { - this.a = this.d = 1; - this.b = this.c = this.tx = this.ty = 0; - return this; + public set translation(value: Vector2) { + this.m31 = value.x; + this.m32 = value.y; } - public translate(dx: number, dy: number): Matrix2D { - this.tx += dx; - this.ty += dy; - return this; + /** + * 以弧度为单位的旋转,存储在这个矩阵中 + */ + public get rotation(): number { + return Math.atan2(this.m21, this.m11); } - public scale(sx: number, sy: number): Matrix2D { - if (sx !== 1) { - this.a *= sx; - this.c *= sx; - this.tx *= sx; - } - if (sy !== 1) { - this.b *= sy; - this.d *= sy; - this.ty *= sy; - } - return this; + public set rotation(value: number){ + let val1 = Math.cos(value); + let val2 = Math.sin(value); + + this.m11 = val1; + this.m12 = val2; + this.m21 = -val2; + this.m22 = val1; } - public rotate(angle: number): Matrix2D { - angle = +angle; - if (angle !== 0) { - angle = angle / DEG_TO_RAD; - let u = Math.cos(angle); - let v = Math.sin(angle); - let ta = this.a; - let tb = this.b; - let tc = this.c; - let td = this.d; - let ttx = this.tx; - let tty = this.ty; - this.a = ta * u - tb * v; - this.b = ta * v + tb * u; - this.c = tc * u - td * v; - this.d = tc * v + td * u; - this.tx = ttx * u - tty * v; - this.ty = ttx * v + tty * u; - } - return this; + /** + * 矩阵中存储的旋转度数 + */ + public get rotationDegrees() { + return MathHelper.toDegrees(this.rotation); } - public invert(): Matrix2D { - this.$invertInto(this); - return this; + public set rotationDegrees(value: number) { + this.rotation = MathHelper.toRadians(value); + } + + /** + * 储存在这个矩阵中的缩放 + */ + public get scale(): Vector2 { + return new Vector2(this.m11, this.m22); + } + + public set scale(value: Vector2) { + this.m11 = value.x; + this.m22 = value.y; + } + + static _identity: Matrix2D = new Matrix2D(1, 0, 0, 1, 0, 0); + + /** + * 构建一个矩阵 + * @param m11 + * @param m12 + * @param m21 + * @param m22 + * @param m31 + * @param m32 + */ + constructor(m11: number, m12: number, m21: number, m22: number, m31: number, m32: number){ + this.m11 = m11; + this.m12 = m12; + + this.m21 = m21; + this.m22 = m22; + + this.m31 = m31; + this.m32 = m32; + } + + /** + * 创建一个新的围绕Z轴的旋转矩阵2D + * @param radians + */ + public static createRotation(radians: number){ + let result: Matrix2D = this.identity; + + let val1 = Math.cos(radians); + let val2 = Math.sin(radians); + + result.m11 = val1; + result.m12 = val2; + result.m21 = -val2; + result.m22 = val1; + + return result; + } + + /** + * 创建一个新的缩放矩阵2D + * @param xScale + * @param yScale + */ + public static createScale(xScale: number, yScale: number){ + let result: Matrix2D = this.identity; + result.m11 = xScale; + result.m12 = 0; + + result.m21 = 0; + result.m22 = yScale; + + result.m31 = 0; + result.m32 = 0; + + return result; + } + + /** + * 创建一个新的平移矩阵2D + * @param xPosition + * @param yPosition + */ + public static createTranslation(xPosition: number, yPosition: number) { + let result: Matrix2D = this.identity; + result.m11 = 1; + result.m12 = 0; + + result.m21 = 0; + result.m22 = 1; + + result.m31 = xPosition; + result.m32 = yPosition; + + return result; + } + + public static invert(matrix: Matrix2D) { + let det = 1 / matrix.determinant(); + + let result = this.identity; + result.m11 = matrix.m22 * det; + result.m12 = -matrix.m12 * det; + + result.m21 = -matrix.m21 * det; + result.m22 = matrix.m11 * det; + + result.m31 = (matrix.m32 * matrix.m21 - matrix.m31 * matrix.m22) * det; + result.m32 = -(matrix.m32 * matrix.m11 - matrix.m31 * matrix.m12) * det; + + return result; } /** @@ -185,10 +234,56 @@ module es { return this.m11 * this.m22 - this.m12 * this.m21; } - public release(matrix: Matrix2D) { - if (!matrix) - return; - matrixPool.push(matrix); + /** + * 创建一个新的Matrix2D,包含指定矩阵中的线性插值。 + * @param matrix1 + * @param matrix2 + * @param amount + */ + public static lerp(matrix1: Matrix2D, matrix2: Matrix2D, amount: number){ + matrix1.m11 = matrix1.m11 + ((matrix2.m11 - matrix1.m11) * amount); + matrix1.m12 = matrix1.m12 + ((matrix2.m12 - matrix1.m12) * amount); + + matrix1.m21 = matrix1.m21 + ((matrix2.m21 - matrix1.m21) * amount); + matrix1.m22 = matrix1.m22 + ((matrix2.m22 - matrix1.m22) * amount); + + matrix1.m31 = matrix1.m31 + ((matrix2.m31 - matrix1.m31) * amount); + matrix1.m32 = matrix1.m32 + ((matrix2.m32 - matrix1.m32) * amount); + return matrix1; + } + + /** + * 交换矩阵的行和列 + * @param matrix + */ + public static transpose(matrix: Matrix2D) { + let ret: Matrix2D = this.identity; + ret.m11 = matrix.m11; + ret.m12 = matrix.m21; + + ret.m21 = matrix.m12; + ret.m22 = matrix.m22; + + ret.m31 = 0; + ret.m32 = 0; + return ret; + } + + public mutiplyTranslation(x: number, y: number){ + let trans = Matrix2D.createTranslation(x, y); + return MatrixHelper.mutiply(this, trans); + } + + /** + * 比较当前实例是否等于指定的Matrix2D + * @param other + */ + public equals(other: Matrix2D){ + return this == other; + } + + public toString() { + return `{m11:${this.m11} m12:${this.m12} m21:${this.m21} m22:${this.m22} m31:${this.m31} m32:${this.m32}}` } } } diff --git a/source/src/Math/MatrixHelper.ts b/source/src/Math/MatrixHelper.ts new file mode 100644 index 00000000..5601a80c --- /dev/null +++ b/source/src/Math/MatrixHelper.ts @@ -0,0 +1,99 @@ +module es { + export class MatrixHelper { + /** + * 创建一个新的Matrix2D,其中包含两个矩阵的和 + * @param matrix1 + * @param matrix2 + */ + public static add(matrix1: Matrix2D, matrix2: Matrix2D): Matrix2D { + let result = Matrix2D.identity; + result.m11 = matrix1.m11 + matrix2.m11; + result.m12 = matrix1.m12 + matrix2.m12; + + result.m21 = matrix1.m21 + matrix2.m21; + result.m22 = matrix1.m22 + matrix2.m22; + + result.m31 = matrix1.m31 + matrix2.m31; + result.m32 = matrix1.m32 + matrix2.m32; + + return result; + } + + /** + * 将一个Matrix2D的元素除以另一个矩阵的元素 + * @param matrix1 + * @param matrix2 + */ + public static divide(matrix1: Matrix2D, matrix2: Matrix2D) { + let result = Matrix2D.identity; + + result.m11 = matrix1.m11 / matrix2.m11; + result.m12 = matrix1.m12 / matrix2.m12; + result.m21 = matrix1.m21 / matrix2.m21; + result.m22 = matrix1.m22 / matrix2.m22; + result.m31 = matrix1.m31 / matrix2.m31; + result.m32 = matrix1.m32 / matrix2.m32; + + return result; + } + + /** + * 创建一个新的Matrix2D,包含两个矩阵的乘法 + * @param matrix1 + * @param matrix2 + */ + public static mutiply(matrix1: Matrix2D, matrix2: Matrix2D | number) { + let result = Matrix2D.identity; + if (matrix2 instanceof Matrix2D) { + let m11 = (matrix1.m11 * matrix2.m11) + (matrix1.m12 * matrix2.m21); + let m12 = (matrix2.m11 * matrix2.m12) + (matrix1.m12 * matrix2.m22); + + let m21 = (matrix1.m21 * matrix2.m11) + (matrix1.m22 * matrix2.m21); + let m22 = (matrix1.m21 * matrix2.m12) + (matrix1.m22 * matrix2.m22); + + let m31 = (matrix1.m31 * matrix2.m11) + (matrix1.m32 * matrix2.m21) + matrix2.m31; + let m32 = (matrix1.m31 * matrix2.m12) + (matrix1.m32 * matrix2.m22) + matrix2.m32; + + result.m11 = m11; + result.m12 = m12; + + result.m21 = m21; + result.m22 = m22; + + result.m31 = m31; + result.m32 = m32; + } else if (typeof matrix2 == "number"){ + result.m11 = matrix1.m11 * matrix2; + result.m12 = matrix1.m12 * matrix2; + + result.m21 = matrix1.m21 * matrix2; + result.m22 = matrix1.m22 * matrix2; + + result.m31 = matrix1.m31 * matrix2; + result.m32 = matrix1.m32 * matrix2; + } + + return result; + } + + /** + * 创建一个新的Matrix2D,包含一个矩阵与另一个矩阵的减法。 + * @param matrix1 + * @param matrix2 + */ + public static subtract(matrix1: Matrix2D, matrix2: Matrix2D) { + let result = Matrix2D.identity; + + result.m11 = matrix1.m11 - matrix2.m11; + result.m12 = matrix1.m12 - matrix2.m12; + + result.m21 = matrix1.m21 - matrix2.m21; + result.m22 = matrix1.m22 - matrix2.m22; + + result.m31 = matrix1.m31 - matrix2.m31; + result.m32 = matrix1.m32 - matrix2.m32; + + return result; + } + } +} \ No newline at end of file diff --git a/source/src/Math/Rectangle.ts b/source/src/Math/Rectangle.ts index 0e67f022..44f3d500 100644 --- a/source/src/Math/Rectangle.ts +++ b/source/src/Math/Rectangle.ts @@ -1,7 +1,68 @@ module es { - export class Rectangle extends egret.Rectangle { - public _tempMat: Matrix2D; - public _transformMat: Matrix2D; + export class Rectangle implements IEquatable { + static emptyRectangle: Rectangle = new Rectangle(); + + /** + * 该矩形的左上角的x坐标 + */ + public x: number = 0; + + /** + * 该矩形的左上角的y坐标 + */ + public y: number = 0; + + /** + * 该矩形的宽度 + */ + public width: number = 0; + + /** + * 该矩形的高度 + */ + public height: number = 0; + + /** + * 返回X=0, Y=0, Width=0, Height=0的矩形 + */ + public static get empty(): Rectangle { + return this.emptyRectangle; + } + + /** + * 返回一个Number.Min/Max值的矩形 + */ + public static get maxRect(): Rectangle { + return new Rectangle(Number.MIN_VALUE / 2, Number.MIN_VALUE / 2, Number.MAX_VALUE, Number.MAX_VALUE); + } + + /** + * 返回此矩形左边缘的X坐标 + */ + public get left(): number { + return this.x; + } + + /** + * 返回此矩形右边缘的X坐标 + */ + public get right(): number { + return this.x + this.width; + } + + /** + * 返回此矩形顶边的y坐标 + */ + public get top(): number { + return this.y; + } + + /** + * 返回此矩形底边的y坐标 + */ + public get bottom(): number { + return this.y + this.height; + } /** * 获取矩形的最大点,即右下角 @@ -10,22 +71,26 @@ module es { return new Vector2(this.right, this.bottom); } - /** 中心点坐标 */ - public get center() { - return new Vector2(this.x + (this.width / 2), this.y + (this.height / 2)); + /** + * 这个矩形的宽和高是否为0,位置是否为(0,0) + */ + public isEmpty(): boolean { + return ((((this.width == 0) && (this.height == 0)) && (this.x == 0)) && (this.y == 0)); } - /** 左上角的坐标 */ + /** 这个矩形的左上角坐标 */ public get location() { return new Vector2(this.x, this.y); } - /** 左上角的坐标 */ public set location(value: Vector2) { this.x = value.x; this.y = value.y; } + /** + * 这个矩形的宽-高坐标 + */ public get size() { return new Vector2(this.width, this.height); } @@ -35,8 +100,35 @@ module es { this.height = value.y; } + /** + * 位于这个矩形中心的一个点 + * 如果 "宽度 "或 "高度 "是奇数,则中心点将向下舍入 + */ + public get center() { + return new Vector2(this.x + (this.width / 2), this.y + (this.height / 2)); + } + + // temp 用于计算边界的矩阵 + public _tempMat: Matrix2D; + public _transformMat: Matrix2D; + /** - * 创建一个矩形的最小/最大点(左上角,右下角的点) + * 创建一个新的Rectanglestruct实例,指定位置、宽度和高度。 + * @param x 创建的矩形的左上角的X坐标 + * @param y 创建的矩形的左上角的y坐标 + * @param width 创建的矩形的宽度 + * @param height 创建的矩形的高度 + */ + constructor(x: number = 0, y: number = 0, width: number = 0, height: number = 0) { + this.x = x; + this.y = y; + this.width = width; + this.height = height; + } + + + /** + * 创建一个给定最小/最大点(左上角,右下角)的矩形 * @param minX * @param minY * @param maxX @@ -49,6 +141,7 @@ module es { /** * 给定多边形的点,计算边界 * @param points + * @returns 来自多边形的点 */ public static rectEncompassingPoints(points: Vector2[]) { // 我们需要求出x/y的最小值/最大值 @@ -71,28 +164,69 @@ module es { } /** - * 如果其他相交矩形返回true - * @param value + * 获取指定边缘的位置 + * @param edge */ - public intersects(value: egret.Rectangle) { + public getSide(edge: Edge) { + switch (edge) { + case Edge.top: + return this.top; + case Edge.bottom: + return this.bottom; + case Edge.left: + return this.left; + case Edge.right: + return this.right; + default: + throw new Error("Argument Out Of Range"); + } + } + + /** + * 获取所提供的坐标是否在这个矩形的范围内 + * @param x 检查封堵点的X坐标 + * @param y 检查封堵点的Y坐标 + */ + public contains(x: number, y: number): boolean { + return ((((this.x <= x) && (x < (this.x + this.width))) && + (this.y <= y)) && (y < (this.y + this.height))); + } + + /** + * 按指定的水平和垂直方向调整此矩形的边缘 + * @param horizontalAmount 调整左、右边缘的值 + * @param verticalAmount 调整上、下边缘的值 + */ + public inflate(horizontalAmount: number, verticalAmount: number) { + this.x -= horizontalAmount; + this.y -= verticalAmount; + this.width += horizontalAmount * 2; + this.height += verticalAmount * 2; + } + + /** + * 获取其他矩形是否与这个矩形相交 + * @param value 另一个用于测试的矩形 + */ + public intersects(value: Rectangle) { return value.left < this.right && this.left < value.right && value.top < this.bottom && this.top < value.bottom; } - public rayIntersects(ray: Ray2D, distance: Ref): boolean{ + public rayIntersects(ray: Ray2D, distance: Ref): boolean { distance.value = 0; let maxValue = Number.MAX_VALUE; - if (Math.abs(ray.direction.x) < 1E-06){ + if (Math.abs(ray.direction.x) < 1E-06) { if ((ray.start.x < this.x) || (ray.start.x > this.x + this.width)) return false; - }else{ + } else { let num11 = 1 / ray.direction.x; let num8 = (this.x - ray.start.x) * num11; let num7 = (this.x + this.width - ray.start.x) * num11; - if (num8 > num7){ + if (num8 > num7) { let num14 = num8; num8 = num7; num7 = num14; @@ -104,14 +238,14 @@ module es { return false; } - if (Math.abs(ray.direction.y) < 1E-06){ + if (Math.abs(ray.direction.y) < 1E-06) { if ((ray.start.y < this.y) || (ray.start.y > this.y + this.height)) return false; - }else{ + } else { let num10 = 1 / ray.direction.y; let num6 = (this.y - ray.start.y) * num10; let num5 = (this.y + this.height - ray.start.y) * num10; - if (num6 > num5){ + if (num6 > num5) { let num13 = num6; num6 = num5; num5 = num13; @@ -136,28 +270,64 @@ 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); } + public getClosestPointOnBoundsToOrigin() { + let max = this.max; + let minDist = Math.abs(this.location.x); + let boundsPoint = new Vector2(this.location.x, 0); + + if (Math.abs(max.x) < minDist) { + minDist = Math.abs(max.x); + boundsPoint.x = max.x; + boundsPoint.y = 0; + } + + if (Math.abs(max.y) < minDist) { + minDist = Math.abs(max.y); + boundsPoint.x = 0; + boundsPoint.y = max.y; + } + + if (Math.abs(this.location.y) < minDist) { + minDist = Math.abs(this.location.y); + boundsPoint.x = 0; + boundsPoint.y = this.location.y; + } + + return boundsPoint; + } + + /** + * 返回离给定点最近的点 + * @param point 矩形上离点最近的点 + */ + public getClosestPointOnRectangleToPoint(point: Vector2) { + // 对于每条轴,如果点在框外,就把它限制在框内,否则就不要管它 + let res = new Vector2(); + res.x = MathHelper.clamp(point.x, this.left, this.right); + res.y = MathHelper.clamp(point.y, this.top, this.bottom); + + return res; + } + /** * 获取矩形边界上与给定点最近的点 * @param point * @param edgeNormal + * @returns 矩形边框上离点最近的点 */ public getClosestPointOnRectangleBorderToPoint(point: Vector2, edgeNormal: Vector2): Vector2 { edgeNormal = Vector2.zero; - // 对于每个轴,如果点在盒子外面 + // 对于每条轴,如果点在框外,就把它限制在框内,否则就不要管它 let res = new Vector2(); res.x = MathHelper.clamp(point.x, this.left, this.right); res.y = MathHelper.clamp(point.y, this.top, this.bottom); - // 如果点在矩形内,我们需要推res到边界,因为它将在矩形内 + // 如果点在矩形内,我们需要将res推到边界上,因为它将在矩形内 if (this.contains(res.x, res.y)) { let dl = res.x - this.left; let dr = this.right - res.x; @@ -189,55 +359,81 @@ module es { } /** - * + * 创建一个新的RectangleF,该RectangleF包含两个其他矩形的重叠区域 + * @param value1 + * @param value2 + * @returns 将两个矩形的重叠区域作为输出参数 */ - public getClosestPointOnBoundsToOrigin() { - let max = this.max; - let minDist = Math.abs(this.location.x); - let boundsPoint = new Vector2(this.location.x, 0); - - if (Math.abs(max.x) < minDist) { - minDist = Math.abs(max.x); - boundsPoint.x = max.x; - boundsPoint.y = 0; + public static intersect(value1: Rectangle, value2: Rectangle) { + if (value1.intersects(value2)) { + let right_side = Math.min(value1.x + value1.width, value2.x + value2.width); + let left_side = Math.max(value1.x, value2.x); + let top_side = Math.max(value1.y, value2.y); + let bottom_side = Math.min(value1.y + value1.height, value2.y + value2.height); + return new Rectangle(left_side, top_side, right_side - left_side, bottom_side - top_side); + } else { + return new Rectangle(0, 0, 0, 0); } - - if (Math.abs(max.y) < minDist) { - minDist = Math.abs(max.y); - boundsPoint.x = 0; - boundsPoint.y = max.y; - } - - if (Math.abs(this.location.y) < minDist) { - minDist = Math.abs(this.location.y); - boundsPoint.x = 0; - boundsPoint.y = this.location.y; - } - - return boundsPoint; } - public calculateBounds(parentPosition: Vector2, position: Vector2, origin: Vector2, scale: Vector2, rotation: number, width: number, height: number) { + /** + * 改变这个矩形的位置 + * @param offsetX 要添加到这个矩形的X坐标 + * @param offsetY 要添加到这个矩形的y坐标 + */ + public offset(offsetX: number, offsetY: number) { + this.x += offsetX; + this.y += offsetY; + } + + /** + * 创建一个完全包含两个其他矩形的新矩形 + * @param value1 + * @param value2 + */ + public static union(value1: Rectangle, value2: Rectangle) { + let x = Math.min(value1.x, value2.x); + let y = Math.min(value1.y, value2.y); + return new Rectangle(x, y, + Math.max(value1.right, value2.right) - x, + Math.max(value1.bottom, value2.bottom) - y); + } + + /** + * 在矩形重叠的地方创建一个新的矩形 + * @param value1 + * @param value2 + */ + public static overlap(value1: Rectangle, value2: Rectangle): Rectangle { + let x = Math.max(Math.max(value1.x, value2.x), 0); + let y = Math.max(Math.max(value1.y, value2.y), 0); + return new Rectangle(x, y, + Math.max(Math.min(value1.right, value2.right) - x, 0), + Math.max(Math.min(value1.bottom, value2.bottom) - y, 0)); + } + + public calculateBounds(parentPosition: Vector2, position: Vector2, origin: Vector2, scale: Vector2, + rotation: number, width: number, height: number) { if (rotation == 0) { this.x = parentPosition.x + position.x - origin.x * scale.x; this.y = parentPosition.y + position.y - origin.y * scale.y; this.width = width * scale.x; this.height = height * scale.y; } else { - // 特别注意旋转的边界。我们需要找到绝对的最小/最大值并从中创建边界 + // 我们需要找到我们的绝对最小/最大值,并据此创建边界 let worldPosX = parentPosition.x + position.x; let worldPosY = parentPosition.y + position.y; - // 将参考点设置为世界参考 - this._transformMat = Matrix2D.create().translate(-worldPosX - origin.x, -worldPosY - origin.y); - this._tempMat = Matrix2D.create().scale(scale.x, scale.y); + // 考虑到原点,将参考点设置为世界参考 + this._transformMat = Matrix2D.createTranslation(-worldPosX - origin.x, -worldPosY - origin.y); + this._tempMat = Matrix2D.createScale(scale.x, scale.y); this._transformMat = this._transformMat.multiply(this._tempMat); - this._tempMat = Matrix2D.create().rotate(rotation); + this._tempMat = Matrix2D.createRotation(rotation); this._transformMat = this._transformMat.multiply(this._tempMat); - this._tempMat = Matrix2D.create().translate(worldPosX, worldPosY); + this._tempMat = Matrix2D.createTranslation(worldPosX, worldPosY); this._transformMat = this._transformMat.multiply(this._tempMat); - // TODO: 这有点傻。我们可以把世界变换留在矩阵中,避免在世界空间中得到所有的四个角 + // TODO: 我们可以把世界变换留在矩阵中,避免在世界空间中得到所有的四个角 let topLeft = new Vector2(worldPosX, worldPosY); let topRight = new Vector2(worldPosX + width, worldPosY); let bottomLeft = new Vector2(worldPosX, worldPosY + height); @@ -248,6 +444,7 @@ module es { Vector2Ext.transformR(bottomLeft, this._transformMat, bottomLeft); Vector2Ext.transformR(bottomRight, this._transformMat, bottomRight); + // 找出最小值和最大值,这样我们就可以计算出我们的边界框。 let minX = Math.min(topLeft.x, bottomRight.x, topRight.x, bottomLeft.x); let maxX = Math.max(topLeft.x, bottomRight.x, topRight.x, bottomLeft.x); let minY = Math.min(topLeft.y, bottomRight.y, topRight.y, bottomLeft.y); @@ -258,5 +455,105 @@ module es { this.height = maxY - minY; } } + + /** + * 返回一个横跨当前矩形和提供的三角形位置的矩形 + * @param deltaX + * @param deltaY + */ + public getSweptBroadphaseBounds(deltaX: number, deltaY: number){ + let broadphasebox = Rectangle.empty; + + broadphasebox.x = deltaX > 0 ? this.x : this.x + deltaX; + broadphasebox.y = deltaY > 0 ? this.y : this.y + deltaY; + broadphasebox.width = deltaX > 0 ? deltaX + this.width : this.width - deltaX; + broadphasebox.height = deltaY > 0 ? deltaY + this.height : this.height - deltaY; + + return broadphasebox; + } + + /** + * 如果发生碰撞,返回true + * moveX和moveY将返回b1为避免碰撞而必须移动的移动量 + * @param other + * @param moveX + * @param moveY + */ + public collisionCheck(other: Rectangle, moveX: Ref, moveY: Ref){ + moveX.value = moveY.value = 0; + + let l = other.x - (this.x + this.width); + let r = (other.x + other.width) - this.x; + let t = (other.y - (this.y + this.height)); + let b = (other.y + other.height) - this.y; + + // 检验是否有碰撞 + if (l > 0 || r < 0 || t > 0 || b < 0) + return false; + + // 求两边的偏移量 + moveX.value = Math.abs(l) < r ? l : r; + moveY.value = Math.abs(t) < b ? t : b; + + // 只使用最小的偏移量 + if (Math.abs(moveX.value) < Math.abs(moveY.value)) + moveY.value = 0; + else + moveX.value = 0; + + return true; + } + + /** + * 计算两个矩形之间有符号的交点深度 + * @param rectA + * @param rectB + * @returns 两个相交的矩形之间的重叠量。 + * 这些深度值可以是负值,取决于矩形/相交的哪些边。 + * 这允许调用者确定正确的推送对象的方向,以解决碰撞问题。 + * 如果矩形不相交,则返回Vector2.Zero + */ + public static getIntersectionDepth(rectA: Rectangle, rectB: Rectangle): Vector2 { + // 计算半尺寸 + let halfWidthA = rectA.width / 2; + let halfHeightA = rectA.height / 2; + let halfWidthB = rectB.width / 2; + let halfHeightB = rectB.height / 2; + + // 计算中心 + let centerA = new Vector2(rectA.left + halfWidthA, rectA.top + halfHeightA); + let centerB = new Vector2(rectB.left + halfWidthB, rectB.top + halfHeightB); + + // 计算当前中心间的距离和最小非相交距离 + let distanceX = centerA.x - centerB.x; + let distanceY = centerA.y - centerB.y; + let minDistanceX = halfWidthA + halfWidthB; + let minDistanceY = halfHeightA + halfHeightB; + + // 如果我们根本不相交,则返回(0,0) + if (Math.abs(distanceX) >= minDistanceX || Math.abs(distanceY) >= minDistanceY) + return Vector2.zero; + + // 计算并返回交叉点深度 + let depthX = distanceX > 0 ? minDistanceX - distanceX : -minDistanceX - distanceX; + let depthY = distanceY > 0 ? minDistanceY - distanceY : -minDistanceY - distanceY; + + return new Vector2(depthX, depthY); + } + + /** + * 比较当前实例是否等于指定的矩形 + * @param other + */ + public equals(other: Rectangle) { + return this === other; + } + + /** + * 获取这个矩形的哈希码 + */ + public getHashCode(): number{ + return (this.x ^ this.y ^ this.width ^ this.height); + } } } diff --git a/source/src/Physics/Collision.ts b/source/src/Physics/Collision.ts index 874e5c8f..c1e9ef30 100644 --- a/source/src/Physics/Collision.ts +++ b/source/src/Physics/Collision.ts @@ -79,7 +79,7 @@ module es { return Vector2.distanceSquared(circleCenter, point) < radius * radius; } - public static rectToCircle(rect: egret.Rectangle, cPosition: Vector2, cRadius: number): boolean { + public static rectToCircle(rect: Rectangle, cPosition: Vector2, cRadius: number): boolean { if (this.rectToPoint(rect.x, rect.y, rect.width, rect.height, cPosition)) return true; diff --git a/source/src/Physics/Shapes/Polygon.ts b/source/src/Physics/Shapes/Polygon.ts index c80de6fd..06cb2b04 100644 --- a/source/src/Physics/Shapes/Polygon.ts +++ b/source/src/Physics/Shapes/Polygon.ts @@ -217,10 +217,10 @@ module es { if (collider.shouldColliderScaleAndRotateWithTransform) { let hasUnitScale = true; let tempMat: Matrix2D; - let combinedMatrix = Matrix2D.create().translate(-this._polygonCenter.x, -this._polygonCenter.y); + let combinedMatrix = Matrix2D.createTranslation(-this._polygonCenter.x, -this._polygonCenter.y); if (!collider.entity.transform.scale.equals(Vector2.one)) { - tempMat = Matrix2D.create().scale(collider.entity.transform.scale.x, collider.entity.transform.scale.y); + tempMat = Matrix2D.createScale(collider.entity.transform.scale.x, collider.entity.transform.scale.y); combinedMatrix = combinedMatrix.multiply(tempMat); hasUnitScale = false; @@ -229,7 +229,7 @@ module es { } if (collider.entity.transform.rotation != 0) { - tempMat = Matrix2D.create().rotate(collider.entity.transform.rotation); + tempMat = Matrix2D.createRotation(collider.entity.transform.rotation); combinedMatrix = combinedMatrix.multiply(tempMat); // 为了处理偏移原点的旋转我们只需要将圆心在(0,0)附近移动 @@ -241,7 +241,7 @@ module es { collider.entity.transform.rotationDegrees + offsetAngle); } - tempMat = Matrix2D.create().translate(this._polygonCenter.x, this._polygonCenter.y); + tempMat = Matrix2D.createTranslation(this._polygonCenter.x, this._polygonCenter.y); combinedMatrix = combinedMatrix.multiply(tempMat); // 最后变换原始点 diff --git a/source/src/Physics/SpatialHash.ts b/source/src/Physics/SpatialHash.ts index 92ac411b..0cb358e9 100644 --- a/source/src/Physics/SpatialHash.ts +++ b/source/src/Physics/SpatialHash.ts @@ -53,7 +53,7 @@ module es { for (let y = p1.y; y <= p2.y; y++) { // 如果没有单元格,我们需要创建它 let c: Collider[] = this.cellAtPosition(x, y, true); - if (!c.firstOrDefault(c => c.hashCode == collider.hashCode)) + if (!c.firstOrDefault(c => c == collider)) c.push(collider); } } @@ -134,7 +134,7 @@ module es { continue; if (bounds.intersects(collider.bounds)) { - if (!this._tempHashSet.firstOrDefault(c => c.hashCode == collider.hashCode)) + if (!this._tempHashSet.firstOrDefault(c => c == collider)) this._tempHashSet.push(collider); } } diff --git a/source/src/Utils/Analysis/Layout.ts b/source/src/Utils/Analysis/Layout.ts deleted file mode 100644 index dc9468c9..00000000 --- a/source/src/Utils/Analysis/Layout.ts +++ /dev/null @@ -1,71 +0,0 @@ -module es { - /** - * 支持标题安全区的布局类。 - */ - export class Layout { - public clientArea: Rectangle; - public safeArea: Rectangle; - - constructor() { - this.clientArea = new Rectangle(0, 0, Core.graphicsDevice.viewport.width, Core.graphicsDevice.viewport.height); - this.safeArea = this.clientArea; - } - - public place(size: Vector2, horizontalMargin: number, verticalMargine: number, alignment: Alignment) { - let rc = new Rectangle(0, 0, size.x, size.y); - if ((alignment & Alignment.left) != 0) { - rc.x = this.clientArea.x + (this.clientArea.width * horizontalMargin); - } else if ((alignment & Alignment.right) != 0) { - rc.x = this.clientArea.x + (this.clientArea.width * (1 - horizontalMargin)) - rc.width; - } else if ((alignment & Alignment.horizontalCenter) != 0) { - rc.x = this.clientArea.x + (this.clientArea.width - rc.width) / 2 + (horizontalMargin * this.clientArea.width); - } else { - - } - - if ((alignment & Alignment.top) != 0) { - rc.y = this.clientArea.y + (this.clientArea.height * verticalMargine); - } else if ((alignment & Alignment.bottom) != 0) { - rc.y = this.clientArea.y + (this.clientArea.height * (1 - verticalMargine)) - rc.height; - } else if ((alignment & Alignment.verticalCenter) != 0) { - rc.y = this.clientArea.y + (this.clientArea.height - rc.height) / 2 + (verticalMargine * this.clientArea.height); - } else { - - } - - // 确保布局区域在安全区域内。 - if (rc.left < this.safeArea.left) - rc.x = this.safeArea.left; - - if (rc.right > this.safeArea.right) - rc.x = this.safeArea.right - rc.width; - - if (rc.top < this.safeArea.top) - rc.y = this.safeArea.top; - - if (rc.bottom > this.safeArea.bottom) - rc.y = this.safeArea.bottom - rc.height; - - return rc; - } - } - - export enum Alignment { - none = 0, - left = 1, - right = 2, - horizontalCenter = 4, - top = 8, - bottom = 16, - verticalCenter = 32, - topLeft = top | left, - topRight = top | right, - topCenter = top | horizontalCenter, - bottomLeft = bottom | left, - bottomRight = bottom | right, - bottomCenter = bottom | horizontalCenter, - centerLeft = verticalCenter | left, - centerRight = verticalCenter | right, - center = verticalCenter | horizontalCenter - } -} diff --git a/source/src/Utils/Analysis/TimeRuler.ts b/source/src/Utils/Analysis/TimeRuler.ts deleted file mode 100644 index 1cf01823..00000000 --- a/source/src/Utils/Analysis/TimeRuler.ts +++ /dev/null @@ -1,408 +0,0 @@ -module es { - /** - * 通过使用这个类,您可以直观地找到瓶颈和基本的CPU使用情况。 - */ - export class TimeRuler { - /** 最大条数 8 */ - public static readonly maxBars = 8; - /** */ - public static readonly maxSamples = 256; - /** 每条的最大嵌套调用 */ - public static readonly maxNestCall = 32; - /** 条的高度(以像素为单位) */ - public static readonly barHeight = 8; - /** 最大显示帧 */ - public static readonly maxSampleFrames = 4; - /** 持续时间(帧数)为采取抓拍日志。 */ - public static readonly logSnapDuration = 120; - public static readonly barPadding = 2; - public static readonly autoAdjustDelay = 30; - private static _instance; - /** 获取/设置目标样本帧。 */ - public targetSampleFrames: number; - /** 获取/设置计时器标尺宽度。 */ - public width: number; - public enabled: true; - /** 获取/设置日志显示或否 */ - public showLog = false; - /** 每帧的日志 */ - public logs: FrameLog[]; - /** 当前显示帧计数 */ - private sampleFrames: number; - /** TimerRuler画的位置。 */ - private _position: Vector2; - /** 上一帧日志 */ - private prevLog: FrameLog; - /** 当前帧日志 */ - private curLog: FrameLog; - /** 当前帧数量 */ - private frameCount: number; - /** */ - private markers: MarkerInfo[] = []; - /** 秒表用来测量时间。 */ - private stopwacth: stopwatch.Stopwatch = new stopwatch.Stopwatch(); - /** 从标记名映射到标记id的字典。 */ - private _markerNameToIdMap: Map = new Map(); - /** - * 你想在游戏开始时调用StartFrame更新方法。 - * 当游戏在固定时间步进模式下运行缓慢时,更新会多次调用。 - * 在这种情况下,我们应该忽略StartFrame调用。 - * 为此,我们只需一直跟踪StartFrame调用的次数,直到Draw被调用。 - */ - private _updateCount: number; - private _frameAdjust: number; - - /** 画透明背景 */ - private _rectShape1: egret.Shape = new egret.Shape(); - private _rectShape2: egret.Shape = new egret.Shape(); - private _rectShape3: egret.Shape = new egret.Shape(); - private _rectShape4: egret.Shape = new egret.Shape(); - private _rectShape5: egret.Shape = new egret.Shape(); - private _rectShape6: egret.Shape = new egret.Shape(); - - constructor() { - this.logs = new Array(2); - for (let i = 0; i < this.logs.length; ++i) - this.logs[i] = new FrameLog(); - - this.sampleFrames = this.targetSampleFrames = 1; - this.width = Math.floor(Core.graphicsDevice.viewport.width * 0.8); - - es.Core.emitter.addObserver(CoreEvents.GraphicsDeviceReset, this.onGraphicsDeviceReset, this); - this.onGraphicsDeviceReset(); - - es.Core.Instance.stage.addChild(this._rectShape1); - es.Core.Instance.stage.addChild(this._rectShape2); - es.Core.Instance.stage.addChild(this._rectShape3); - es.Core.Instance.stage.addChild(this._rectShape4); - es.Core.Instance.stage.addChild(this._rectShape5); - es.Core.Instance.stage.addChild(this._rectShape6); - } - - public static get Instance(): TimeRuler { - if (!this._instance) - this._instance = new TimeRuler(); - return this._instance; - } - - /** - * 开始新的帧 - */ - public startFrame() { - // 当这个方法被多次调用时,我们跳过复位帧。 - if (isNaN(this._updateCount)) - this._updateCount = 0; - let count = this._updateCount ++; - if (this.enabled && (1 < count && count < TimeRuler.maxSampleFrames)) - return; - - // 更新当前帧记录 - this.prevLog = this.logs[this.frameCount++ & 0x1]; - this.curLog = this.logs[this.frameCount & 0x1]; - - let endFrameTime = this.stopwacth.getTime(); - // 更新标记并创建日志。 - for (let barIdx = 0; barIdx < this.prevLog.bars.length; ++barIdx) { - let prevBar = this.prevLog.bars[barIdx]; - let nextBar = this.curLog.bars[barIdx]; - - // 重新打开前一帧中没有被调用的EndMark的标记 - for (let nest = 0; nest < prevBar.nestCount; ++nest) { - let markerIdx = prevBar.markerNests[nest]; - prevBar.markers[markerIdx].endTime = endFrameTime; - nextBar.markerNests[nest] = nest; - nextBar.markers[nest].markerId = prevBar.markers[markerIdx].markerId; - nextBar.markers[nest].beginTime = 0; - nextBar.markers[nest].endTime = -1; - nextBar.markers[nest].color = prevBar.markers[markerIdx].color; - } - - // 更新日志标记 - for (let markerIdx = 0; markerIdx < prevBar.markCount; ++markerIdx) { - let duration = prevBar.markers[markerIdx].endTime - prevBar.markers[markerIdx].beginTime; - let markerId = prevBar.markers[markerIdx].markerId; - let m = this.markers[markerId]; - - m.logs[barIdx].color = prevBar.markers[markerIdx].color; - if (!m.logs[barIdx].initialized) { - m.logs[barIdx].min = duration; - m.logs[barIdx].max = duration; - m.logs[barIdx].avg = duration; - m.logs[barIdx].initialized = true; - } else { - m.logs[barIdx].min = Math.min(m.logs[barIdx].min, duration); - m.logs[barIdx].max = Math.min(m.logs[barIdx].max, duration); - m.logs[barIdx].avg += duration; - m.logs[barIdx].avg *= 0.5; - - if (m.logs[barIdx].samples++ >= TimeRuler.logSnapDuration) { - m.logs[barIdx].snapMin = m.logs[barIdx].min; - m.logs[barIdx].snapMax = m.logs[barIdx].max; - m.logs[barIdx].snapAvg = m.logs[barIdx].avg; - m.logs[barIdx].samples = 0; - } - } - } - - nextBar.markCount = prevBar.nestCount; - nextBar.nestCount = prevBar.nestCount; - } - - this.stopwacth.reset(); - this.stopwacth.start(); - } - - /** - * 开始测量时间。 - * @param markerName - * @param color - * @param barIndex - */ - public beginMark(markerName: string, color: number, barIndex: number = 0) { - if (barIndex < 0 || barIndex >= TimeRuler.maxBars) - throw new Error("barIndex argument out of range"); - - let bar = this.curLog.bars[barIndex]; - if (bar.markCount >= TimeRuler.maxSamples) { - throw new Error("超出采样次数,可以设置更大的数字为timeruler.maxsaple,或者降低采样次数"); - } - - if (bar.nestCount >= TimeRuler.maxNestCall) { - throw new Error("超出采样次数,可以设置更大的数字为timeruler.maxsaple,或者降低采样次数"); - } - - // 获取注册的标记 - let markerId = this._markerNameToIdMap.get(markerName); - if (isNaN(markerId)) { - // 如果此标记未注册,则注册此标记。 - markerId = this.markers.length; - this._markerNameToIdMap.set(markerName, markerId); - this.markers.push(new MarkerInfo(markerName)); - } - - // 开始测量 - bar.markerNests[bar.nestCount++] = bar.markCount; - - // 填充标记参数 - bar.markers[bar.markCount].markerId = markerId; - bar.markers[bar.markCount].color = color; - bar.markers[bar.markCount].beginTime = this.stopwacth.getTime(); - - bar.markers[bar.markCount].endTime = -1; - - bar.markCount ++; - } - - /** - * - * @param markerName - * @param barIndex - */ - public endMark(markerName: string, barIndex: number = 0) { - if (barIndex < 0 || barIndex >= TimeRuler.maxBars) - throw new Error("barIndex参数超出范围"); - - let bar = this.curLog.bars[barIndex]; - if (bar.nestCount <= 0) { - throw new Error("先调用beginMark方法,再调用endMark方法"); - } - - let markerId = this._markerNameToIdMap.get(markerName); - if (isNaN(markerId)) { - throw new Error(`标记 ${markerName} 未注册。请确认您指定的名称与 beginMark 方法使用的名称相同`); - } - - let markerIdx = bar.markerNests[--bar.nestCount]; - if (bar.markers[markerIdx].markerId != markerId) { - throw new Error("beginMark/endMark方法的调用顺序不正确,beginMark(A),beginMark(B),endMark(B),endMark(A),但你不能像beginMark(A),beginMark(B),endMark(A),endMark(B)这样调用。"); - } - - bar.markers[markerIdx].endTime = this.stopwacth.getTime(); - } - - /** - * 获取给定bar索引和标记名称的平均时间。 - * @param barIndex - * @param markerName - */ - public getAverageTime(barIndex: number, markerName: string) { - if (barIndex < 0 || barIndex >= TimeRuler.maxBars) { - throw new Error("barIndex参数超出范围"); - } - let result = 0; - let markerId = this._markerNameToIdMap.get(markerName); - if (markerId) { - result = this.markers[markerId].logs[barIndex].avg; - } - - return result; - } - - /** - * - */ - public resetLog() { - this.markers.forEach(markerInfo => { - for (let i = 0; i < markerInfo.logs.length; ++i) { - markerInfo.logs[i].initialized = false; - markerInfo.logs[i].snapMin = 0; - markerInfo.logs[i].snapMax = 0; - markerInfo.logs[i].snapAvg = 0; - - markerInfo.logs[i].min = 0; - markerInfo.logs[i].max = 0; - markerInfo.logs[i].avg = 0; - - markerInfo.logs[i].samples = 0; - } - }); - } - - public render(position: Vector2 = this._position, width: number = this.width) { - if (!this.showLog) - return; - - let height = 0; - let maxTime = 0; - this.prevLog.bars.forEach(bar => { - if (bar.markCount > 0) { - height += TimeRuler.barHeight + TimeRuler.barPadding * 2; - maxTime = Math.max(maxTime, bar.markers[bar.markCount - 1].endTime); - } - }); - - const frameSpan = 1 / 60 * 1000; - let sampleSpan = this.sampleFrames * frameSpan; - - if (maxTime > sampleSpan) { - this._frameAdjust = Math.max(0, this._frameAdjust) + 1; - } else { - this._frameAdjust = Math.min(0, this._frameAdjust) - 1; - } - - if (Math.max(this._frameAdjust) > TimeRuler.autoAdjustDelay) { - this.sampleFrames = Math.min(TimeRuler.maxSampleFrames, this.sampleFrames); - this.sampleFrames = Math.max(this.targetSampleFrames, Math.floor(maxTime / frameSpan) + 1); - - this._frameAdjust = 0; - } - - let msToPs = width / sampleSpan; - let startY = position.y - (height - TimeRuler.barHeight); - let y = startY; - - // 画透明背景 - let rc = new Rectangle(position.x, y, width, height); - this._rectShape1.graphics.clear(); - this._rectShape1.graphics.beginFill(0x000000, 128 / 255); - this._rectShape1.graphics.drawRect(rc.x, rc.y, rc.width, rc.height); - this._rectShape1.graphics.endFill(); - - // 为每条线画标记 - rc.height = TimeRuler.barHeight; - this._rectShape2.graphics.clear(); - for (let bar of this.prevLog.bars){ - rc.y = y + TimeRuler.barPadding; - if (bar.markCount > 0){ - for (let j = 0; j < bar.markCount; ++j){ - let bt = bar.markers[j].beginTime; - let et = bar.markers[j].endTime; - let sx = Math.floor(position.x + bt * msToPs); - let ex = Math.floor(position.x + et * msToPs); - rc.x = sx; - rc.width = Math.max(ex - sx, 1); - - this._rectShape2.graphics.beginFill(bar.markers[j].color); - this._rectShape2.graphics.drawRect(rc.x, rc.y, rc.width, rc.height); - this._rectShape2.graphics.endFill(); - } - } - - y += TimeRuler.barHeight + TimeRuler.barPadding; - } - - // 画网格线 - // 每个网格代表ms - rc = new Rectangle(position.x, startY, 1, height); - this._rectShape3.graphics.clear(); - for (let t = 1; t < sampleSpan; t += 1){ - rc.x = Math.floor(position.x + t * msToPs); - this._rectShape3.graphics.beginFill(0x808080); - this._rectShape3.graphics.drawRect(rc.x, rc.y, rc.width, rc.height); - this._rectShape3.graphics.endFill(); - } - - // 画frame grid - this._rectShape4.graphics.clear(); - for (let i = 0; i <= this.sampleFrames; ++i){ - rc.x = Math.floor(position.x + frameSpan * i * msToPs); - this._rectShape4.graphics.beginFill(0xFFFFFF); - this._rectShape4.graphics.drawRect(rc.x, rc.y, rc.width, rc.height); - this._rectShape4.graphics.endFill(); - } - - // TODO: 绘制字体 - } - - private onGraphicsDeviceReset() { - let layout = new Layout(); - this._position = layout.place(new Vector2(this.width, TimeRuler.barHeight), 0, 0.01, Alignment.bottomCenter).location; - } - } - - /** - * 日志信息 - */ - export class FrameLog { - public bars: MarkerCollection[]; - - constructor() { - this.bars = new Array(TimeRuler.maxBars); - this.bars.fill(new MarkerCollection(), 0, TimeRuler.maxBars); - } - } - - /** - * 标记的集合 - */ - export class MarkerCollection { - public markers: Marker[] = new Array(TimeRuler.maxSamples); - public markCount: number = 0; - public markerNests: number[] = new Array(TimeRuler.maxNestCall); - public nestCount: number = 0; - - constructor() { - this.markers.fill(new Marker(), 0, TimeRuler.maxSamples); - this.markerNests.fill(0, 0, TimeRuler.maxNestCall); - } - } - - export class Marker { - public markerId: number = 0; - public beginTime: number = 0; - public endTime: number = 0; - public color: number = 0x000000; - } - - export class MarkerInfo { - public name: string; - public logs: MarkerLog[] = new Array(TimeRuler.maxBars); - - constructor(name) { - this.name = name; - this.logs.fill(new MarkerLog(), 0, TimeRuler.maxBars); - } - } - - export class MarkerLog { - public snapMin: number = 0; - public snapMax: number = 0; - public snapAvg: number = 0; - public min: number = 0; - public max: number = 0; - public avg: number = 0; - public samples: number = 0; - public color: number = 0x000000; - public initialized: boolean = false; - } -} diff --git a/source/src/Utils/ContentManager.ts b/source/src/Utils/ContentManager.ts deleted file mode 100644 index aeb5de02..00000000 --- a/source/src/Utils/ContentManager.ts +++ /dev/null @@ -1,44 +0,0 @@ -module es { - export class ContentManager { - protected loadedAssets: Map = new Map(); - - /** 异步加载资源 */ - public loadRes(name: string, local: boolean = true): Promise { - return new Promise((resolve, reject) => { - let res = this.loadedAssets.get(name); - if (res) { - resolve(res); - return; - } - - if (local) { - RES.getResAsync(name).then((data) => { - this.loadedAssets.set(name, data); - resolve(data); - }).catch((err) => { - console.error("资源加载错误:", name, err); - reject(err); - }); - } else { - RES.getResByUrl(name).then((data) => { - this.loadedAssets.set(name, data); - resolve(data); - }).catch((err) => { - console.error("资源加载错误:", name, err); - reject(err); - }); - } - }); - } - - public dispose() { - this.loadedAssets.forEach(value => { - let assetsToRemove = value; - if (RES.destroyRes(assetsToRemove)) - assetsToRemove.dispose(); - }); - - this.loadedAssets.clear(); - } - } -} diff --git a/source/src/Utils/Coroutines/Coroutine.ts b/source/src/Utils/Coroutines/Coroutine.ts deleted file mode 100644 index 6c038224..00000000 --- a/source/src/Utils/Coroutines/Coroutine.ts +++ /dev/null @@ -1,38 +0,0 @@ -module es { - /** - * startCoroutine返回的接口,提供了在执行中停止协同程序的能力 - */ - export interface ICoroutine { - /** - * 停止协同程序 - */ - stop(); - - /** - * 设置协程应该使用时间增量还是使用非缩放时间增量来计时 - * @param useUnscaledDeltaTime - */ - setUseUnscaledDeltaTime(useUnscaledDeltaTime): ICoroutine; - } - - export class Coroutine { - public static waitForSeconds(seconds: number){ - return WaitForSeconds.waiter.wait(seconds); - } - } - - /** - * 协作程序需要暂停一段时间时的助手类。 - * 返回协同程序。 - * waitForSeconds返回number。 - */ - export class WaitForSeconds { - public static waiter: WaitForSeconds = new WaitForSeconds(); - public waitTime: number; - - public wait(seconds: number): WaitForSeconds { - WaitForSeconds.waiter.waitTime = seconds; - return WaitForSeconds.waiter; - } - } -} \ No newline at end of file diff --git a/source/src/Utils/Coroutines/CoroutineManager.ts b/source/src/Utils/Coroutines/CoroutineManager.ts deleted file mode 100644 index 44f164c6..00000000 --- a/source/src/Utils/Coroutines/CoroutineManager.ts +++ /dev/null @@ -1,153 +0,0 @@ -module es { - /** - * CoroutineManager使用的内部类,用于隐藏协同程序所需的数据 - */ - export class CoroutineImpl implements ICoroutine, IPoolable { - public enumerator: Iterator; - /** - * 每当产生延迟时,它就被添加到跟踪延迟的waitTimer中 - */ - public waitTimer: number; - public isDone: boolean; - public waitForCoroutine: CoroutineImpl; - public useUnscaledDeltaTime: boolean = false; - - public stop(){ - this.isDone = true; - } - - public setUseUnscaledDeltaTime(useUnscaledDeltaTime): es.ICoroutine { - this.useUnscaledDeltaTime = useUnscaledDeltaTime; - return this; - } - - public prepareForuse(){ - this.isDone = false; - } - - public reset() { - this.isDone = true; - this.waitTimer = 0; - this.waitForCoroutine = null; - this.enumerator = null; - this.useUnscaledDeltaTime = false; - } - } - - /** - * 基本CoroutineManager。协同程序可以做以下事情: - * - return null(在下一帧继续执行) - * - return Coroutine.waitForSeconds(3)。等待3秒(延时3秒后再次执行) - * - return startCoroutine(another())(在再次执行之前等待另一个协程) - */ - export class CoroutineManager extends GlobalManager { - /** - * 标记来跟踪何时处于更新循环中。 - * 如果一个新的协程在更新循环期间启动,我们必须将其插入到shouldRunNextFrame列表中,以避免在迭代时修改列表。 - */ - public _isInUpdate: boolean; - - public _unblockedCoroutines: CoroutineImpl[] = []; - public _shouldRunNextFrame: CoroutineImpl[] = []; - - /** - * 将i枚举器添加到CoroutineManager。协程在每一帧调用更新之前被执行。 - * @param enumerator - */ - public startCoroutine(enumerator: Iterator) { - // 查找或创建CoroutineImpl - let coroutine = Pool.obtain(CoroutineImpl); - coroutine.prepareForuse(); - - // 设置协程并添加它 - coroutine.enumerator = enumerator; - let shouldContinueCoroutine = this.tickCoroutine(coroutine); - - // 防止空协程 - if (!shouldContinueCoroutine) - return null; - - if (this._isInUpdate) - this._shouldRunNextFrame.push(coroutine); - else - this._unblockedCoroutines.push(coroutine); - - return coroutine; - } - - public update() { - this._isInUpdate = true; - for (let i = 0; i < this._unblockedCoroutines.length; i ++){ - let coroutine = this._unblockedCoroutines[i]; - - // 检查已停止的协程 - if (coroutine.isDone){ - Pool.free(coroutine); - continue; - } - - // 我们是否在等待其他协程完成 - if (coroutine.waitForCoroutine != null){ - if (coroutine.waitForCoroutine.isDone){ - coroutine.waitForCoroutine = null; - }else{ - this._shouldRunNextFrame.push(coroutine); - continue; - } - } - - // 如果我们有计时器,就用它 - if (coroutine.waitTimer > 0){ - // 还有时间。递减,并再次运行下一帧,确保递减与适当的deltaTime。 - coroutine.waitTimer -= coroutine.useUnscaledDeltaTime ? Time.unscaledDeltaTime : Time.deltaTime; - this._shouldRunNextFrame.push(coroutine); - continue; - } - - if (this.tickCoroutine(coroutine)) - this._shouldRunNextFrame.push(coroutine); - } - - this._unblockedCoroutines.length = 0; - this._unblockedCoroutines.concat(this._shouldRunNextFrame); - this._shouldRunNextFrame.length = 0; - - this._isInUpdate = false; - } - - /** - * 如果协同程序在下一帧继续运行,则返回true。此方法将把完成的协程放回池中! - * @param coroutine - */ - public tickCoroutine(coroutine: CoroutineImpl){ - let current = coroutine.enumerator.next(); - // 这个协同程序已经完成了 - if (!current.value || current.done){ - Pool.free(coroutine); - return false; - } - - if (!current.value){ - return true; - } - - if (current.value instanceof WaitForSeconds){ - coroutine.waitTimer = (current.value as WaitForSeconds).waitTime; - return true; - } - - if (current.value instanceof Number){ - console.warn("协同程序检查返回一个Number类型,请不要在生产环境使用"); - coroutine.waitTimer = Number(current); - return true; - } - - if (current.value instanceof CoroutineImpl){ - coroutine.waitForCoroutine = current.value as CoroutineImpl; - return true; - }else { - return true; - } - } - } -} \ No newline at end of file diff --git a/source/src/Utils/DrawUtils.ts b/source/src/Utils/DrawUtils.ts deleted file mode 100644 index 1134fa85..00000000 --- a/source/src/Utils/DrawUtils.ts +++ /dev/null @@ -1,17 +0,0 @@ -module es { - /** 各种辅助方法来辅助绘图 */ - export class DrawUtils { - public static getColorMatrix(color: number): egret.ColorMatrixFilter { - let colorMatrix = [ - 1, 0, 0, 0, 0, - 0, 1, 0, 0, 0, - 0, 0, 1, 0, 0, - 0, 0, 0, 1, 0 - ]; - colorMatrix[0] = Math.floor(color / 256 / 256) / 255; - colorMatrix[6] = Math.floor(color / 256 % 256) / 255; - colorMatrix[12] = color % 256 / 255; - return new egret.ColorMatrixFilter(colorMatrix); - } - } -} diff --git a/source/src/Utils/Input/Input.ts b/source/src/Utils/Input/Input.ts deleted file mode 100644 index fa3f3d9c..00000000 --- a/source/src/Utils/Input/Input.ts +++ /dev/null @@ -1,193 +0,0 @@ -module es { - export class TouchState { - public x = 0; - public y = 0; - public touchPoint: number = -1; - public touchDown: boolean = false; - - public get position() { - return new Vector2(this.x, this.y); - } - - public reset() { - this.x = 0; - this.y = 0; - this.touchDown = false; - this.touchPoint = -1; - } - } - - export class Input { - private static _init: boolean = false; - private static _previousTouchState: TouchState = new TouchState(); - private static _resolutionOffset: Vector2 = new Vector2(); - private static _touchIndex: number = 0; - - private static _gameTouchs: TouchState[] = []; - - /** - * 触摸列表 存放最大个数量触摸点信息 - * 可通过判断touchPoint是否为-1 来确定是否为有触摸 - * 通过判断touchDown 判断触摸点是否有按下 - */ - public static get gameTouchs() { - return this._gameTouchs; - } - - private static _resolutionScale: Vector2 = Vector2.one; - - /** 获取缩放值 默认为1 */ - public static get resolutionScale() { - return this._resolutionScale; - } - - private static _totalTouchCount: number = 0; - - /** 当前触摸点数量 */ - public static get totalTouchCount() { - return this._totalTouchCount; - } - - /** 返回第一个触摸点的坐标 */ - public static get touchPosition() { - if (!this._gameTouchs[0]) - return Vector2.zero; - return this._gameTouchs[0].position; - } - - public static _virtualInputs: VirtualInput[] = []; - - /** 获取最大触摸数 */ - public static get maxSupportedTouch() { - return Core._instance.stage.maxTouches; - } - - /** - * 设置最大触摸数 - */ - public static set maxSupportedTouch(value: number) { - Core._instance.stage.maxTouches = value; - this.initTouchCache(); - } - - /** 获取第一个触摸点距离上次距离的增量 */ - public static get touchPositionDelta() { - let delta = Vector2.subtract(this.touchPosition, this._previousTouchState.position); - if (delta.length() > 0) { - this.setpreviousTouchState(this._gameTouchs[0]); - } - return delta; - } - - public static initialize() { - if (this._init) - return; - - this._init = true; - Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.touchBegin, this); - Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_MOVE, this.touchMove, this); - Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_END, this.touchEnd, this); - Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_CANCEL, this.touchEnd, this); - Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_RELEASE_OUTSIDE, this.touchEnd, this); - - this.initTouchCache(); - } - - public static update(){ - KeyboardUtils.update(); - for (let i = 0; i < this._virtualInputs.length; i ++) - this._virtualInputs[i].update(); - } - - public static scaledPosition(position: Vector2) { - let scaledPos = new Vector2(position.x - this._resolutionOffset.x, position.y - this._resolutionOffset.y); - return Vector2.multiply(scaledPos, this.resolutionScale); - } - - /** - * 只有在当前帧按下并且在上一帧没有按下时才算press - * @param key - */ - public static isKeyPressed(key: Keys): boolean{ - return KeyboardUtils.currentKeys.contains(key) && !KeyboardUtils.previousKeys.contains(key); - } - - public static isKeyPressedBoth(keyA: Keys, keyB: Keys){ - return this.isKeyPressed(keyA) || this.isKeyPressed(keyB); - } - - public static isKeyDown(key: Keys): boolean { - return KeyboardUtils.currentKeys.contains(key); - } - - public static isKeyDownBoth(keyA: Keys, keyB: Keys){ - return this.isKeyDown(keyA) || this.isKeyDown(keyB); - } - - public static isKeyReleased(key: Keys){ - return !KeyboardUtils.currentKeys.contains(key) && KeyboardUtils.previousKeys.contains(key); - } - - public static isKeyReleasedBoth(keyA: Keys, keyB: Keys){ - return this.isKeyReleased(keyA) || this.isKeyReleased(keyB); - } - - private static initTouchCache() { - this._totalTouchCount = 0; - this._touchIndex = 0; - this._gameTouchs.length = 0; - for (let i = 0; i < this.maxSupportedTouch; i++) { - this._gameTouchs.push(new TouchState()); - } - } - - private static touchBegin(evt: egret.TouchEvent) { - if (this._touchIndex < this.maxSupportedTouch) { - this._gameTouchs[this._touchIndex].touchPoint = evt.touchPointID; - this._gameTouchs[this._touchIndex].touchDown = evt.touchDown; - this._gameTouchs[this._touchIndex].x = evt.stageX; - this._gameTouchs[this._touchIndex].y = evt.stageY; - if (this._touchIndex == 0) { - this.setpreviousTouchState(this._gameTouchs[0]); - } - this._touchIndex++; - this._totalTouchCount++; - } - } - - private static touchMove(evt: egret.TouchEvent) { - if (evt.touchPointID == this._gameTouchs[0].touchPoint) { - this.setpreviousTouchState(this._gameTouchs[0]); - } - - let touchIndex = this._gameTouchs.findIndex(touch => touch.touchPoint == evt.touchPointID); - if (touchIndex != -1) { - let touchData = this._gameTouchs[touchIndex]; - touchData.x = evt.stageX; - touchData.y = evt.stageY; - } - } - - private static touchEnd(evt: egret.TouchEvent) { - let touchIndex = this._gameTouchs.findIndex(touch => touch.touchPoint == evt.touchPointID); - if (touchIndex != -1) { - let touchData = this._gameTouchs[touchIndex]; - touchData.reset(); - if (touchIndex == 0) - this._previousTouchState.reset(); - this._totalTouchCount--; - if (this.totalTouchCount == 0) { - this._touchIndex = 0; - } - } - } - - private static setpreviousTouchState(touchState: TouchState) { - this._previousTouchState = new TouchState(); - this._previousTouchState.x = touchState.position.x; - this._previousTouchState.y = touchState.position.y; - this._previousTouchState.touchPoint = touchState.touchPoint; - this._previousTouchState.touchDown = touchState.touchDown; - } - } -} diff --git a/source/src/Utils/Input/KeyboardUtils.ts b/source/src/Utils/Input/KeyboardUtils.ts deleted file mode 100644 index 1b984afb..00000000 --- a/source/src/Utils/Input/KeyboardUtils.ts +++ /dev/null @@ -1,47 +0,0 @@ -import Keys = es.Keys; - -class KeyboardUtils { - /** - * 当前帧按键状态 - */ - public static currentKeys: Keys[] = []; - /** - * 上一帧按键状态 - */ - public static previousKeys: Keys[] = []; - private static keyStatusKeys: Keys[] = []; - - public static init(): void { - document.addEventListener("keydown", KeyboardUtils.onKeyDownHandler); - document.addEventListener("keyup", KeyboardUtils.onKeyUpHandler); - } - - public static update(){ - KeyboardUtils.previousKeys.length = 0; - for (let key of KeyboardUtils.currentKeys){ - KeyboardUtils.previousKeys.push(key); - KeyboardUtils.currentKeys.remove(key); - } - KeyboardUtils.currentKeys.length = 0; - for (let key of KeyboardUtils.keyStatusKeys){ - KeyboardUtils.currentKeys.push(key); - } - } - - public static destroy(): void { - KeyboardUtils.currentKeys.length = 0; - - document.removeEventListener("keyup", KeyboardUtils.onKeyUpHandler); - document.removeEventListener("keypress", KeyboardUtils.onKeyDownHandler); - } - - private static onKeyDownHandler(event: KeyboardEvent): void { - if (!KeyboardUtils.keyStatusKeys.contains(event.keyCode)) - KeyboardUtils.keyStatusKeys.push(event.keyCode); - } - - private static onKeyUpHandler(event: KeyboardEvent): void { - if (KeyboardUtils.keyStatusKeys.contains(event.keyCode)) - KeyboardUtils.keyStatusKeys.remove(event.keyCode); - } -} \ No newline at end of file diff --git a/source/src/Utils/Input/Keys.ts b/source/src/Utils/Input/Keys.ts deleted file mode 100644 index 2e32a9a5..00000000 --- a/source/src/Utils/Input/Keys.ts +++ /dev/null @@ -1,116 +0,0 @@ -module es { - export enum Keys { - none, - back = 8, - tab = 9, - enter = 13, - capsLock = 20, - escape = 27, - space = 32, - pageUp = 33, - pageDown = 34, - end = 35, - home = 36, - left = 37, - up = 38, - right = 39, - down = 40, - select = 41, - print = 42, - execute = 43, - printScreen = 44, - insert = 45, - delete = 46, - help = 47, - d0 = 48, - d1 = 49, - d2 = 50, - d3 = 51, - d4 = 52, - d5 = 53, - d6 = 54, - d7 = 55, - d8 = 56, - d9 = 57, - a = 65, - b = 66, - c = 67, - d = 68, - e = 69, - f = 70, - g = 71, - h = 72, - i = 73, - j = 74, - k = 75, - l = 76, - m = 77, - n = 78, - o = 79, - p = 80, - q = 81, - r = 82, - s = 83, - t = 84, - u = 85, - v = 86, - w = 87, - x = 88, - y = 89, - z = 90, - leftWindows = 91, - rightWindows = 92, - apps = 93, - sleep = 95, - numPad0 = 96, - numPad1 = 97, - numPad2 = 98, - numPad3 = 99, - numPad4 = 100, - numPad5 = 101, - numPad6 = 102, - numPad7 = 103, - numPad8 = 104, - numPad9 = 105, - multiply = 106, - add = 107, - seperator = 108, - subtract = 109, - decimal = 110, - divide = 111, - f1 = 112, - f2 = 113, - f3 = 114, - f4 = 115, - f5 = 116, - f6 = 117, - f7 = 118, - f8 = 119, - f9 = 120, - f10 = 121, - f11 = 122, - f12 = 123, - f13 = 124, - f14 = 125, - f15 = 126, - f16 = 127, - f17 = 128, - f18 = 129, - f19 = 130, - f20 = 131, - f21 = 132, - f22 = 133, - f23 = 134, - f24 = 135, - numLock = 144, - scroll = 145, - leftShift = 160, - rightShift = 161, - leftControl = 162, - rightControl = 163, - leftAlt = 164, - rightAlt = 165, - browserBack = 166, - browserForward = 167 - } -} \ No newline at end of file diff --git a/source/src/Utils/Input/Virtual/VirtualAxis.ts b/source/src/Utils/Input/Virtual/VirtualAxis.ts deleted file mode 100644 index aa0e7be6..00000000 --- a/source/src/Utils/Input/Virtual/VirtualAxis.ts +++ /dev/null @@ -1,79 +0,0 @@ -/// -/// -module es { - /** - * 用-1和1之间的浮点数表示的虚拟输入 - */ - export class VirtualAxis extends VirtualInput { - public nodes: VirtualAxisNode[] = []; - - public get value() { - for (let i = 0; i < this.nodes.length; i++) { - let val = this.nodes[i].value; - if (val != 0) - return val; - } - - return 0; - } - - constructor(...nodes: VirtualAxisNode[]) { - super(); - this.nodes.concat(nodes); - } - - public update() { - for (let i = 0; i < this.nodes.length; i++) - this.nodes[i].update(); - } - } - - export class KeyboardKeys extends VirtualAxisNode { - public overlapBehavior: OverlapBehavior; - public positive: Keys; - public negative: Keys; - public _value: number = 0; - public _turned: boolean; - - constructor(overlapBehavior: OverlapBehavior, negative: Keys, positive: Keys) { - super(); - this.overlapBehavior = overlapBehavior; - this.negative = negative; - this.positive = positive; - } - - public update() { - if (Input.isKeyDown(this.positive)) { - if (Input.isKeyDown(this.negative)) { - switch (this.overlapBehavior) { - default: - case es.OverlapBehavior.cancelOut: - this._value = 0; - break; - case es.OverlapBehavior.takeNewer: - if (!this._turned) { - this._value *= -1; - this._turned = true; - } - break; - case es.OverlapBehavior.takeOlder: - break; - } - } else { - this._turned = false; - this._value = 1; - } - } else if (Input.isKeyDown(this.negative)) { - this._turned = false; - this._value = -1; - } else { - this._turned = false; - this._value = 0; - } - } - - public get value(){ - return this._value; - } - } -} \ No newline at end of file diff --git a/source/src/Utils/Input/Virtual/VirtualButton.ts b/source/src/Utils/Input/Virtual/VirtualButton.ts deleted file mode 100644 index 3c2db342..00000000 --- a/source/src/Utils/Input/Virtual/VirtualButton.ts +++ /dev/null @@ -1,134 +0,0 @@ -/// -module es { - /** - * 用布尔值表示的虚拟输入。除了简单地检查当前按钮状态, - * 您还可以询问它是否刚刚被按下或释放了这个框架。 - * 您还可以将按下的按钮存储在缓冲区中一段有限的时间,或者直到调用consumeBuffer()将其使用为止。 - */ - export class VirtualButton extends VirtualInput{ - public nodes: Node[] = []; - public bufferTime: number = 0; - public firstRepeatTime: number = 0; - public mutiRepeatTime: number = 0; - public isRepeating: boolean; - - public _bufferCounter: number = 0; - public _repeatCounter: number = 0; - public _willRepeat: boolean; - - constructor(bufferTime: number = 0, ...nodes: Node[]){ - super(); - this.nodes = nodes; - this.bufferTime = bufferTime; - } - - public setRepeat(firstRepeatTime: number, mutiRepeatTime: number = firstRepeatTime){ - this.firstRepeatTime = firstRepeatTime; - this.mutiRepeatTime = mutiRepeatTime; - this._willRepeat = this.firstRepeatTime > 0; - if (!this._willRepeat) - this.isRepeating = false; - } - - public update() { - this._bufferCounter -= Time.unscaledDeltaTime; - this.isRepeating = false; - - let check = false; - for (let i = 0; i < this.nodes.length; i ++){ - this.nodes[i].update(); - if (this.nodes[i].isPressed){ - this._bufferCounter = this.bufferTime; - check = true; - }else if(this.nodes[i].isDown){ - check = true; - } - } - - if (!check){ - this._repeatCounter = 0; - this._bufferCounter = 0; - }else if(this._willRepeat){ - if (this._repeatCounter == 0){ - this._repeatCounter = this.firstRepeatTime; - }else{ - this._repeatCounter -= Time.unscaledDeltaTime; - if (this._repeatCounter <= 0){ - this.isRepeating = true; - this._repeatCounter = this.mutiRepeatTime; - } - } - } - } - - public get isDown(){ - for (let node of this.nodes){ - if (node.isDown) - return true; - } - - return false; - } - - public get isPressed(){ - if (this._bufferCounter > 0 || this.isRepeating) - return true; - - for (let node of this.nodes){ - if (node.isPressed) - return true; - } - - return false; - } - - public get isReleased(){ - for (let node of this.nodes){ - if (node.isReleased) - return true; - } - return false; - } - - public consumeBuffer(){ - this._bufferCounter = 0; - } - - /** - * 添加一个键盘键到这个虚拟按钮 - * @param key - */ - public addKeyboardKey(key: Keys): VirtualButton{ - this.nodes.push(new KeyboardKey(key)); - return this; - } - } - - export abstract class Node extends VirtualInputNode { - public abstract isDown: boolean; - public abstract isPressed: boolean; - public abstract isReleased: boolean; - } - - export class KeyboardKey extends Node { - public key: Keys; - - constructor(key: Keys){ - super(); - - this.key = key; - } - - public get isDown(){ - return Input.isKeyDown(this.key); - } - - public get isPressed(){ - return Input.isKeyPressed(this.key); - } - - public get isReleased(){ - return Input.isKeyReleased(this.key); - } - } -} \ No newline at end of file diff --git a/source/src/Utils/Input/Virtual/VirtualInput.ts b/source/src/Utils/Input/Virtual/VirtualInput.ts deleted file mode 100644 index a4973873..00000000 --- a/source/src/Utils/Input/Virtual/VirtualInput.ts +++ /dev/null @@ -1,43 +0,0 @@ -module es { - export enum OverlapBehavior { - /** - * 重复的输入将导致相互抵消,并且不会记录任何输入。 - * 例如:按左箭头键,按住时按右箭头键。这将导致相互抵消。 - */ - cancelOut, - /** - * 将使用找到的第一个输入 - */ - takeOlder, - /** - * 将使用找到的最后一个输入 - */ - takeNewer, - } - - /** - * 虚拟按钮,其状态由其VirtualInputNodes的状态决定 - */ - export abstract class VirtualInput { - protected constructor() { - Input._virtualInputs.push(this); - } - - /** - * 从输入系统取消虚拟输入的注册。在轮询VirtualInput之后调用这个函数 - */ - public deregister(){ - Input._virtualInputs.remove(this); - } - - public abstract update(); - } - - /** - * 将它们添加到您的VirtualInput中,以定义它如何确定当前输入状态。 - * 例如,如果你想检查一个键盘键是否被按下,创建一个VirtualButton并添加一个VirtualButton.keyboardkey - */ - export abstract class VirtualInputNode { - public update() {} - } -} \ No newline at end of file diff --git a/source/src/Utils/Input/Virtual/VirtualIntegerAxis.ts b/source/src/Utils/Input/Virtual/VirtualIntegerAxis.ts deleted file mode 100644 index a1bff4cb..00000000 --- a/source/src/Utils/Input/Virtual/VirtualIntegerAxis.ts +++ /dev/null @@ -1,44 +0,0 @@ -module es { - /** - * 用int(-1、0或1)表示的虚拟输入。它对应的输入可以从上到下到下, - * 如使用两个键盘键作为正/负检查。 - */ - export class VirtualIntegerAxis extends VirtualInput { - public nodes: VirtualAxisNode[] = []; - - public get value(){ - for (let i = 0; i < this.nodes.length; i ++){ - let val = this.nodes[i].value; - if (val != 0) - return Math.sign(val); - } - - return 0; - } - - constructor(...nodes: VirtualAxisNode[]){ - super(); - this.nodes.concat(nodes); - } - - public update() { - for (let i = 0; i < this.nodes.length; i ++) - this.nodes[i].update(); - } - - /** - * 添加键盘键来模拟这个虚拟输入的左/右或上/下 - * @param overlapBehavior - * @param negative - * @param positive - */ - public addKeyboardKeys(overlapBehavior: OverlapBehavior, negative: Keys, positive: Keys){ - this.nodes.push(new KeyboardKeys(overlapBehavior, negative, positive)); - return this; - } - } - - export abstract class VirtualAxisNode extends VirtualInputNode { - public abstract value: number; - } -} \ No newline at end of file diff --git a/source/src/Utils/Pool.ts b/source/src/Utils/Pool.ts index 1ffc7144..c3be4fd7 100644 --- a/source/src/Utils/Pool.ts +++ b/source/src/Utils/Pool.ts @@ -52,7 +52,7 @@ module es { public static free(obj: T) { this._objectQueue.unshift(obj); - if (egret.is(obj, "IPoolable")){ + if (isIPoolable(obj)){ obj["reset"](); } } @@ -64,4 +64,6 @@ module es { */ reset(); } + + export var isIPoolable = (props: any): props is IPoolable => typeof (props as IPoolable)['js'] !== 'undefined'; } \ No newline at end of file diff --git a/source/src/Utils/RuntimeSpriteSheet/AssetPacker.ts b/source/src/Utils/RuntimeSpriteSheet/AssetPacker.ts deleted file mode 100644 index 4007fbc5..00000000 --- a/source/src/Utils/RuntimeSpriteSheet/AssetPacker.ts +++ /dev/null @@ -1,133 +0,0 @@ -module es { - import Bitmap = egret.Bitmap; - - export class AssetPacker { - protected itemsToRaster: TextureToPack[] = []; - public onProcessCompleted: Function; - public useCache: boolean = false; - public cacheName: string = ""; - - protected _sprites: Map = new Map(); - protected allow4096Textures = false; - - public addTextureToPack(texture: egret.Texture, customID: string){ - this.itemsToRaster.push(new TextureToPack(texture, customID)); - } - - public async process(allow4096Textures: boolean = false){ - this.allow4096Textures = allow4096Textures; - if (this.useCache){ - if (this.cacheName == "") { - console.error("未指定缓存名称"); - return; - } - - let cacheExist = await RES.getResByUrl(this.cacheName); - - if (!cacheExist) - this.createPack(); - else - this.loadPack(); - }else{ - this.createPack(); - } - } - - protected async loadPack() { - let loaderTexture = await RES.getResByUrl(this.cacheName); - if (this.onProcessCompleted) this.onProcessCompleted(); - return loaderTexture; - } - - protected createPack(){ - let textures: egret.Bitmap[] = []; - let images = []; - - for (let itemToRaster of this.itemsToRaster){ - textures.push(new Bitmap(itemToRaster.texture)); - images.push(itemToRaster.id); - } - - let textureSize = this.allow4096Textures ? 4096 : 2048; - - let rectangles = []; - for (let i = 0; i < textures.length; i ++){ - if (textures[i].width > textureSize || textures[i].height > textureSize){ - throw new Error("一个纹理的大小比图集的大小大"); - }else{ - rectangles.push(new Rectangle(0, 0, textures[i].width, textures[i].height)); - } - } - - const padding = 1; - let numSpriteSheet = 0; - while (rectangles.length > 0){ - let texture = new egret.RenderTexture(); - - let packer: RectanglePacker = new RectanglePacker(textureSize, textureSize, padding); - for (let i = 0; i < rectangles.length; i ++) - packer.insertRectangle(Math.floor(rectangles[i].width), Math.floor(rectangles[i].height), i); - - packer.packRectangles(); - - if (packer.rectangleCount > 0){ - let rect = new IntegerRectangle(); - let textureAssets: TextureAsset[] = []; - let garbageRect: Rectangle[] = []; - let garabeTextures: egret.Texture[] = []; - let garbageImages: string[] = []; - - for (let j = 0; j < packer.rectangleCount; j ++){ - rect = packer.getRectangle(j, rect); - let index = packer.getRectangleId(j); - texture.drawToTexture(textures[index], new Rectangle(rect.x, rect.y, rect.width, rect.height)); - - let textureAsset: TextureAsset = new TextureAsset(); - textureAsset.x = rect.x; - textureAsset.y = rect.y; - textureAsset.width = rect.width; - textureAsset.height = rect.height; - textureAsset.name = images[index]; - - textureAssets.push(textureAsset); - - garbageRect.push(rectangles[index]); - garabeTextures.push(textures[index].texture); - garbageImages.push(images[index]); - } - - for (let garbage of garbageRect) - rectangles.remove(garbage); - - for (let garbage of garabeTextures) - textures.removeAll(a => {return a.texture.hashCode == garbage.hashCode}); - - for (let garbage of garbageImages) - images.remove(garbage); - - if (this.cacheName != ""){ - texture.saveToFile("image/png", this.cacheName); - ++ numSpriteSheet; - } - - for (let textureAsset of textureAssets) - this._sprites.set(textureAsset.name, texture); - } - } - - if (this.onProcessCompleted) this.onProcessCompleted(); - } - - public dispose(){ - this._sprites.forEach((asset, name) => { - asset.dispose(); - RES.destroyRes(name); - }); - this._sprites.clear(); - } - - public getTexture(id: string){ - return this._sprites.get(id); - } - } -} \ No newline at end of file diff --git a/source/src/Utils/RuntimeSpriteSheet/IntegerRectangle.ts b/source/src/Utils/RuntimeSpriteSheet/IntegerRectangle.ts deleted file mode 100644 index 7f8679e5..00000000 --- a/source/src/Utils/RuntimeSpriteSheet/IntegerRectangle.ts +++ /dev/null @@ -1,9 +0,0 @@ -module es { - /** - * 类中用于存储矩形值的矩形封装器 - * ID参数需要连接矩形和原来插入的矩形 - */ - export class IntegerRectangle extends Rectangle{ - public id: number; - } -} \ No newline at end of file diff --git a/source/src/Utils/RuntimeSpriteSheet/RectanglePacker.ts b/source/src/Utils/RuntimeSpriteSheet/RectanglePacker.ts deleted file mode 100644 index a3e5b4cc..00000000 --- a/source/src/Utils/RuntimeSpriteSheet/RectanglePacker.ts +++ /dev/null @@ -1,278 +0,0 @@ -module es { - /** - * 类用于在容器矩形内包装矩形,并具有接近最优解。 - */ - export class RectanglePacker { - private _width: number = 0; - private _height: number = 0; - private _padding: number = 8; - - private _packedWidth = 0; - private _packedHeight = 0; - - private _insertList: SortableSize[] = []; - private _insertedRectangles: IntegerRectangle[] = []; - private _freeAreas: IntegerRectangle[] = []; - private _newFreeAreas: IntegerRectangle[] = []; - - private _outsideRectangle: IntegerRectangle; - - private _sortableSizeStack: SortableSize[] = []; - private _rectangleStack: IntegerRectangle[] = []; - - public get rectangleCount() { - return this._insertedRectangles.length; - } - - public get packedWidth() { - return this._packedWidth; - } - - public get packedHeight() { - return this._packedHeight; - } - - public get padding() { - return this._padding; - } - - constructor(width: number, height: number, padding: number = 0) { - this._outsideRectangle = new IntegerRectangle(width + 1, height + 1, 0, 0); - this.reset(width, height, padding); - } - - public reset(width: number, height: number, padding: number = 0) { - while (this._insertedRectangles.length > 0) - this.freeRectangle(this._insertedRectangles.pop()); - - while (this._freeAreas.length > 0) - this.freeRectangle(this._freeAreas.pop()); - - this._width = width; - this._height = height; - - this._packedWidth = 0; - this._packedHeight = 0; - - this._freeAreas.push(this.allocateRectangle(0, 0, this._width, this._height)); - - while (this._insertedRectangles.length > 0) - this.freeSize(this._insertList.pop()); - - this._padding = padding; - } - - public insertRectangle(width: number, height: number, id: number) { - let sortableSize = this.allocateSize(width, height, id); - this._insertList.push(sortableSize); - } - - public packRectangles(sort: boolean = true) { - if (sort) - this._insertList.sort((emp1, emp2) => { - return emp1.width - emp2.width; - }); - - while (this._insertList.length > 0) { - let sortableSize = this._insertList.pop(); - let width = sortableSize.width; - let height = sortableSize.height; - - let index = this.getFreeAreaIndex(width, height); - if (index >= 0) { - let freeArea = this._freeAreas[index]; - let target = this.allocateRectangle(freeArea.x, freeArea.y, width, height); - target.id = sortableSize.id; - - this.generateNewFreeAreas(target, this._freeAreas, this._newFreeAreas); - - while (this._newFreeAreas.length > 0) - this._freeAreas.push(this._newFreeAreas.pop()); - - this._insertedRectangles.push(target); - - if (target.right > this._packedWidth) - this._packedWidth = target.right; - - if (target.bottom > this._packedHeight) - this._packedHeight = target.bottom; - } - - this.freeSize(sortableSize); - } - - return this.rectangleCount; - } - - public getRectangle(index: number, rectangle: IntegerRectangle){ - let inserted = this._insertedRectangles[index]; - rectangle.x = inserted.x; - rectangle.y = inserted.y; - rectangle.width = inserted.width; - rectangle.height = inserted.height; - - return rectangle; - } - - public getRectangleId(index: number){ - let inserted = this._insertedRectangles[index]; - return inserted.id; - } - - private generateNewFreeAreas(target: IntegerRectangle, areas: IntegerRectangle[], results: IntegerRectangle[]) { - let x = target.x; - let y = target.y; - let right = target.right + 1 + this._padding; - let bottom = target.bottom + 1 + this._padding; - - let targetWithPadding: IntegerRectangle = null; - if (this._padding == 0) - targetWithPadding = target; - - for (let i = areas.length - 1; i >= 0; i --){ - let area = areas[i]; - if (!(x >= area.right || right <= area.x || y >= area.bottom || bottom <= area.y)){ - if (targetWithPadding == null) - targetWithPadding = this.allocateRectangle(target.x, target.y, target.width + this._padding, target.height + this._padding); - - this.generateDividedAreas(targetWithPadding, area, results); - let topOfStack = areas.pop(); - if (i < areas.length){ - areas[i] = topOfStack; - } - } - } - - if (targetWithPadding != null && targetWithPadding != target) - this.freeRectangle(targetWithPadding); - - this.filterSelfSubAreas(results); - } - - private filterSelfSubAreas(areas: IntegerRectangle[]){ - for (let i = areas.length - 1; i >= 0; i --){ - let filtered = areas[i]; - for (let j = areas.length - 1; j >= 0; j --){ - if (i != j){ - let area = areas[j]; - if (filtered.x >= area.x && filtered.y >= area.y && filtered.right <= area.right && filtered.bottom <= area.bottom){ - this.freeRectangle(filtered); - let topOfStack = areas.pop(); - if (i < areas.length){ - areas[i] = topOfStack; - } - break; - } - } - } - } - } - - private generateDividedAreas(divider: IntegerRectangle, area: IntegerRectangle, results: IntegerRectangle[]){ - let count = 0; - - let rightDelta = area.right - divider.right; - if (rightDelta > 0){ - results.push(this.allocateRectangle(divider.right, area.y, rightDelta, area.height)); - count ++; - } - - let leftDelta = divider.x - area.x; - if (leftDelta > 0){ - results.push(this.allocateRectangle(area.x, area.y, leftDelta, area.height)); - count ++; - } - - let bottomDelta = area.bottom - divider.bottom; - if (bottomDelta > 0){ - results.push(this.allocateRectangle(area.x, divider.bottom, area.width, bottomDelta)); - count ++; - } - - let topDelta = divider.y - area.y; - if (topDelta > 0){ - results.push(this.allocateRectangle(area.x, area.y, area.width, topDelta)); - count ++; - } - - if (count == 0 && (divider.width < area.width || divider.height < area.height)){ - results.push(area); - }else{ - this.freeRectangle(area); - } - } - - private getFreeAreaIndex(width: number, height: number) { - let best = this._outsideRectangle; - let index = -1; - - let paddedWidth = width + this._padding; - let paddedHeight = height + this._padding; - - let count = this._freeAreas.length; - for (let i = count - 1; i >= 0; i--) { - let free = this._freeAreas[i]; - if (free.x < this._packedWidth || free.y < this.packedHeight) { - if (free.x < best.x && paddedWidth <= free.width && paddedHeight <= free.height) { - index = i; - if ((paddedWidth == free.width && free.width <= free.height && free.right < this._width) || - (paddedHeight == free.height && free.height <= free.width)) { - break; - } - - best = free; - } - } else { - if (free.x < best.x && width <= free.width && height <= free.height) { - index = i; - if ((width == free.width && free.width <= free.height && free.right < this._width) || - (height == free.height && free.height <= free.width)) { - break; - } - - best = free; - } - } - } - - return index; - } - - private allocateSize(width: number, height: number, id: number): SortableSize { - if (this._sortableSizeStack.length > 0) { - let size: SortableSize = this._sortableSizeStack.pop(); - size.width = width; - size.height = height; - size.id = id; - - return size; - } - - return new SortableSize(width, height, id); - } - - private freeSize(size: SortableSize) { - this._sortableSizeStack.push(size); - } - - private allocateRectangle(x: number, y: number, width: number, height: number) { - if (this._rectangleStack.length > 0) { - let rectangle = this._rectangleStack.pop(); - rectangle.x = x; - rectangle.y = y; - rectangle.width = width; - rectangle.height = height; - rectangle.right = x + width; - rectangle.bottom = y + height; - - return rectangle; - } - - return new IntegerRectangle(x, y, width, height); - } - - private freeRectangle(rectangle: IntegerRectangle) { - this._rectangleStack.push(rectangle); - } - } -} \ No newline at end of file diff --git a/source/src/Utils/RuntimeSpriteSheet/SortableSize.ts b/source/src/Utils/RuntimeSpriteSheet/SortableSize.ts deleted file mode 100644 index 5200b8f9..00000000 --- a/source/src/Utils/RuntimeSpriteSheet/SortableSize.ts +++ /dev/null @@ -1,16 +0,0 @@ -module es { - /** - * 用于根据维度对插入的矩形进行排序 - */ - export class SortableSize { - public width: number; - public height: number; - public id: number; - - constructor(width: number, height: number, id: number){ - this.width = width; - this.height = height; - this.id = id; - } - } -} \ No newline at end of file diff --git a/source/src/Utils/RuntimeSpriteSheet/TextureAssets.ts b/source/src/Utils/RuntimeSpriteSheet/TextureAssets.ts deleted file mode 100644 index 58637478..00000000 --- a/source/src/Utils/RuntimeSpriteSheet/TextureAssets.ts +++ /dev/null @@ -1,16 +0,0 @@ -module es { - export class TextureAssets { - public assets: TextureAsset[]; - constructor(assets: TextureAsset[]){ - this.assets = assets; - } - } - - export class TextureAsset { - public x: number; - public y: number; - public width: number; - public height: number; - public name: string; - } -} \ No newline at end of file diff --git a/source/src/Utils/RuntimeSpriteSheet/TextureToPack.ts b/source/src/Utils/RuntimeSpriteSheet/TextureToPack.ts deleted file mode 100644 index 19b7ff05..00000000 --- a/source/src/Utils/RuntimeSpriteSheet/TextureToPack.ts +++ /dev/null @@ -1,11 +0,0 @@ -module es { - export class TextureToPack { - public texture: egret.Texture; - public id: string; - - constructor(texture: egret.Texture, id: string){ - this.texture = texture; - this.id = id; - } - } -} \ No newline at end of file