#23 组件绘制层支持

This commit is contained in:
YHH
2020-08-08 09:43:03 +08:00
parent e7fb9e0d6b
commit 6a3622a5ef
10 changed files with 100 additions and 48 deletions

View File

@@ -57,7 +57,7 @@ module es {
}
public set renderLayer(value: number) {
this.setRenderLayer(value);
}
protected _bounds: Rectangle = new Rectangle();

View File

@@ -152,7 +152,7 @@ module es {
public render() {
if (this._renderers.length == 0) {
console.error("there are no renderers in the scene!");
console.error("场景中没有渲染器!");
return;
}

View File

@@ -59,7 +59,7 @@ module es {
public addToRenderLayerList(component: IRenderable, renderLayer: number) {
let list = this.componentsWithRenderLayer(renderLayer);
if (!list.contains(component)) {
console.warn("Component renderLayer list already contains this component");
console.warn("组件呈现层列表已经包含此组件");
return;
}
@@ -84,6 +84,7 @@ module es {
if (this._componentsNeedSort) {
this._components.sort(RenderableComponentList.compareUpdatableOrder.compare);
this._componentsNeedSort = false;
this.updateEgretList();
}
if (this._unsortedRenderLayers.length > 0) {
@@ -97,5 +98,18 @@ module es {
this._unsortedRenderLayers.length = 0;
}
}
private updateEgretList(){
let scene = Core._instance._scene;
if (!scene)
return;
for (let i = 0 ; i < this._components.length; i ++){
let component = this._components[i] as RenderableComponent;
let egretDisplayObject = scene.$children.find(a => {return a.hashCode == component.displayObject.hashCode});
let displayIndex = scene.getChildIndex(egretDisplayObject);
if (displayIndex != i) scene.swapChildrenAt(displayIndex, i);
}
}
}
}

View File

@@ -73,7 +73,7 @@ module es {
// 单元格应该始终存在,因为这个碰撞器应该在所有查询的单元格中
let cell = this.cellAtPosition(x, y);
if (!cell)
console.error(`removing Collider [${collider}] from a cell that it is not present in`);
console.log(`从不存在碰撞器的单元格中移除碰撞器: [${collider}]`);
else
cell.remove(collider);
}