update
This commit is contained in:
Submodule engine_support/egret updated: 56a668a551...ac5e49f6e9
26
source/bin/framework.d.ts
vendored
26
source/bin/framework.d.ts
vendored
@@ -167,7 +167,8 @@ declare module es {
|
|||||||
resolutionScale = 8,
|
resolutionScale = 8,
|
||||||
resolutionOffset = 9,
|
resolutionOffset = 9,
|
||||||
createRenderTarget = 10,
|
createRenderTarget = 10,
|
||||||
createCamera = 11
|
createCamera = 11,
|
||||||
|
rendererSizeChanged = 12
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
declare module es {
|
declare module es {
|
||||||
@@ -568,7 +569,8 @@ declare module es {
|
|||||||
readonly _sceneComponents: SceneComponent[];
|
readonly _sceneComponents: SceneComponent[];
|
||||||
_renderers: IRenderer[];
|
_renderers: IRenderer[];
|
||||||
readonly _afterPostProcessorRenderers: IRenderer[];
|
readonly _afterPostProcessorRenderers: IRenderer[];
|
||||||
_didSceneBegin: boolean;
|
private _didSceneBegin;
|
||||||
|
private currentRenderId;
|
||||||
/**
|
/**
|
||||||
* 设置新场景将使用的默认设计尺寸和分辨率策略,水平/垂直Bleed仅与BestFit相关
|
* 设置新场景将使用的默认设计尺寸和分辨率策略,水平/垂直Bleed仅与BestFit相关
|
||||||
* @param width
|
* @param width
|
||||||
@@ -713,7 +715,7 @@ declare module es {
|
|||||||
clean = 0,
|
clean = 0,
|
||||||
positionDirty = 1,
|
positionDirty = 1,
|
||||||
scaleDirty = 2,
|
scaleDirty = 2,
|
||||||
rotationDirty = 3
|
rotationDirty = 4
|
||||||
}
|
}
|
||||||
class Transform {
|
class Transform {
|
||||||
/** 与此转换关联的实体 */
|
/** 与此转换关联的实体 */
|
||||||
@@ -1376,18 +1378,19 @@ declare module es {
|
|||||||
* 非常重要!子类必须覆盖width/height或bounds! 子类必须覆盖width/height或bounds!
|
* 非常重要!子类必须覆盖width/height或bounds! 子类必须覆盖width/height或bounds!
|
||||||
*/
|
*/
|
||||||
abstract class RenderableComponent extends Component implements IRenderable, IComparer<RenderableComponent> {
|
abstract class RenderableComponent extends Component implements IRenderable, IComparer<RenderableComponent> {
|
||||||
|
static renderIdGenerator: number;
|
||||||
/**
|
/**
|
||||||
* 不重写bounds属性的子类必须实现这个!RenderableComponent的宽度。
|
* 不重写bounds属性的子类必须实现这个!RenderableComponent的宽度。
|
||||||
*/
|
*/
|
||||||
readonly width: number;
|
abstract readonly width: any;
|
||||||
/**
|
/**
|
||||||
* 不重写bounds属性的子类必须实现这个!
|
* 不重写bounds属性的子类必须实现这个!
|
||||||
*/
|
*/
|
||||||
readonly height: number;
|
abstract readonly height: any;
|
||||||
/**
|
/**
|
||||||
* 包裹此对象的AABB。用来进行相机筛选。
|
* 包裹此对象的AABB。用来进行相机筛选。
|
||||||
*/
|
*/
|
||||||
readonly bounds: Rectangle;
|
abstract readonly bounds: any;
|
||||||
/**
|
/**
|
||||||
* 标准的Batcher图层深度,0为前面,1为后面。
|
* 标准的Batcher图层深度,0为前面,1为后面。
|
||||||
* 改变这个值会触发场景中可渲染组件列表的排序。
|
* 改变这个值会触发场景中可渲染组件列表的排序。
|
||||||
@@ -1398,6 +1401,10 @@ declare module es {
|
|||||||
* 请注意,这意味着更高的renderLayers首先被发送到Batcher。
|
* 请注意,这意味着更高的renderLayers首先被发送到Batcher。
|
||||||
*/
|
*/
|
||||||
renderLayer: number;
|
renderLayer: number;
|
||||||
|
/**
|
||||||
|
* 渲染时传递给批处理程序的颜色
|
||||||
|
*/
|
||||||
|
color: number;
|
||||||
/**
|
/**
|
||||||
* 由渲染器使用,用于指定该精灵的渲染方式
|
* 由渲染器使用,用于指定该精灵的渲染方式
|
||||||
*/
|
*/
|
||||||
@@ -1411,6 +1418,7 @@ declare module es {
|
|||||||
* 状态的改变最终会调用onBecameVisible/onBecameInvisible方法
|
* 状态的改变最终会调用onBecameVisible/onBecameInvisible方法
|
||||||
*/
|
*/
|
||||||
isVisible: boolean;
|
isVisible: boolean;
|
||||||
|
constructor();
|
||||||
debugRenderEnabled: boolean;
|
debugRenderEnabled: boolean;
|
||||||
protected _localOffset: Vector2;
|
protected _localOffset: Vector2;
|
||||||
protected _layerDepth: number;
|
protected _layerDepth: number;
|
||||||
@@ -1794,6 +1802,7 @@ declare module es {
|
|||||||
private _unsortedRenderLayers;
|
private _unsortedRenderLayers;
|
||||||
private _componentsNeedSort;
|
private _componentsNeedSort;
|
||||||
readonly count: number;
|
readonly count: number;
|
||||||
|
readonly buffer: IRenderable[];
|
||||||
get(index: number): IRenderable;
|
get(index: number): IRenderable;
|
||||||
add(component: IRenderable): void;
|
add(component: IRenderable): void;
|
||||||
remove(component: IRenderable): void;
|
remove(component: IRenderable): void;
|
||||||
@@ -2003,7 +2012,7 @@ declare module es {
|
|||||||
*/
|
*/
|
||||||
shouldRoundDestinations: boolean;
|
shouldRoundDestinations: boolean;
|
||||||
disposed(): any;
|
disposed(): any;
|
||||||
begin(effect: any, transformationMatrix?: Matrix, disableBatching?: boolean): any;
|
begin(id: Ref<number>, effect: any, transformationMatrix?: Matrix, disableBatching?: boolean): any;
|
||||||
end(): any;
|
end(): any;
|
||||||
prepRenderState(): any;
|
prepRenderState(): any;
|
||||||
/**
|
/**
|
||||||
@@ -2013,10 +2022,7 @@ declare module es {
|
|||||||
drawHollowRect(rect: Rectangle, color: number, thickness?: number): any;
|
drawHollowRect(rect: Rectangle, color: number, thickness?: number): any;
|
||||||
drawHollowBounds(x: number, y: number, width: number, height: number, color: number, thickness: number): any;
|
drawHollowBounds(x: number, y: number, width: number, height: number, color: number, thickness: number): any;
|
||||||
drawLine(start: Vector2, end: Vector2, color: number, thickness: any): any;
|
drawLine(start: Vector2, end: Vector2, color: number, thickness: any): any;
|
||||||
drawLineAngle(start: Vector2, radians: number, length: number, color: number, thickness: number): any;
|
|
||||||
draw(texture: any, position: Vector2, color?: number, rotation?: number, origin?: Vector2, scale?: Vector2, effects?: any): any;
|
draw(texture: any, position: Vector2, color?: number, rotation?: number, origin?: Vector2, scale?: Vector2, effects?: any): any;
|
||||||
flushBatch(): any;
|
|
||||||
drawPrimitives(texture: any, baseSprite: number, batchSize: number): any;
|
|
||||||
drawPixel(position: Vector2, color: number, size?: number): any;
|
drawPixel(position: Vector2, color: number, size?: number): any;
|
||||||
drawPolygon(position: Vector2, points: Vector2[], color: number, closePoly?: boolean, thickness?: number): any;
|
drawPolygon(position: Vector2, points: Vector2[], color: number, closePoly?: boolean, thickness?: number): any;
|
||||||
drawCircle(position: Vector2, radius: number, color: number, thickness?: number, resolution?: number): any;
|
drawCircle(position: Vector2, radius: number, color: number, thickness?: number, resolution?: number): any;
|
||||||
|
|||||||
@@ -381,6 +381,7 @@ var es;
|
|||||||
CoreEvents[CoreEvents["resolutionOffset"] = 9] = "resolutionOffset";
|
CoreEvents[CoreEvents["resolutionOffset"] = 9] = "resolutionOffset";
|
||||||
CoreEvents[CoreEvents["createRenderTarget"] = 10] = "createRenderTarget";
|
CoreEvents[CoreEvents["createRenderTarget"] = 10] = "createRenderTarget";
|
||||||
CoreEvents[CoreEvents["createCamera"] = 11] = "createCamera";
|
CoreEvents[CoreEvents["createCamera"] = 11] = "createCamera";
|
||||||
|
CoreEvents[CoreEvents["rendererSizeChanged"] = 12] = "rendererSizeChanged";
|
||||||
})(CoreEvents = es.CoreEvents || (es.CoreEvents = {}));
|
})(CoreEvents = es.CoreEvents || (es.CoreEvents = {}));
|
||||||
})(es || (es = {}));
|
})(es || (es = {}));
|
||||||
var es;
|
var es;
|
||||||
@@ -1139,6 +1140,7 @@ var es;
|
|||||||
this._sceneComponents = [];
|
this._sceneComponents = [];
|
||||||
this._renderers = [];
|
this._renderers = [];
|
||||||
this._afterPostProcessorRenderers = [];
|
this._afterPostProcessorRenderers = [];
|
||||||
|
this.currentRenderId = new es.Ref(null);
|
||||||
this.entities = new es.EntityList(this);
|
this.entities = new es.EntityList(this);
|
||||||
this.renderableComponents = new es.RenderableComponentList();
|
this.renderableComponents = new es.RenderableComponentList();
|
||||||
this.entityProcessors = new es.EntityProcessorList();
|
this.entityProcessors = new es.EntityProcessorList();
|
||||||
@@ -1385,8 +1387,8 @@ var es;
|
|||||||
var currentRenderTarget = es.MathHelper.isEven(enabledCounter) ? this._sceneRenderTarget : this._destinationRenderTarget;
|
var currentRenderTarget = es.MathHelper.isEven(enabledCounter) ? this._sceneRenderTarget : this._destinationRenderTarget;
|
||||||
es.Framework.emitter.emit(es.CoreEvents.setRenderTarget, finalRenderTarget);
|
es.Framework.emitter.emit(es.CoreEvents.setRenderTarget, finalRenderTarget);
|
||||||
es.Framework.emitter.emit(es.CoreEvents.clearGraphics);
|
es.Framework.emitter.emit(es.CoreEvents.clearGraphics);
|
||||||
es.Framework.batcher.begin(null);
|
es.Framework.batcher.begin(this.currentRenderId, null);
|
||||||
es.Framework.batcher.draw(currentRenderTarget, new es.Vector2(this._finalRenderDestinationRect.x, this._finalRenderDestinationRect.y), 0xffffff, 0, es.Vector2.zero, new es.Vector2(this._finalRenderDestinationRect.width, this._finalRenderDestinationRect.height));
|
es.Framework.batcher.draw(currentRenderTarget.value, new es.Vector2(this._finalRenderDestinationRect.x, this._finalRenderDestinationRect.y), 0xffffff, 0, es.Vector2.zero, new es.Vector2(this._finalRenderDestinationRect.width, this._finalRenderDestinationRect.height));
|
||||||
es.Framework.batcher.end();
|
es.Framework.batcher.end();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -1453,6 +1455,8 @@ var es;
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
renderer.onAddedToScene(this);
|
renderer.onAddedToScene(this);
|
||||||
|
if (this._didSceneBegin)
|
||||||
|
es.Framework.emitter.emit(es.CoreEvents.rendererSizeChanged, this._sceneRenderTarget.value);
|
||||||
return renderer;
|
return renderer;
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
@@ -1475,12 +1479,14 @@ var es;
|
|||||||
* @param renderer
|
* @param renderer
|
||||||
*/
|
*/
|
||||||
Scene.prototype.removeRenderer = function (renderer) {
|
Scene.prototype.removeRenderer = function (renderer) {
|
||||||
es.Insist.isTrue(new linq.List(this._renderers).contains(renderer) ||
|
var afterProcessLinqList = new linq.List(this._afterPostProcessorRenderers);
|
||||||
new linq.List(this._afterPostProcessorRenderers).contains(renderer));
|
var rendererLinqList = new linq.List(this._renderers);
|
||||||
|
es.Insist.isTrue(rendererLinqList.contains(renderer) ||
|
||||||
|
afterProcessLinqList.contains(renderer));
|
||||||
if (renderer.wantsToRenderAfterPostProcessors)
|
if (renderer.wantsToRenderAfterPostProcessors)
|
||||||
new linq.List(this._afterPostProcessorRenderers).remove(renderer);
|
afterProcessLinqList.remove(renderer);
|
||||||
else
|
else
|
||||||
new linq.List(this._renderers).remove(renderer);
|
rendererLinqList.remove(renderer);
|
||||||
renderer.unload();
|
renderer.unload();
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
@@ -1597,7 +1603,7 @@ var es;
|
|||||||
DirtyType[DirtyType["clean"] = 0] = "clean";
|
DirtyType[DirtyType["clean"] = 0] = "clean";
|
||||||
DirtyType[DirtyType["positionDirty"] = 1] = "positionDirty";
|
DirtyType[DirtyType["positionDirty"] = 1] = "positionDirty";
|
||||||
DirtyType[DirtyType["scaleDirty"] = 2] = "scaleDirty";
|
DirtyType[DirtyType["scaleDirty"] = 2] = "scaleDirty";
|
||||||
DirtyType[DirtyType["rotationDirty"] = 3] = "rotationDirty";
|
DirtyType[DirtyType["rotationDirty"] = 4] = "rotationDirty";
|
||||||
})(DirtyType = es.DirtyType || (es.DirtyType = {}));
|
})(DirtyType = es.DirtyType || (es.DirtyType = {}));
|
||||||
var Transform = /** @class */ (function () {
|
var Transform = /** @class */ (function () {
|
||||||
function Transform(entity) {
|
function Transform(entity) {
|
||||||
@@ -3077,45 +3083,17 @@ var es;
|
|||||||
var RenderableComponent = /** @class */ (function (_super) {
|
var RenderableComponent = /** @class */ (function (_super) {
|
||||||
__extends(RenderableComponent, _super);
|
__extends(RenderableComponent, _super);
|
||||||
function RenderableComponent() {
|
function RenderableComponent() {
|
||||||
var _this = _super !== null && _super.apply(this, arguments) || this;
|
var _this = _super.call(this) || this;
|
||||||
|
/**
|
||||||
|
* 渲染时传递给批处理程序的颜色
|
||||||
|
*/
|
||||||
|
_this.color = 0xffffff;
|
||||||
_this.debugRenderEnabled = true;
|
_this.debugRenderEnabled = true;
|
||||||
|
_this._localOffset = es.Vector2.zero;
|
||||||
|
_this._bounds = es.Rectangle.empty;
|
||||||
_this._areBoundsDirty = true;
|
_this._areBoundsDirty = true;
|
||||||
return _this;
|
return _this;
|
||||||
}
|
}
|
||||||
Object.defineProperty(RenderableComponent.prototype, "width", {
|
|
||||||
/**
|
|
||||||
* 不重写bounds属性的子类必须实现这个!RenderableComponent的宽度。
|
|
||||||
*/
|
|
||||||
get: function () {
|
|
||||||
return this.bounds.width;
|
|
||||||
},
|
|
||||||
enumerable: true,
|
|
||||||
configurable: true
|
|
||||||
});
|
|
||||||
Object.defineProperty(RenderableComponent.prototype, "height", {
|
|
||||||
/**
|
|
||||||
* 不重写bounds属性的子类必须实现这个!
|
|
||||||
*/
|
|
||||||
get: function () {
|
|
||||||
return this.bounds.height;
|
|
||||||
},
|
|
||||||
enumerable: true,
|
|
||||||
configurable: true
|
|
||||||
});
|
|
||||||
Object.defineProperty(RenderableComponent.prototype, "bounds", {
|
|
||||||
/**
|
|
||||||
* 包裹此对象的AABB。用来进行相机筛选。
|
|
||||||
*/
|
|
||||||
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, "layerDepth", {
|
Object.defineProperty(RenderableComponent.prototype, "layerDepth", {
|
||||||
/**
|
/**
|
||||||
* 标准的Batcher图层深度,0为前面,1为后面。
|
* 标准的Batcher图层深度,0为前面,1为后面。
|
||||||
@@ -3282,6 +3260,7 @@ var es;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
RenderableComponent.renderIdGenerator = 0;
|
||||||
return RenderableComponent;
|
return RenderableComponent;
|
||||||
}(es.Component));
|
}(es.Component));
|
||||||
es.RenderableComponent = RenderableComponent;
|
es.RenderableComponent = RenderableComponent;
|
||||||
@@ -3622,6 +3601,8 @@ var es;
|
|||||||
var component = _c.value;
|
var component = _c.value;
|
||||||
if (!component)
|
if (!component)
|
||||||
continue;
|
continue;
|
||||||
|
if (component instanceof es.RenderableComponent)
|
||||||
|
new linq.List(this._entity.scene.renderableComponents.buffer).remove(component);
|
||||||
// 处理IUpdatable
|
// 处理IUpdatable
|
||||||
if (es.isIUpdatable(component))
|
if (es.isIUpdatable(component))
|
||||||
new linq.List(this._updatableComponents).remove(component);
|
new linq.List(this._updatableComponents).remove(component);
|
||||||
@@ -3642,6 +3623,8 @@ var es;
|
|||||||
try {
|
try {
|
||||||
for (var _b = __values(this._components), _c = _b.next(); !_c.done; _c = _b.next()) {
|
for (var _b = __values(this._components), _c = _b.next(); !_c.done; _c = _b.next()) {
|
||||||
var component = _c.value;
|
var component = _c.value;
|
||||||
|
if (component instanceof es.RenderableComponent)
|
||||||
|
this._entity.scene.renderableComponents.buffer.push(component);
|
||||||
if (es.isIUpdatable(component))
|
if (es.isIUpdatable(component))
|
||||||
this._updatableComponents.push(component);
|
this._updatableComponents.push(component);
|
||||||
this._entity.componentBits.set(es.ComponentTypeManager.getIndexFor(es.TypeUtils.getType(component)));
|
this._entity.componentBits.set(es.ComponentTypeManager.getIndexFor(es.TypeUtils.getType(component)));
|
||||||
@@ -3670,6 +3653,8 @@ var es;
|
|||||||
if (this._componentsToAdd.length > 0) {
|
if (this._componentsToAdd.length > 0) {
|
||||||
for (var i = 0, count = this._componentsToAdd.length; i < count; i++) {
|
for (var i = 0, count = this._componentsToAdd.length; i < count; i++) {
|
||||||
var component = this._componentsToAdd[i];
|
var component = this._componentsToAdd[i];
|
||||||
|
if (component instanceof es.RenderableComponent)
|
||||||
|
this._entity.scene.renderableComponents.buffer.push(component);
|
||||||
if (es.isIUpdatable(component))
|
if (es.isIUpdatable(component))
|
||||||
this._updatableComponents.push(component);
|
this._updatableComponents.push(component);
|
||||||
this._entity.componentBits.set(es.ComponentTypeManager.getIndexFor(es.TypeUtils.getType(component)));
|
this._entity.componentBits.set(es.ComponentTypeManager.getIndexFor(es.TypeUtils.getType(component)));
|
||||||
@@ -3697,8 +3682,8 @@ var es;
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
ComponentList.prototype.handleRemove = function (component) {
|
ComponentList.prototype.handleRemove = function (component) {
|
||||||
if (!component)
|
if (component instanceof es.RenderableComponent)
|
||||||
return;
|
new linq.List(this._entity.scene.renderableComponents.buffer).remove(component);
|
||||||
if (es.isIUpdatable(component))
|
if (es.isIUpdatable(component))
|
||||||
new linq.List(this._updatableComponents).remove(component);
|
new linq.List(this._updatableComponents).remove(component);
|
||||||
this._entity.componentBits.set(es.ComponentTypeManager.getIndexFor(es.TypeUtils.getType(component)), false);
|
this._entity.componentBits.set(es.ComponentTypeManager.getIndexFor(es.TypeUtils.getType(component)), false);
|
||||||
@@ -4357,6 +4342,13 @@ var es;
|
|||||||
enumerable: true,
|
enumerable: true,
|
||||||
configurable: true
|
configurable: true
|
||||||
});
|
});
|
||||||
|
Object.defineProperty(RenderableComponentList.prototype, "buffer", {
|
||||||
|
get: function () {
|
||||||
|
return this._components;
|
||||||
|
},
|
||||||
|
enumerable: true,
|
||||||
|
configurable: true
|
||||||
|
});
|
||||||
RenderableComponentList.prototype.get = function (index) {
|
RenderableComponentList.prototype.get = function (index) {
|
||||||
return this._components[index];
|
return this._components[index];
|
||||||
};
|
};
|
||||||
|
|||||||
2
source/bin/framework.min.js
vendored
2
source/bin/framework.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -4,32 +4,21 @@ module es {
|
|||||||
* 非常重要!子类必须覆盖width/height或bounds! 子类必须覆盖width/height或bounds!
|
* 非常重要!子类必须覆盖width/height或bounds! 子类必须覆盖width/height或bounds!
|
||||||
*/
|
*/
|
||||||
export abstract class RenderableComponent extends Component implements IRenderable, IComparer<RenderableComponent> {
|
export abstract class RenderableComponent extends Component implements IRenderable, IComparer<RenderableComponent> {
|
||||||
|
public static renderIdGenerator: number = 0;
|
||||||
/**
|
/**
|
||||||
* 不重写bounds属性的子类必须实现这个!RenderableComponent的宽度。
|
* 不重写bounds属性的子类必须实现这个!RenderableComponent的宽度。
|
||||||
*/
|
*/
|
||||||
public get width() {
|
public abstract get width();
|
||||||
return this.bounds.width;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 不重写bounds属性的子类必须实现这个!
|
* 不重写bounds属性的子类必须实现这个!
|
||||||
*/
|
*/
|
||||||
public get height() {
|
public abstract get height();
|
||||||
return this.bounds.height;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 包裹此对象的AABB。用来进行相机筛选。
|
* 包裹此对象的AABB。用来进行相机筛选。
|
||||||
*/
|
*/
|
||||||
public get bounds(): Rectangle {
|
public abstract get bounds();
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 标准的Batcher图层深度,0为前面,1为后面。
|
* 标准的Batcher图层深度,0为前面,1为后面。
|
||||||
@@ -53,6 +42,11 @@ module es {
|
|||||||
this.setRenderLayer(value);
|
this.setRenderLayer(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 渲染时传递给批处理程序的颜色
|
||||||
|
*/
|
||||||
|
public color: number = 0xffffff;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 由渲染器使用,用于指定该精灵的渲染方式
|
* 由渲染器使用,用于指定该精灵的渲染方式
|
||||||
*/
|
*/
|
||||||
@@ -84,12 +78,16 @@ module es {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
public debugRenderEnabled: boolean = true;
|
public debugRenderEnabled: boolean = true;
|
||||||
|
|
||||||
protected _localOffset: Vector2;
|
protected _localOffset: Vector2 = Vector2.zero;
|
||||||
protected _layerDepth: number;
|
protected _layerDepth: number;
|
||||||
protected _renderLayer: number;
|
protected _renderLayer: number;
|
||||||
protected _bounds: Rectangle;
|
protected _bounds: Rectangle = Rectangle.empty;
|
||||||
protected _isVisble: boolean;
|
protected _isVisble: boolean;
|
||||||
|
|
||||||
protected _areBoundsDirty: boolean = true;
|
protected _areBoundsDirty: boolean = true;
|
||||||
|
|||||||
@@ -24,5 +24,6 @@ module es {
|
|||||||
resolutionOffset,
|
resolutionOffset,
|
||||||
createRenderTarget,
|
createRenderTarget,
|
||||||
createCamera,
|
createCamera,
|
||||||
|
rendererSizeChanged,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,7 +80,9 @@ module es {
|
|||||||
public readonly _sceneComponents: SceneComponent[] = [];
|
public readonly _sceneComponents: SceneComponent[] = [];
|
||||||
public _renderers: IRenderer[] = [];
|
public _renderers: IRenderer[] = [];
|
||||||
public readonly _afterPostProcessorRenderers: IRenderer[] = [];
|
public readonly _afterPostProcessorRenderers: IRenderer[] = [];
|
||||||
public _didSceneBegin: boolean;
|
private _didSceneBegin: boolean;
|
||||||
|
|
||||||
|
private currentRenderId: Ref<number> = new Ref(null);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置新场景将使用的默认设计尺寸和分辨率策略,水平/垂直Bleed仅与BestFit相关
|
* 设置新场景将使用的默认设计尺寸和分辨率策略,水平/垂直Bleed仅与BestFit相关
|
||||||
@@ -369,8 +371,8 @@ module es {
|
|||||||
Framework.emitter.emit(CoreEvents.setRenderTarget, finalRenderTarget);
|
Framework.emitter.emit(CoreEvents.setRenderTarget, finalRenderTarget);
|
||||||
Framework.emitter.emit(CoreEvents.clearGraphics);
|
Framework.emitter.emit(CoreEvents.clearGraphics);
|
||||||
|
|
||||||
Framework.batcher.begin(null);
|
Framework.batcher.begin(this.currentRenderId, null);
|
||||||
Framework.batcher.draw(currentRenderTarget,
|
Framework.batcher.draw(currentRenderTarget.value,
|
||||||
new Vector2(this._finalRenderDestinationRect.x, this._finalRenderDestinationRect.y),
|
new Vector2(this._finalRenderDestinationRect.x, this._finalRenderDestinationRect.y),
|
||||||
0xffffff,
|
0xffffff,
|
||||||
0,
|
0,
|
||||||
@@ -451,6 +453,9 @@ module es {
|
|||||||
|
|
||||||
renderer.onAddedToScene(this);
|
renderer.onAddedToScene(this);
|
||||||
|
|
||||||
|
if (this._didSceneBegin)
|
||||||
|
Framework.emitter.emit(CoreEvents.rendererSizeChanged, this._sceneRenderTarget.value);
|
||||||
|
|
||||||
return renderer;
|
return renderer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -477,13 +482,15 @@ module es {
|
|||||||
* @param renderer
|
* @param renderer
|
||||||
*/
|
*/
|
||||||
public removeRenderer(renderer: IRenderer) {
|
public removeRenderer(renderer: IRenderer) {
|
||||||
Insist.isTrue(new linq.List(this._renderers).contains(renderer) ||
|
let afterProcessLinqList = new linq.List(this._afterPostProcessorRenderers);
|
||||||
new linq.List(this._afterPostProcessorRenderers).contains(renderer));
|
let rendererLinqList = new linq.List(this._renderers);
|
||||||
|
Insist.isTrue(rendererLinqList.contains(renderer) ||
|
||||||
|
afterProcessLinqList.contains(renderer));
|
||||||
|
|
||||||
if (renderer.wantsToRenderAfterPostProcessors)
|
if (renderer.wantsToRenderAfterPostProcessors)
|
||||||
new linq.List(this._afterPostProcessorRenderers).remove(renderer);
|
afterProcessLinqList.remove(renderer);
|
||||||
else
|
else
|
||||||
new linq.List(this._renderers).remove(renderer);
|
rendererLinqList.remove(renderer);
|
||||||
|
|
||||||
renderer.unload();
|
renderer.unload();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,6 +82,9 @@ module es {
|
|||||||
for (let component of this._components) {
|
for (let component of this._components) {
|
||||||
if (!component) continue;
|
if (!component) continue;
|
||||||
|
|
||||||
|
if (component instanceof RenderableComponent)
|
||||||
|
new linq.List(this._entity.scene.renderableComponents.buffer).remove(component);
|
||||||
|
|
||||||
// 处理IUpdatable
|
// 处理IUpdatable
|
||||||
if (isIUpdatable(component))
|
if (isIUpdatable(component))
|
||||||
new linq.List(this._updatableComponents).remove(component);
|
new linq.List(this._updatableComponents).remove(component);
|
||||||
@@ -93,6 +96,9 @@ module es {
|
|||||||
|
|
||||||
public registerAllComponents() {
|
public registerAllComponents() {
|
||||||
for (let component of this._components) {
|
for (let component of this._components) {
|
||||||
|
if (component instanceof RenderableComponent)
|
||||||
|
this._entity.scene.renderableComponents.buffer.push(component);
|
||||||
|
|
||||||
if (isIUpdatable(component))
|
if (isIUpdatable(component))
|
||||||
this._updatableComponents.push(component);
|
this._updatableComponents.push(component);
|
||||||
|
|
||||||
@@ -118,6 +124,9 @@ module es {
|
|||||||
for (let i = 0, count = this._componentsToAdd.length; i < count; i++) {
|
for (let i = 0, count = this._componentsToAdd.length; i < count; i++) {
|
||||||
let component = this._componentsToAdd[i];
|
let component = this._componentsToAdd[i];
|
||||||
|
|
||||||
|
if (component instanceof RenderableComponent)
|
||||||
|
this._entity.scene.renderableComponents.buffer.push(component);
|
||||||
|
|
||||||
if (isIUpdatable(component))
|
if (isIUpdatable(component))
|
||||||
this._updatableComponents.push(component);
|
this._updatableComponents.push(component);
|
||||||
|
|
||||||
@@ -153,7 +162,8 @@ module es {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public handleRemove(component: Component) {
|
public handleRemove(component: Component) {
|
||||||
if (!component) return;
|
if (component instanceof RenderableComponent)
|
||||||
|
new linq.List(this._entity.scene.renderableComponents.buffer).remove(component);
|
||||||
|
|
||||||
if (isIUpdatable(component))
|
if (isIUpdatable(component))
|
||||||
new linq.List(this._updatableComponents).remove(component);
|
new linq.List(this._updatableComponents).remove(component);
|
||||||
|
|||||||
@@ -19,6 +19,10 @@ module es {
|
|||||||
return this._components.length;
|
return this._components.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public get buffer(){
|
||||||
|
return this._components;
|
||||||
|
}
|
||||||
|
|
||||||
public get(index: number): IRenderable {
|
public get(index: number): IRenderable {
|
||||||
return this._components[index];
|
return this._components[index];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ module es {
|
|||||||
*/
|
*/
|
||||||
shouldRoundDestinations: boolean;
|
shouldRoundDestinations: boolean;
|
||||||
disposed();
|
disposed();
|
||||||
begin(effect, transformationMatrix?: Matrix, disableBatching?: boolean);
|
begin(id: Ref<number>, effect, transformationMatrix?: Matrix, disableBatching?: boolean);
|
||||||
end();
|
end();
|
||||||
prepRenderState();
|
prepRenderState();
|
||||||
/**
|
/**
|
||||||
@@ -19,10 +19,7 @@ module es {
|
|||||||
drawHollowRect(rect: Rectangle, color: number, thickness?: number);
|
drawHollowRect(rect: Rectangle, color: number, thickness?: number);
|
||||||
drawHollowBounds(x: number, y: number, width: number, height: number, color: number, thickness: number);
|
drawHollowBounds(x: number, y: number, width: number, height: number, color: number, thickness: number);
|
||||||
drawLine(start: Vector2, end: Vector2, color: number, thickness);
|
drawLine(start: Vector2, end: Vector2, color: number, thickness);
|
||||||
drawLineAngle(start: Vector2, radians: number, length: number, color: number, thickness: number);
|
|
||||||
draw(texture, position: Vector2, color?: number, rotation?: number, origin?: Vector2, scale?: Vector2, effects?);
|
draw(texture, position: Vector2, color?: number, rotation?: number, origin?: Vector2, scale?: Vector2, effects?);
|
||||||
flushBatch();
|
|
||||||
drawPrimitives(texture, baseSprite: number, batchSize: number);
|
|
||||||
drawPixel(position: Vector2, color: number, size?: number);
|
drawPixel(position: Vector2, color: number, size?: number);
|
||||||
drawPolygon(position: Vector2, points: Vector2[], color: number, closePoly?: boolean, thickness?: number);
|
drawPolygon(position: Vector2, points: Vector2[], color: number, closePoly?: boolean, thickness?: number);
|
||||||
drawCircle(position: Vector2, radius: number, color: number, thickness?: number, resolution?: number);
|
drawCircle(position: Vector2, radius: number, color: number, thickness?: number, resolution?: number);
|
||||||
|
|||||||
Reference in New Issue
Block a user