feat: group 1.0.0

This commit is contained in:
zzc
2026-05-12 06:46:31 +08:00
parent 493b4709bc
commit 2fc90c1219
55 changed files with 23561 additions and 1767 deletions

View File

@@ -1,8 +1,20 @@
import { _decorator, Component, google, Label, Node } from "cc";
import {
_decorator,
Color,
Component,
google,
Label,
Node,
Sprite,
tween,
UITransform,
Vec3,
} from "cc";
import { GlobalData } from "../config/GlobalData";
import { EventDispatcher } from "../libs/EventDispatcher";
import { GameState } from "../config/Config";
import { MusicManager } from "../managers/MusicManager";
import Common from "../libs/Common";
const { ccclass, property } = _decorator;
@ccclass("GameSceneControl")
@@ -15,6 +27,14 @@ export class GameSceneControl extends Component {
@property(Label)
lifeNumLabel: Label = null;
// 开始游戏提示label
@property(Node)
startGameNode: Node = null;
// 速度提升游戏节点
@property(Node)
speedUpNode: Node = null;
// ui 节点
@property(Node)
uiNode: Node = null;
@@ -22,7 +42,14 @@ export class GameSceneControl extends Component {
// 音频管理器
musicManager: MusicManager = null;
// 屏幕宽度
screenWidth: number = 0;
onLoad() {
// 设置游戏背景和界面小恐龙头颜色
this.setPageBackgroundColor();
// 获取屏幕宽度
this.screenWidth = this.node.getComponent(UITransform).width;
// 获取音频管理器
this.musicManager = this.node.getComponent(MusicManager);
@@ -66,6 +93,7 @@ export class GameSceneControl extends Component {
// 设置游戏状态为进行中
GlobalData.gameState = GameState.PLAYING;
// 开始游戏提示动画
this.showStartGameTip();
// 1 s 后正式开始游戏
this.scheduleOnce(() => {
@@ -97,7 +125,12 @@ export class GameSceneControl extends Component {
}
// 更新速度显示
updateSpeed() {}
updateSpeed() {
this.uiNode
.getChildByName("note_info")
.getChildByName("speed")
.getComponent(Label).string = "速度: x" + GlobalData.speedRate;
}
// 暂停游戏
pauseGame() {
@@ -122,4 +155,90 @@ export class GameSceneControl extends Component {
playMusic() {
this.musicManager.play();
}
// 显示开始游戏提示
showStartGameTip() {
if (GlobalData.speedRate > 1) {
// 显示速度提升提示
this.speedUpTipAnim();
} else {
// 首次开始游戏动画
this.firstStartGameAnim();
}
}
// 显示速度提升提示
speedUpTipAnim() {
// 设置速度提升提示文字
this.speedUpNode.getComponent(Label).string =
`速度提升: (x ${GlobalData.speedRate})`;
// 首先显示节点
this.speedUpNode.active = true;
// 获取原有位置
const oriPos = this.speedUpNode.getPosition().clone();
// tween 向右移动半屏距离 然后停留 0.5 s 消失
tween(this.speedUpNode)
.to(0.3, {
position: new Vec3(oriPos.x + this.screenWidth / 2 + 200, oriPos.y, 0),
})
.delay(0.5)
.to(0.3, {
position: new Vec3(oriPos.x + this.screenWidth + 200, oriPos.y, 0),
})
.call(() => {
// 消失节点
this.speedUpNode.active = false;
// 重置当前节点的位置
this.speedUpNode.setPosition(oriPos);
})
.start();
}
// 首次开始游戏动画
firstStartGameAnim() {
// 首先显示节点
this.startGameNode.active = true;
// 获取原有位置
const oriPos = this.startGameNode.getPosition().clone();
// tween 向右移动半屏距离 然后停留 0.5 s 消失
tween(this.startGameNode)
.to(0.3, {
position: new Vec3(oriPos.x + this.screenWidth / 2 + 200, oriPos.y, 0),
})
.delay(0.5)
.to(0.3, {
position: new Vec3(oriPos.x + this.screenWidth + 200, oriPos.y, 0),
})
.call(() => {
// 消失节点
this.startGameNode.active = false;
// 重置当前节点的位置
this.startGameNode.setPosition(oriPos);
})
.start();
}
// 设置页面的背景颜色
setPageBackgroundColor() {
// 获取当前小恐龙信息
const dinoInfo = GlobalData.currentDinoInfo;
// 获取背景色
const backgroundColor = new Color(dinoInfo.bgColor);
// 获取小恐龙颜色
const dinoColor = new Color(dinoInfo.dinoColor);
// 获取小恐龙 ui 头节点
const dinoHeadNode = this.uiNode
.getChildByName("life")
.getChildByName("dino_head");
// 设置小恐龙 ui 头节点的颜色
dinoHeadNode.getComponent(Sprite).color = dinoColor;
// 设置页面的背景颜色
Common.setPageBackgroundColor(
this.node.getChildByName("bg"),
backgroundColor,
);
}
}