实体跟随相机
This commit is contained in:
@@ -1,11 +1,46 @@
|
||||
class Camera {
|
||||
private _displayContent: egret.DisplayObject;
|
||||
///<reference path="../Component.ts"/>
|
||||
class Camera extends Component {
|
||||
private _zoom;
|
||||
private _origin: Vector2;
|
||||
private _transformMatrix: Matrix2D = Matrix2D.identity;
|
||||
private _inverseTransformMatrix = Matrix2D.identity;
|
||||
|
||||
constructor(displayObject: egret.DisplayObject){
|
||||
this._displayContent = displayObject;
|
||||
public get transformMatrix(){
|
||||
this.updateMatrixes();
|
||||
|
||||
return this._transformMatrix;
|
||||
}
|
||||
|
||||
public destory(){
|
||||
this._displayContent = null;
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
public initialize() {
|
||||
|
||||
}
|
||||
|
||||
public update(){
|
||||
SceneManager.getActiveScene().entities.forEach(entity => entity.components.forEach(component => {
|
||||
if (component.displayRender){
|
||||
let has = this.entity.scene.$children.indexOf(component.displayRender)
|
||||
if (has == -1){
|
||||
this.entity.scene.stage.addChild(component.displayRender);
|
||||
}
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
public setPosition(position: Vector2){
|
||||
this.entity.transform.setPosition(position);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public updateMatrixes(){
|
||||
this._transformMatrix = Matrix2D.createTranslation(-this.entity.transform.position.x, -this.entity.transform.position.y);
|
||||
}
|
||||
|
||||
public destory() {
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user