You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
833 B
34 lines
833 B
import { Camera, Vec3 } from "cc";
|
|
|
|
export class CameraManager {
|
|
private static _instance: CameraManager;
|
|
public static get instance(): CameraManager {
|
|
if (!this._instance) {
|
|
this._instance = new CameraManager();
|
|
}
|
|
return this._instance;
|
|
}
|
|
|
|
private _camera: Camera;
|
|
private _defaultHeight: number;
|
|
|
|
setCamera(camera: Camera) {
|
|
this._camera = camera;
|
|
this._defaultHeight = this._camera.orthoHeight;
|
|
}
|
|
|
|
reset() {
|
|
this._camera.orthoHeight = this._defaultHeight;
|
|
this._camera.node.setPosition(Vec3.ZERO);
|
|
}
|
|
|
|
moveToPos(worldPosition: Vec3, hight: number = 0) {
|
|
this._camera.orthoHeight = hight;
|
|
this._camera.node.setWorldPosition(worldPosition);
|
|
}
|
|
|
|
moveToTarget(target: Node, hight: number = 0) {
|
|
|
|
}
|
|
|
|
} |