滚动节奏调整
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 2m9s

This commit is contained in:
TJH 2025-12-29 09:42:40 +08:00
parent 5b25f3b84b
commit b6849b164c
5 changed files with 101 additions and 37 deletions

View File

@ -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,

View File

@ -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);
// }
// });
// });
// }
/**
*

View File

@ -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

View File

@ -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);
}
});
});
}
}
// 滚轮停止滚动

View File

@ -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"