43 lines
1.1 KiB
TypeScript
43 lines
1.1 KiB
TypeScript
import { _decorator, Component, Node, tween, UIOpacity, Vec3 } from 'cc';
|
|
import Utils from '../../Main/Common/Utils';
|
|
const { ccclass, property } = _decorator;
|
|
|
|
/**界面打开动画 */
|
|
@ccclass('UIOpenAni')
|
|
export class UIOpenAni extends Component {
|
|
private uiopa: UIOpacity = null;
|
|
start() {
|
|
this.uiopa = this.node.getComponent(UIOpacity);
|
|
if (!this.uiopa) {
|
|
this.uiopa = this.node.addComponent(UIOpacity);
|
|
}
|
|
|
|
//动作1 透明度
|
|
this.uiopa.opacity = 0;
|
|
tween(this.uiopa)
|
|
.delay(0.1)
|
|
.to(0.15, { opacity: 255 })
|
|
.start();
|
|
|
|
//动作2 缩放
|
|
let scaleRatio = Utils.getScaleRatio(2)
|
|
if (scaleRatio > 1) {
|
|
scaleRatio = 1;
|
|
}
|
|
let origScale = new Vec3(scaleRatio, scaleRatio, scaleRatio);
|
|
tween(this.node)
|
|
.delay(0.1)
|
|
.call(() => {
|
|
this.node.scale = new Vec3(0.7, 0.7, 0.7);
|
|
})
|
|
.to(0.2, { scale: origScale }, { easing: 'backOut' })
|
|
.start();
|
|
}
|
|
|
|
update(deltaTime: number) {
|
|
|
|
}
|
|
}
|
|
|
|
|