first commit

This commit is contained in:
zzc
2026-04-30 00:13:37 +08:00
commit 493b4709bc
189 changed files with 24791 additions and 0 deletions

View File

@@ -0,0 +1,93 @@
import { _decorator, Component, Label, Node, Animation, tween, Vec3 } from "cc";
import { EventDispatcher } from "../libs/EventDispatcher";
const { ccclass, property } = _decorator;
@ccclass("BombEffect")
export class BombEffect extends Component {
// 提示语数组
private bombTips: string[] = [
"完美",
"真棒",
"棒呆",
"太棒了",
"无敌",
"超棒",
"天才",
];
// 爆炸标题 Lable
@property(Label)
private bombLabel: Label = null;
// 爆炸图片节点
@property(Node)
private bombImageNode: Node = null;
// 动画组件
private bombAnimation: Animation = null;
onLoad() {
// 初始化动画组件
this.bombAnimation = this.bombImageNode.getComponent(Animation);
// 监听动画完成事件
this.bombAnimation.on(
Animation.EventType.FINISHED,
this.onAnimationFinished,
this,
);
// 设置随机的提示语
this.setBombTip();
// 监听小恐龙吃到音符事件
EventDispatcher.getTarget().on(
EventDispatcher.DINO_EAT_NOTE,
this.hideBombTip,
this,
);
}
// 动画完成事件
private onAnimationFinished() {
// 隐藏爆炸图片
this.bombImageNode.active = false;
// 标题缩小到 0.1
tween(this.bombLabel.node)
.to(0.2, { scale: new Vec3(0.1, 0.1, 1) })
.call(() => {
// 销毁整个特效节点
this.node.destroy();
})
.start();
}
// 播放爆炸特效
public playBombEffect() {
// 播放动画
this.bombAnimation.play("bomb");
// 显示爆炸标题
this.bombLabel.node.active = true;
// 放大标题1.1倍速
tween(this.bombLabel.node)
.to(0.5, { scale: new Vec3(1.1, 1.1, 1) })
.start();
}
// 设置随机的提示语
private setBombTip() {
let randomIndex = Math.floor(Math.random() * this.bombTips.length);
// 设置爆炸标题的文本
this.bombLabel.string = this.bombTips[randomIndex];
}
// 隐藏爆炸标题
private hideBombTip() {
// 隐藏爆炸标题
this.bombLabel.node.active = false;
}
// 隐藏爆炸特效
private hideBombEffect() {
// 隐藏爆炸特效
this.node.active = false;
}
update(deltaTime: number) {}
}