消消方块阵换皮表情
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.
 
 
 

59 lines
1.6 KiB

import { _decorator, Camera, CCFloat, Component, director, game, Node, sys, tween, Vec3, view } from 'cc';
import { UIManager } from '../module/ui/UIManager';
const { ccclass, property } = _decorator;
@ccclass('MoveCamera')
export class MoveCamera extends Component {
@property({ type: CCFloat, tooltip: "时间" })
time: number = 1;
@property({ tooltip: "相机高度" })
orthoHeight: number = view.getVisibleSize().height / 2;
@property({ tooltip: "显示时播放" })
playOnEnable: boolean = false;
@property({ tooltip: "回到默认" })
toDefault: boolean = false;
private _camera: Camera = null;
protected onEnable(): void {
this._camera = UIManager.Ins.GameCamera;
if (this.playOnEnable) this.startMove();
}
startMove(callback?: Function) {
if (!this._camera) {
this._camera = UIManager.Ins.GameCamera;
}
if (this.toDefault) {
MoveCamera.moveToDefault(this.time);
return;
}
tween(this._camera.node)
.to(this.time, { worldPosition: this.node.worldPosition })
.start();
tween(this._camera)
.to(this.time, { orthoHeight: this.orthoHeight })
.call(() => {
if (callback) callback();
})
.start();
}
static moveToDefault(time: number = 1) {
let h = view.getVisibleSize().height / 2;
let c = UIManager.Ins.GameCamera;
tween(c.node)
.to(time, { position: Vec3.ZERO })
.start();
tween(c)
.to(time, { orthoHeight: h })
.start();
}
}