Boss anim, open close

This commit is contained in:
Martin
2022-12-31 12:29:27 +01:00
parent 354be800ec
commit 93424a5c8a
27 changed files with 1090 additions and 443 deletions

View File

@@ -0,0 +1,33 @@
import { Animation, Component, _decorator } from "cc";
import { delay } from "../Services/Utils/AsyncUtils";
const { ccclass, property } = _decorator;
@ccclass("OpenCloseAnimator")
export class OpenCloseAnimator extends Component {
@property(Animation) private animation: Animation;
private readonly openStateName = "Open";
private readonly closeStateName = "Close";
private openDuration = 0;
private closeDuration = 0;
public start(): void {
this.node.active = false;
this.openDuration = this.animation.getState(this.openStateName).duration;
this.closeDuration = this.animation.getState(this.closeStateName).duration;
}
public async playOpen(): Promise<void> {
this.node.active = true;
this.animation.play(this.openStateName);
await delay(this.openDuration);
}
public async playClose(): Promise<void> {
this.node.active = true;
this.animation.play(this.openStateName);
await delay(this.closeDuration);
this.node.active = false;
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "f9bdc2e9-98c7-4882-a58d-3a07ad74cbf5",
"files": [],
"subMetas": {},
"userData": {}
}