From b6849b164c2d6c761c4b4828a4e19b2d98b41960 Mon Sep 17 00:00:00 2001 From: TJH Date: Mon, 29 Dec 2025 09:42:40 +0800 Subject: [PATCH] =?UTF-8?q?=E6=BB=9A=E5=8A=A8=E8=8A=82=E5=A5=8F=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Game/prefabs/FeatureBuy/FeatureBuy.prefab | 8 +-- assets/Game/scripts/game/BaseRoller.ts | 55 ++++++++++--------- assets/Game/scripts/game/Roller.ts | 31 +++++++++++ assets/Game/scripts/game/RollerManager.ts | 42 ++++++++++++-- assets/Loading/scripts/comm.ts | 2 +- 5 files changed, 101 insertions(+), 37 deletions(-) diff --git a/assets/Game/prefabs/FeatureBuy/FeatureBuy.prefab b/assets/Game/prefabs/FeatureBuy/FeatureBuy.prefab index d612e1f..b05e351 100644 --- a/assets/Game/prefabs/FeatureBuy/FeatureBuy.prefab +++ b/assets/Game/prefabs/FeatureBuy/FeatureBuy.prefab @@ -1884,8 +1884,8 @@ }, "_contentSize": { "__type__": "cc.Size", - "width": 900, - "height": 250 + "width": 639, + "height": 175 }, "_anchorPoint": { "__type__": "cc.Vec2", @@ -1921,12 +1921,12 @@ "a": 255 }, "_spriteFrame": { - "__uuid__": "b321b675-c45c-4ee3-9fb3-1f21d73c380b@f9941", + "__uuid__": "a791e7f5-4c59-4365-84ad-ba6f8233341c@f9941", "__expectedType__": "cc.SpriteFrame" }, "_type": 0, "_fillType": 0, - "_sizeMode": 0, + "_sizeMode": 1, "_fillCenter": { "__type__": "cc.Vec2", "x": 0, diff --git a/assets/Game/scripts/game/BaseRoller.ts b/assets/Game/scripts/game/BaseRoller.ts index 2d1d31f..71516ef 100644 --- a/assets/Game/scripts/game/BaseRoller.ts +++ b/assets/Game/scripts/game/BaseRoller.ts @@ -340,15 +340,15 @@ export abstract class BaseRoller extends Component { getInitialSpeedData(): number[][] { return this._info.isFastSpin ? [ - [0.1, -1000], - // [0.1, 0], - [0, 4000] + [0.05, -1000], + [0.1, 0], + [0.05, 6000] ] : [ [0.05 * this._rollerId, 0], // [0.1, -1000], [0.1, 0], - [0.1, 4000] + [0.1, 5000] ]; } @@ -356,33 +356,34 @@ export abstract class BaseRoller extends Component { /** * 开始滚动 */ - startScroll() { - if (this._info.state != ROLLER_STATE.STOP) { - return; - } + // startScroll() { + // if (this._info.state != ROLLER_STATE.STOP) { + // return; + // } - // 收集现有图标 - this.collectExistingIcons(); + // // 收集现有图标 + // this.collectExistingIcons(); - // 设置速度数据 - let speedData = this.getInitialSpeedData(); + // // 设置速度数据 + // let speedData = this.getInitialSpeedData(); - // 开始加速 - this.changeState(ROLLER_STATE.ACCELERATE); - this.tweenSpeed(speedData, () => { - // 进入匀速阶段 - let uniformSpeedData = this._info.isFastSpin ? [[0]] : [[0.3]]; - this.changeState(ROLLER_STATE.UNIFORM); + // // 开始加速 + // this.changeState(ROLLER_STATE.ACCELERATE); + // this.tweenSpeed(speedData, () => { + // // 进入匀速阶段 + // let uniformSpeedData = this._info.isFastSpin ? [[0]] : [[0.6]]; + // this.changeState(ROLLER_STATE.UNIFORM); - this.tweenSpeed(uniformSpeedData, () => { - this._info.speedDataComplete = true; - let stopSpeedData = this._info.isFastSpin ? [[0, 6000]] : [[0.1, 3500]]; - if (this._info.receiveStopData) { - this.stopScrollWork(stopSpeedData); - } - }); - }); - } + // this.tweenSpeed(uniformSpeedData, () => { + // this._info.speedDataComplete = true; + // let rollerSpeed = this.row * this.iconHeight / 0.1 * 175; + // let stopSpeedData = this._info.isFastSpin ? [[0, rollerSpeed]] : [[0.4, 5500]]; + // if (this._info.receiveStopData) { + // this.stopScrollWork(stopSpeedData); + // } + // }); + // }); + // } /** * 停止滚动 diff --git a/assets/Game/scripts/game/Roller.ts b/assets/Game/scripts/game/Roller.ts index ec34ae8..526c3ee 100644 --- a/assets/Game/scripts/game/Roller.ts +++ b/assets/Game/scripts/game/Roller.ts @@ -195,6 +195,37 @@ export class Roller extends BaseRoller { } } + startScroll() { + if (this._info.state != ROLLER_STATE.STOP) return; + + this.collectExistingIcons(); + let speedData = this.getInitialSpeedData(); + + this.changeState(ROLLER_STATE.ACCELERATE); + this.tweenSpeed(speedData, () => { + let uniformSpeedData = this._info.isFastSpin ? [[0]] : [[0.6]]; + this.changeState(ROLLER_STATE.UNIFORM); + + if (this._info.isManualStop) { + this._info.speedDataComplete = true; + let stopSpeedData = this._info.isFastSpin ? [[0, 15000]] : [[0.3, 15000]]; + if (this._info.receiveStopData) { + this.stopScrollWork(stopSpeedData); + } + return; + } + + this.tweenSpeed(uniformSpeedData, () => { + this._info.speedDataComplete = true; + let rollerSpeed = this.row * this.iconHeight / 0.1 * 175; + let stopSpeedData = this._info.isFastSpin ? [[0, rollerSpeed]] : [[0.4, 5500]]; + if (this._info.receiveStopData) { + this.stopScrollWork(stopSpeedData); + } + }); + }); + } + /** * 手动停止滚动 * @param data 停止时的图标数据 diff --git a/assets/Game/scripts/game/RollerManager.ts b/assets/Game/scripts/game/RollerManager.ts index d39a5ba..71c1b45 100644 --- a/assets/Game/scripts/game/RollerManager.ts +++ b/assets/Game/scripts/game/RollerManager.ts @@ -6,6 +6,19 @@ import { AudioManager } from '../../../Loading/scripts/manager/AudioManager'; import { BaseRoller } from './BaseRoller'; let { ccclass, property, executeInEditMode } = _decorator; +// 帧到启动ID映射(按帧序) +let frameOrder = [ + { frame: 1, ids: [5] }, + { frame: 3, ids: [0] }, + { frame: 9, ids: [1, 6] }, + { frame: 14, ids: [2, 7] }, + { frame: 20, ids: [3] }, + { frame: 22, ids: [8] }, + { frame: 27, ids: [4] }, +]; + +let fps = 60; + @ccclass('RollerManager') @executeInEditMode export class RollerManager extends Component { @@ -33,7 +46,7 @@ export class RollerManager extends Component { // 竖向滚轮数组 vRollers: Roller[] = []; // 滚轮数组 - allRollers: BaseRoller[] = []; + allRollers: Roller[] = []; // 是否快速旋转 _isFastSpin: boolean = false; // 是否手动停止 @@ -486,11 +499,30 @@ export class RollerManager extends Component { // 滚轮开始滚动 startScroll() { - this.scatterPos = []; this._isManualStop = false; - this.allRollers.forEach(roller => { - roller.startScroll(); - }) + this.unscheduleAllCallbacks(); + if (this._isFastSpin) { + for (let i = 0; i < this.allRollers.length; i++) { + let roller = this.allRollers[i]; + if (roller) { + if (this._isManualStop) return; + roller.startScroll(); + } + } + } else { + frameOrder.forEach(({ frame, ids }) => { + let delay = Math.max(0, (frame - 1) / fps); + ids.forEach(id => { + let roller = this.allRollers[id]; + if (roller) { + this.scheduleOnce(() => { + if (this._isManualStop) return; + roller.startScroll(); + }, delay); + } + }); + }); + } } // 滚轮停止滚动 diff --git a/assets/Loading/scripts/comm.ts b/assets/Loading/scripts/comm.ts index 4c1174f..43bacb4 100644 --- a/assets/Loading/scripts/comm.ts +++ b/assets/Loading/scripts/comm.ts @@ -7,7 +7,7 @@ import { PREVIEW } from "cc/env" const gameId = "rp_11001"; // let apiaddr = "https://rpgames-api.rpfafafahkdev.com"; let apiaddr = ""; -let token = "eyJQIjoxMDA5NDksIkUiOjE3NjY3NTY5ODcsIlMiOjEwMDAsIkQiOiJycF8xMTAwMSJ9.P7fLsOvGnv9823PYrOrQKkio4A90CDDl-F46IJTS78I"; +let token = "eyJQIjoxMDA5NDksIkUiOjE3NjcwMTU2MDMsIlMiOjEwMDAsIkQiOiJycF8xMTAwMSJ9.ZFVTUEx8b15hwZk9wW3bJxKMkpA3IUlwbgYH5uY-uhA"; let language = "en"