新增renderer渲染器 用于控制场景如何渲染
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* 所有可渲染组件的基类
|
||||
*/
|
||||
abstract class RenderableComponent extends Component {
|
||||
abstract class RenderableComponent extends Component implements IRenderable {
|
||||
private _isVisible: boolean;
|
||||
protected _areBoundsDirty = true;
|
||||
protected _bounds: Rectangle;
|
||||
@@ -60,4 +60,8 @@ abstract class RenderableComponent extends Component {
|
||||
this.isVisible = camera.bounds.intersects(this.bounds);
|
||||
return this.isVisible;
|
||||
}
|
||||
|
||||
public onEntityTransformChanged(comp: ComponentTransform){
|
||||
this._areBoundsDirty = true;
|
||||
}
|
||||
}
|
||||
5
source/src/ECS/Components/SpriteEffects.ts
Normal file
5
source/src/ECS/Components/SpriteEffects.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
enum SpriteEffects {
|
||||
none = 0,
|
||||
flipHorizontally = 1,
|
||||
flipVertically = 2
|
||||
}
|
||||
@@ -31,6 +31,20 @@ class SpriteRenderer extends RenderableComponent {
|
||||
return this;
|
||||
}
|
||||
|
||||
public get origin(){
|
||||
return this._origin;
|
||||
}
|
||||
public set origin(value: Vector2){
|
||||
this.setOrigin(value);
|
||||
}
|
||||
public setOrigin(origin: Vector2){
|
||||
if (this._origin != origin){
|
||||
this._origin = origin;
|
||||
this._areBoundsDirty = true;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public render(camera: Camera) {
|
||||
if (!this.sprite)
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user