|
|
@@ -2,7 +2,7 @@
|
|
|
* @Author: mojunshou 1637302775@qq.com
|
|
|
* @Date: 2025-03-20 15:01:09
|
|
|
* @LastEditors: mojunshou 1637302775@qq.com
|
|
|
- * @LastEditTime: 2025-04-17 18:12:06
|
|
|
+ * @LastEditTime: 2025-04-17 19:26:14
|
|
|
* @Description: 消除游戏主场景
|
|
|
*/
|
|
|
import { _decorator, Button, Color, EventTouch, instantiate, JsonAsset, Label, Node, Prefab, randomRangeInt, Sprite, tween, UITransform, Vec2, Vec3, Widget } from "cc";
|
|
|
@@ -129,6 +129,9 @@ export class EliminateViewComp extends CCComp {
|
|
|
@property({ type: Node, displayName: "引导层" })
|
|
|
private guideNode: Node = null!;
|
|
|
|
|
|
+ @property({ type: Node, displayName: "ComboNode" })
|
|
|
+ private comboNode: Node = null!;
|
|
|
+
|
|
|
|
|
|
//游戏配置行列
|
|
|
private rows: number = 8; // 行数
|
|
|
@@ -1232,7 +1235,7 @@ export class EliminateViewComp extends CCComp {
|
|
|
|
|
|
// 显示消除次数动画
|
|
|
showEliminateCountAnimation(yPosition: number, eliminationCount: number) {
|
|
|
- if (!this.lab_total) return;
|
|
|
+ if (!this.comboNode) return;
|
|
|
|
|
|
// 如果需要重置计数器,先将计数归零
|
|
|
if (this.shouldResetEliminateCount) {
|
|
|
@@ -1243,17 +1246,20 @@ export class EliminateViewComp extends CCComp {
|
|
|
this.currentCombo += eliminationCount;
|
|
|
|
|
|
// 复制总次数Label
|
|
|
- const totalLabel = instantiate(this.lab_total.node);
|
|
|
- totalLabel.active = true;
|
|
|
+ const comboNode = instantiate(this.comboNode);
|
|
|
+ comboNode.active = true;
|
|
|
|
|
|
// 设置文本
|
|
|
- const label = totalLabel.getComponent(Label);
|
|
|
+ const label = comboNode.getChildByName("lab_combo");
|
|
|
if (label) {
|
|
|
- label.string = `Combo${this.currentCombo}`;
|
|
|
+ const labelComponent = label.getComponent(Label);
|
|
|
+ if (labelComponent) {
|
|
|
+ labelComponent.string = `${this.currentCombo}`;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// 添加到场景中
|
|
|
- this.node.addChild(totalLabel);
|
|
|
+ this.node.addChild(comboNode);
|
|
|
|
|
|
// 计算网格区域的X轴中心位置,Y轴使用传入的消除行位置
|
|
|
const centerPos = new Vec3();
|
|
|
@@ -1263,11 +1269,11 @@ export class EliminateViewComp extends CCComp {
|
|
|
centerPos.set(worldPos.x, yPosition, worldPos.z);
|
|
|
}
|
|
|
|
|
|
- totalLabel.setWorldPosition(centerPos);
|
|
|
+ comboNode.setWorldPosition(centerPos);
|
|
|
|
|
|
// 创建动画效果
|
|
|
const num = this.isDoubleSpeed ? this.doubleNum : 1;
|
|
|
- tween(totalLabel)
|
|
|
+ tween(comboNode)
|
|
|
.to(0.3 / num, {
|
|
|
scale: new Vec3(1.5, 1.5, 1.5),
|
|
|
opacity: 255
|
|
|
@@ -1275,11 +1281,11 @@ export class EliminateViewComp extends CCComp {
|
|
|
.delay(0.5 / num) // 停留更长时间
|
|
|
.to(0.4 / num, {
|
|
|
scale: new Vec3(1.2, 1.2, 1.2),
|
|
|
- position: new Vec3(totalLabel.position.x, totalLabel.position.y + 50, 0),
|
|
|
+ position: new Vec3(comboNode.position.x, comboNode.position.y + 50, 0),
|
|
|
opacity: 0
|
|
|
})
|
|
|
.call(() => {
|
|
|
- totalLabel.destroy();
|
|
|
+ comboNode.destroy();
|
|
|
})
|
|
|
.start();
|
|
|
}
|
|
|
@@ -1512,19 +1518,19 @@ export class EliminateViewComp extends CCComp {
|
|
|
}
|
|
|
|
|
|
// 保存原始位置
|
|
|
- const originalPosition = this.tweenWechatNode.position;
|
|
|
+ const originalPosition = this.amountLb.node.worldPosition;
|
|
|
|
|
|
//设置原始位置
|
|
|
- this.tweenWechatNode.setPosition(originalPosition);
|
|
|
+ this.tweenWechatNode.setWorldPosition(originalPosition);
|
|
|
// 显示节点
|
|
|
this.tweenWechatNode.active = true;
|
|
|
|
|
|
// 创建向上移动的动画
|
|
|
tween(this.tweenWechatNode)
|
|
|
.to(0.8, {
|
|
|
- position: new Vec3(
|
|
|
+ worldPosition: new Vec3(
|
|
|
originalPosition.x,
|
|
|
- originalPosition.y + 100,
|
|
|
+ originalPosition.y + 50,
|
|
|
originalPosition.z
|
|
|
),
|
|
|
opacity: 255
|
|
|
@@ -1532,9 +1538,9 @@ export class EliminateViewComp extends CCComp {
|
|
|
.to(0.2, { opacity: 0 })
|
|
|
.call(() => {
|
|
|
//设置位置y-100
|
|
|
- this.tweenWechatNode.setPosition(new Vec3(
|
|
|
+ this.tweenWechatNode.setWorldPosition(new Vec3(
|
|
|
originalPosition.x,
|
|
|
- originalPosition.y - 100,
|
|
|
+ originalPosition.y,
|
|
|
originalPosition.z
|
|
|
))
|
|
|
this.tweenWechatNode.active = false;
|
|
|
@@ -1562,27 +1568,27 @@ export class EliminateViewComp extends CCComp {
|
|
|
scoreLabel.string = "+" + formattedValue;
|
|
|
}
|
|
|
// 保存原始位置
|
|
|
- const originalPosition = this.tweenRedNode.position;
|
|
|
+ const originalPosition = this.awardLb.node.worldPosition;
|
|
|
//设置原始位置
|
|
|
- this.tweenRedNode.setPosition(originalPosition);
|
|
|
+ this.tweenRedNode.setWorldPosition(originalPosition);
|
|
|
// 显示节点
|
|
|
this.tweenRedNode.active = true;
|
|
|
// 创建向上移动的动画
|
|
|
const num = this.isDoubleSpeed ? this.doubleNum : 1;
|
|
|
tween(this.tweenRedNode)
|
|
|
.to(0.8 / num, {
|
|
|
- position: new Vec3(
|
|
|
+ worldPosition: new Vec3(
|
|
|
originalPosition.x,
|
|
|
- originalPosition.y + 100,
|
|
|
+ originalPosition.y + 50,
|
|
|
originalPosition.z
|
|
|
),
|
|
|
opacity: 255
|
|
|
})
|
|
|
.to(0.2 / num, { opacity: 0 })
|
|
|
.call(() => {
|
|
|
- this.tweenRedNode.setPosition(new Vec3(
|
|
|
+ this.tweenRedNode.setWorldPosition(new Vec3(
|
|
|
originalPosition.x,
|
|
|
- originalPosition.y - 100,
|
|
|
+ originalPosition.y,
|
|
|
originalPosition.z
|
|
|
))
|
|
|
|
|
|
@@ -1803,7 +1809,6 @@ export class EliminateViewComp extends CCComp {
|
|
|
break;
|
|
|
case GameState.GAME_OVER:
|
|
|
//打开游戏结束界面
|
|
|
- this.gameState = GameState.READY
|
|
|
this.autoState = false;
|
|
|
this.adShowingFlag = false;
|
|
|
//自动按钮改为手动
|