pinball/assets/_Game/Scripts/UI/TutorialController.ts

39 lines
1.3 KiB
TypeScript
Raw Normal View History

2024-03-26 20:04:28 -07:00
import { _decorator, Component, EventTouch, Input, Node, Tween, tween, Vec3 } from 'cc';
import { GameManager } from '../Manager/GameManager';
const { ccclass, property } = _decorator;
@ccclass('TutorialController')
export class TutorialController extends Component {
@property({ type: Node, visible: true })
private _tapL: Node;
@property({ type: Node, visible: true })
private _tapR: Node;
protected onLoad(): void {
this.node.on(Input.EventType.TOUCH_START, this.onTouch, this);
}
protected start() {
tween(this._tapL)
.by(0.5, { position: new Vec3(0, 50) }, { easing: 'quintOut' })
.by(0.5, { position: new Vec3(0, -50) }, { easing: 'sineOut' })
.union()
.repeatForever()
.start();
tween(this._tapR)
.delay(0.5)
.by(0.5, { position: new Vec3(0, 50) }, { easing: 'quintOut' })
.by(0.5, { position: new Vec3(0, -50) }, { easing: 'sineOut' })
.union()
.repeatForever()
.start();
}
private onTouch(event: EventTouch) {
Tween.stopAllByTarget(this._tapL);
Tween.stopAllByTarget(this._tapR);
this.node.active = false;
GameManager.instance.play();
}
}