初始化默认数值
This commit is contained in:
@@ -5,10 +5,10 @@ module es {
|
||||
}
|
||||
|
||||
export class CameraInset {
|
||||
public left: number;
|
||||
public right: number;
|
||||
public top: number;
|
||||
public bottom: number;
|
||||
public left: number = 0;
|
||||
public right: number = 0;
|
||||
public top: number = 0;
|
||||
public bottom: number = 0;
|
||||
}
|
||||
|
||||
export class Camera extends Component {
|
||||
@@ -167,8 +167,8 @@ module es {
|
||||
public _zoom;
|
||||
public _minimumZoom = 0.3;
|
||||
public _maximumZoom = 3;
|
||||
public _bounds: Rectangle;
|
||||
public _inset: CameraInset;
|
||||
public _bounds: Rectangle = new Rectangle();
|
||||
public _inset: CameraInset = new CameraInset();
|
||||
public _transformMatrix: Matrix2D = new Matrix2D().identity();
|
||||
public _inverseTransformMatrix: Matrix2D = new Matrix2D().identity();
|
||||
public _origin: Vector2 = Vector2.zero;
|
||||
@@ -190,7 +190,7 @@ module es {
|
||||
/**
|
||||
* 相机聚焦于屏幕中心的偏移
|
||||
*/
|
||||
public focusOffset: Vector2 = new Vector2();
|
||||
public focusOffset: Vector2 = Vector2.zero;
|
||||
/**
|
||||
* 如果为true 相机位置则不会超出地图矩形(0, 0, mapwidth, mapheight)
|
||||
*/
|
||||
@@ -198,7 +198,7 @@ module es {
|
||||
/**
|
||||
* 當前地圖映射的寬度和高度
|
||||
*/
|
||||
public mapSize: Vector2 = new Vector2();
|
||||
public mapSize: Vector2 = Vector2.zero;
|
||||
|
||||
public _targetEntity: Entity;
|
||||
public _targetCollider: Collider;
|
||||
|
||||
@@ -57,6 +57,7 @@ module es {
|
||||
|
||||
if (this._instance._scene == null) {
|
||||
this._instance._scene = value;
|
||||
this._instance.addChild(value);
|
||||
this._instance._scene.begin();
|
||||
Core.Instance.onSceneChanged();
|
||||
} else {
|
||||
@@ -100,7 +101,7 @@ module es {
|
||||
}
|
||||
|
||||
protected async update() {
|
||||
this.startDebugUpdate();
|
||||
// this.startDebugUpdate();
|
||||
|
||||
// 更新我们所有的系统管理器
|
||||
Time.update(egret.getTimer());
|
||||
@@ -121,17 +122,19 @@ module es {
|
||||
}
|
||||
|
||||
if (this._nextScene) {
|
||||
this.removeChild(this._scene);
|
||||
this._scene.end();
|
||||
|
||||
this._scene = this._nextScene;
|
||||
this._nextScene = null;
|
||||
this.onSceneChanged();
|
||||
|
||||
this.addChild(this._scene);
|
||||
await this._scene.begin();
|
||||
}
|
||||
}
|
||||
|
||||
this.endDebugUpdate();
|
||||
// this.endDebugUpdate();
|
||||
}
|
||||
|
||||
public async draw() {
|
||||
|
||||
@@ -220,7 +220,7 @@ module es {
|
||||
/**
|
||||
* 值会根据位置、旋转和比例自动重新计算
|
||||
*/
|
||||
public _localTransform: Matrix2D;
|
||||
public _localTransform: Matrix2D = Matrix2D.create();
|
||||
/**
|
||||
* 值将自动从本地和父矩阵重新计算。
|
||||
*/
|
||||
@@ -228,17 +228,17 @@ module es {
|
||||
public _worldToLocalTransform = Matrix2D.create().identity();
|
||||
public _worldInverseTransform = Matrix2D.create().identity();
|
||||
|
||||
public _rotationMatrix: Matrix2D;
|
||||
public _translationMatrix: Matrix2D;
|
||||
public _scaleMatrix: Matrix2D;
|
||||
public _rotationMatrix: Matrix2D = Matrix2D.create();
|
||||
public _translationMatrix: Matrix2D = Matrix2D.create();
|
||||
public _scaleMatrix: Matrix2D = Matrix2D.create();
|
||||
|
||||
public _position: Vector2;
|
||||
public _scale: Vector2;
|
||||
public _rotation: number;
|
||||
public _position: Vector2 = Vector2.zero;
|
||||
public _scale: Vector2 = Vector2.one;
|
||||
public _rotation: number = 0;
|
||||
|
||||
public _localPosition: Vector2;
|
||||
public _localScale: Vector2;
|
||||
public _localRotation: number;
|
||||
public _localPosition: Vector2 = Vector2.zero;
|
||||
public _localScale: Vector2 = Vector2.one;
|
||||
public _localRotation: number = 0;
|
||||
|
||||
public _children: Transform[];
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
module es {
|
||||
export var matrixPool = [];
|
||||
/**
|
||||
* 表示右手3 * 3的浮点矩阵,可以存储平移、缩放和旋转信息。
|
||||
*/
|
||||
@@ -40,32 +41,66 @@ module es {
|
||||
this.ty = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* 从对象池中取出或创建一个新的Matrix对象。
|
||||
*/
|
||||
public static create(): Matrix2D{
|
||||
return egret.Matrix.create() as Matrix2D;
|
||||
let matrix = matrixPool.pop();
|
||||
if (!matrix)
|
||||
matrix = new Matrix2D();
|
||||
return matrix;
|
||||
}
|
||||
|
||||
public identity(): Matrix2D{
|
||||
super.identity();
|
||||
this.a = this.d = 1;
|
||||
this.b = this.c = this.tx = this.ty = 0;
|
||||
return this;
|
||||
}
|
||||
|
||||
public translate(dx: number, dy: number): Matrix2D {
|
||||
super.translate(dx, dy);
|
||||
this.tx += dx;
|
||||
this.ty += dy;
|
||||
return this;
|
||||
}
|
||||
|
||||
public scale(sx: number, sy: number): Matrix2D {
|
||||
super.scale(sx, sy);
|
||||
if (sx !== 1){
|
||||
this.a *= sx;
|
||||
this.c *= sx;
|
||||
this.tx *= sx;
|
||||
}
|
||||
if (sy !== 1){
|
||||
this.b *= sy;
|
||||
this.d *= sy;
|
||||
this.ty *= sy;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public rotate(angle: number): Matrix2D {
|
||||
super.rotate(angle);
|
||||
angle = +angle;
|
||||
if (angle !== 0) {
|
||||
angle = angle / DEG_TO_RAD;
|
||||
let u = Math.cos(angle);
|
||||
let v = Math.sin(angle);
|
||||
let ta = this.a;
|
||||
let tb = this.b;
|
||||
let tc = this.c;
|
||||
let td = this.d;
|
||||
let ttx = this.tx;
|
||||
let tty = this.ty;
|
||||
this.a = ta * u - tb * v;
|
||||
this.b = ta * v + tb * u;
|
||||
this.c = tc * u - td * v;
|
||||
this.d = tc * v + td * u;
|
||||
this.tx = ttx * u - tty * v;
|
||||
this.ty = ttx * v + tty * u;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public invert(): Matrix2D {
|
||||
super.invert();
|
||||
this.$invertInto(this);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -137,5 +172,11 @@ module es {
|
||||
public determinant(){
|
||||
return this.m11 * this.m22 - this.m12 * this.m21;
|
||||
}
|
||||
|
||||
public release(matrix: Matrix2D) {
|
||||
if (!matrix)
|
||||
return;
|
||||
matrixPool.push(matrix);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user