实体跟随相机

This commit is contained in:
yhh
2020-06-08 16:23:48 +08:00
parent f20c460fc6
commit cadd9ab0fc
18 changed files with 925 additions and 54 deletions

View File

@@ -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() {
}
}