Skip to content

Commit

Permalink
debugRender 新增camera参数来修正渲染位置
Browse files Browse the repository at this point in the history
  • Loading branch information
esengine committed Aug 28, 2020
1 parent a3c5311 commit 7a308f7
Show file tree
Hide file tree
Showing 27 changed files with 236 additions and 192 deletions.
19 changes: 10 additions & 9 deletions demo/libs/framework/framework.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ declare module es {
onAddedToEntity(): void;
onRemovedFromEntity(): void;
onEntityTransformChanged(comp: transform.Component): void;
debugRender(): void;
debugRender(camera: Camera): void;
onEnabled(): void;
onDisabled(): void;
update(): void;
Expand Down Expand Up @@ -336,7 +336,7 @@ declare module es {
onAddedToScene(): void;
onRemovedFromScene(): void;
update(): void;
debugRender(): void;
debugRender(camera: Camera): void;
addComponent<T extends Component>(component: T): T;
getComponent<T extends Component>(type: any): T;
hasComponent<T extends Component>(type: any): boolean;
Expand Down Expand Up @@ -561,7 +561,7 @@ declare module es {
onAddedToEntity(): void;
onGraphicsDeviceReset(): void;
update(): void;
debugRender(): void;
debugRender(camera: Camera): void;
clampToMapSize(position: Vector2): Vector2;
follow(targetEntity: Entity, cameraStyle?: CameraStyle): void;
updateFollow(): void;
Expand Down Expand Up @@ -598,12 +598,13 @@ declare module es {
isVisible: boolean;
onEntityTransformChanged(comp: transform.Component): void;
abstract render(camera: Camera): any;
debugRender(): void;
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;
Expand Down Expand Up @@ -847,7 +848,7 @@ declare module es {
setSize(width: number, height: number): this;
setWidth(width: number): BoxCollider;
setHeight(height: number): void;
debugRender(): void;
debugRender(camera: Camera): void;
toString(): string;
}
}
Expand All @@ -860,7 +861,7 @@ declare module es {
constructor(radius?: number);
radius: number;
setRadius(radius: number): CircleCollider;
debugRender(): void;
debugRender(camera: Camera): void;
toString(): string;
}
}
Expand Down Expand Up @@ -956,7 +957,7 @@ declare module es {
onEntityTransformChanged(comp: transform.Component): void;
onEntityEnabled(): void;
onEntityDisabled(): void;
debugRender(): void;
debugRender(camera: Camera): void;
}
}
declare module es {
Expand Down Expand Up @@ -1042,7 +1043,7 @@ declare module es {
isVisible: boolean;
isVisibleFromCamera(camera: Camera): any;
render(camera: Camera): any;
debugRender(): any;
debugRender(camera: Camera): any;
}
class RenderableComparer {
compare(self: IRenderable, other: IRenderable): number;
Expand Down Expand Up @@ -2114,7 +2115,7 @@ declare module es {
static perpendicular(first: Vector2, second: Vector2): Vector2;
static normalize(vec: Vector2): void;
static transformA(sourceArray: Vector2[], sourceIndex: number, matrix: Matrix2D, destinationArray: Vector2[], destinationIndex: number, length: number): void;
static transformR(position: Vector2, matrix: Matrix2D): Vector2;
static transformR(position: Vector2, matrix: Matrix2D, result: Vector2): void;
static transform(sourceArray: Vector2[], matrix: Matrix2D, destinationArray: Vector2[]): void;
static round(vec: Vector2): Vector2;
}
Expand Down
120 changes: 65 additions & 55 deletions demo/libs/framework/framework.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion demo/libs/framework/framework.min.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions demo/src/Main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class Main extends es.Core {
protected initialize() {
try {
es.Core.debugRenderEndabled = true;
es.TimeRuler.Instance.showLog = true;
this.runGame();
} catch(err) {
console.error(err);
Expand Down
17 changes: 17 additions & 0 deletions demo/src/Scenes/Empty Scene/BasicScene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,23 @@ module samples {
public async onStart() {
super.onStart();
manager.AlterManager.alter_tips("空白场景加载成功");

this.content.loadRes("moon_png").then(moonTexture => {
let moonEntity = this.createEntity("moon");
moonEntity.position = new es.Vector2(0, 0);
moonEntity.addComponent(new es.SpriteRenderer(moonTexture));

this.camera.entity.addComponent(new es.FollowCamera(moonEntity));
});
}

public update(){
super.update();
let moonEntity = this.findEntity("moon");
if (!moonEntity)
return;
let spriteRenderer = moonEntity.getComponent<es.SpriteRenderer>(es.SpriteRenderer);
console.log(spriteRenderer.bounds, this.camera.bounds);
}
}
}
2 changes: 2 additions & 0 deletions demo/src/Scenes/Ninja Adventure/NinjaAdventureScene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ module samples {
moonEntity.addComponent(new ProjectileHitDetector());
moonEntity.addComponent(new CircleCollider());
});

manager.AlterManager.alter_tips("Ninja 场景加载成功");
}

/**
Expand Down
19 changes: 10 additions & 9 deletions source/bin/framework.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ declare module es {
onAddedToEntity(): void;
onRemovedFromEntity(): void;
onEntityTransformChanged(comp: transform.Component): void;
debugRender(): void;
debugRender(camera: Camera): void;
onEnabled(): void;
onDisabled(): void;
update(): void;
Expand Down Expand Up @@ -336,7 +336,7 @@ declare module es {
onAddedToScene(): void;
onRemovedFromScene(): void;
update(): void;
debugRender(): void;
debugRender(camera: Camera): void;
addComponent<T extends Component>(component: T): T;
getComponent<T extends Component>(type: any): T;
hasComponent<T extends Component>(type: any): boolean;
Expand Down Expand Up @@ -561,7 +561,7 @@ declare module es {
onAddedToEntity(): void;
onGraphicsDeviceReset(): void;
update(): void;
debugRender(): void;
debugRender(camera: Camera): void;
clampToMapSize(position: Vector2): Vector2;
follow(targetEntity: Entity, cameraStyle?: CameraStyle): void;
updateFollow(): void;
Expand Down Expand Up @@ -598,12 +598,13 @@ declare module es {
isVisible: boolean;
onEntityTransformChanged(comp: transform.Component): void;
abstract render(camera: Camera): any;
debugRender(): void;
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;
Expand Down Expand Up @@ -847,7 +848,7 @@ declare module es {
setSize(width: number, height: number): this;
setWidth(width: number): BoxCollider;
setHeight(height: number): void;
debugRender(): void;
debugRender(camera: Camera): void;
toString(): string;
}
}
Expand All @@ -860,7 +861,7 @@ declare module es {
constructor(radius?: number);
radius: number;
setRadius(radius: number): CircleCollider;
debugRender(): void;
debugRender(camera: Camera): void;
toString(): string;
}
}
Expand Down Expand Up @@ -956,7 +957,7 @@ declare module es {
onEntityTransformChanged(comp: transform.Component): void;
onEntityEnabled(): void;
onEntityDisabled(): void;
debugRender(): void;
debugRender(camera: Camera): void;
}
}
declare module es {
Expand Down Expand Up @@ -1042,7 +1043,7 @@ declare module es {
isVisible: boolean;
isVisibleFromCamera(camera: Camera): any;
render(camera: Camera): any;
debugRender(): any;
debugRender(camera: Camera): any;
}
class RenderableComparer {
compare(self: IRenderable, other: IRenderable): number;
Expand Down Expand Up @@ -2114,7 +2115,7 @@ declare module es {
static perpendicular(first: Vector2, second: Vector2): Vector2;
static normalize(vec: Vector2): void;
static transformA(sourceArray: Vector2[], sourceIndex: number, matrix: Matrix2D, destinationArray: Vector2[], destinationIndex: number, length: number): void;
static transformR(position: Vector2, matrix: Matrix2D): Vector2;
static transformR(position: Vector2, matrix: Matrix2D, result: Vector2): void;
static transform(sourceArray: Vector2[], matrix: Matrix2D, destinationArray: Vector2[]): void;
static round(vec: Vector2): Vector2;
}
Expand Down
Loading

0 comments on commit 7a308f7

Please sign in to comment.