新增renderable组件render方法 去除mathhelper.minof/maxof

This commit is contained in:
yhh
2020-06-18 10:49:32 +08:00
parent 9c293979a4
commit 231276e39b
12 changed files with 162 additions and 68 deletions

View File

@@ -2,6 +2,19 @@ class SpriteRenderer extends RenderableComponent {
private _sprite: egret.DisplayObject;
private _origin: Vector2;
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.width,
this._sprite.height);
this._areBoundsDirty = false;
}
return this.bounds;
}
}
public get sprite(){
return this._sprite;
}
@@ -18,7 +31,16 @@ class SpriteRenderer extends RenderableComponent {
return this;
}
public initialize() {
public render(camera: Camera) {
if (!this.sprite)
return;
this.sprite.x = this.entity.transform.position.x;
this.sprite.y = this.entity.transform.position.y;
this.sprite.rotation = this.entity.transform.rotation;
this.sprite.anchorOffsetX = this._origin.x;
this.sprite.anchorOffsetY = this._origin.y;
this.sprite.scaleX = this.entity.transform.scale.x;
this.sprite.scaleY = this.entity.transform.scale.y;
}
}