修复box因缺少初始化报错问题

This commit is contained in:
yhh
2020-06-16 16:35:17 +08:00
parent 7f5b78f340
commit 447ea4efe4
18 changed files with 272 additions and 910 deletions

View File

@@ -12,7 +12,7 @@ abstract class Collider extends Component{
protected _isParentEntityAddedToScene;
protected _colliderRequiresAutoSizing;
protected _localOffset: Vector2 = new Vector2(0, 0);
protected _isColliderRegisterd;
protected _isColliderRegistered;
public get bounds(): Rectangle {
if (this._isPositionDirty || this._isRotationDirty){
@@ -42,17 +42,17 @@ abstract class Collider extends Component{
}
public registerColliderWithPhysicsSystem(){
if (this._isParentEntityAddedToScene && !this._isColliderRegisterd){
if (this._isParentEntityAddedToScene && !this._isColliderRegistered){
Physics.addCollider(this);
this._isColliderRegisterd = true;
this._isColliderRegistered = true;
}
}
public unregisterColliderWithPhysicsSystem(){
if (this._isParentEntityAddedToScene && this._isColliderRegisterd){
if (this._isParentEntityAddedToScene && this._isColliderRegistered){
Physics.removeCollider(this);
}
this._isColliderRegisterd = false;
this._isColliderRegistered = false;
}
public overlaps(other: Collider){
@@ -112,7 +112,7 @@ abstract class Collider extends Component{
break;
}
if (this._isColliderRegisterd)
if (this._isColliderRegistered)
Physics.updateCollider(this);
}

View File

@@ -49,7 +49,7 @@ class Transform {
constructor(entity: Entity){
this.entity = entity;
this._scale = this._localScale = new Vector2(0, 0);
this._scale = this._localScale = Vector2.one;
this._children = [];
}

View File

@@ -126,19 +126,27 @@ class ComponentList {
for (let i = 0; i < this._components.length; i ++){
let component = this._components[i];
if (typeof(typeName) == "string" && egret.is(component, typeName))
components.push(component);
else if (component instanceof typeName) {
components.push(component);
if (typeof(typeName) == "string"){
if (egret.is(component, typeName)){
components.push(component);
}
}else{
if (component instanceof typeName){
components.push(component);
}
}
}
for (let i = 0; i < this._componentsToAdd.length; i ++){
let component = this._componentsToAdd[i];
if (typeof(typeName) == "string" && egret.is(component, typeName))
components.push(component);
else if (component instanceof typeName){
components.push(component);
if (typeof(typeName) == "string"){
if (egret.is(component, typeName)){
components.push(component);
}
}else{
if (component instanceof typeName){
components.push(component);
}
}
}