新增box复合体 修复vector2运算问题
This commit is contained in:
@@ -8,11 +8,11 @@ abstract class RenderableComponent extends Component {
|
||||
private _localOffset: Vector2;
|
||||
|
||||
public get width(){
|
||||
return this.bounds.width;
|
||||
return this.getWidth();
|
||||
}
|
||||
|
||||
public get height(){
|
||||
return this.bounds.height;
|
||||
return this.getHeight();
|
||||
}
|
||||
|
||||
public get isVisible(){
|
||||
@@ -29,8 +29,20 @@ abstract class RenderableComponent extends Component {
|
||||
}
|
||||
|
||||
public get bounds(): Rectangle{
|
||||
return this.getBounds();
|
||||
}
|
||||
|
||||
protected getWidth(){
|
||||
return this.bounds.width;
|
||||
}
|
||||
|
||||
protected getHeight(){
|
||||
return this.bounds.height;
|
||||
}
|
||||
|
||||
protected getBounds(){
|
||||
if (this._areBoundsDirty){
|
||||
this._bounds.calculateBounds(this.entity.transform.position, this._localOffset, Vector2.Zero,
|
||||
this._bounds.calculateBounds(this.entity.transform.position, this._localOffset, new Vector2(0, 0),
|
||||
this.entity.transform.scale, this.entity.transform.rotation, this.width, this.height);
|
||||
this._areBoundsDirty = false;
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ class Transform {
|
||||
|
||||
constructor(entity: Entity){
|
||||
this.entity = entity;
|
||||
this._scale = this._localScale = Vector2.One;
|
||||
this._scale = this._localScale = new Vector2(0, 0);
|
||||
this._children = [];
|
||||
}
|
||||
|
||||
|
||||
@@ -122,6 +122,11 @@ class ComponentList {
|
||||
|
||||
public update(){
|
||||
this.updateLists();
|
||||
for (let i = 0; i < this._components.length; i ++){
|
||||
let component = this._components[i];
|
||||
if (component.enabled && (component.updateInterval == 1 || Time.frameCount % component.updateInterval == 0))
|
||||
component.update();
|
||||
}
|
||||
}
|
||||
|
||||
public onEntityTransformChanged(comp){
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
class Time {
|
||||
public static unscaledDeltaTime;
|
||||
public static deltaTime: number;
|
||||
public static deltaTime: number = 0;
|
||||
public static timeScale = 1;
|
||||
public static frameCount = 0;;
|
||||
|
||||
private static _lastTime = 0;
|
||||
|
||||
@@ -9,6 +10,7 @@ class Time {
|
||||
let dt = (currentTime - this._lastTime) / 1000;
|
||||
this.deltaTime = dt * this.timeScale;
|
||||
this.unscaledDeltaTime = dt;
|
||||
this.frameCount ++;
|
||||
|
||||
this._lastTime = currentTime;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user