Commit 378f521f authored by Tt's avatar Tt

处理基础完成

parent c43b7c1b
This diff is collapsed.
This diff is collapsed.
...@@ -163,7 +163,7 @@ export default class Game { ...@@ -163,7 +163,7 @@ export default class Game {
this.start = false; this.start = false;
this.data = []; this.data = [];
this.page = 0; this.page = 0;
this.pageSize = 6; this.pageSize = 0; // 移除每页6个的限制
this.player = new Player(); this.player = new Player();
this.state = GAME_STATE.WAIT; this.state = GAME_STATE.WAIT;
} }
...@@ -187,7 +187,7 @@ export default class Game { ...@@ -187,7 +187,7 @@ export default class Game {
* @param data 游戏配置数据 * @param data 游戏配置数据
*/ */
public init(data) { public init(data) {
this.pageSize = 6; // 每页最多6个数据 this.pageSize = 0; // 移除每页数据限制
this.question = { text: data.questionText, audio: data.questionTextAudio }; this.question = { text: data.questionText, audio: data.questionTextAudio };
this.title = data.title; this.title = data.title;
this.bgAudio = data.bgAudio || ""; this.bgAudio = data.bgAudio || "";
...@@ -213,39 +213,32 @@ export default class Game { ...@@ -213,39 +213,32 @@ export default class Game {
this.total = this.data.length; this.total = this.data.length;
} }
/** /**
* 获取当前页的数据 * 获取所有数据
* @param {number} pageIndex 页码索引,默认为当前页码(页码从0开始) * @returns {Array<Option>} 所有选项数据数组
* @returns {Array<Option>} 当前页的选项数据数组
*/ */
getPageData(pageIndex?: number) { getPageData(pageIndex?: number) {
// 如果没有指定页码索引,则使用当前页码(页码从0开始) // 直接返回所有数据,忽略页码参数
const index = pageIndex !== undefined ? pageIndex : this.page; // 如果数据为空,返回空数组
if (!this.data || this.data.length === 0) {
// 计算当前页的起始索引和结束索引
const startIndex = index * this.pageSize;
const endIndex = Math.min(startIndex + this.pageSize, this.data.length);
// 如果起始索引超出数据范围,返回空数组
if (startIndex >= this.data.length) {
return []; return [];
} }
// 提取当前页的数据并转换为Option对象 // 提取所有数据并转换为Option对象
const pageData: Array<Option> = []; const allData: Array<Option> = [];
for (let i = startIndex; i < endIndex; i++) { for (let i = 0; i < this.data.length; i++) {
pageData.push(new Option(this.data[i], i)); allData.push(new Option(this.data[i], i));
} }
return pageData; return allData;
} }
/** /**
* 获取总页数 * 获取总页数
* @returns 总页数(向上取整) * @returns 总是返回1,因为所有数据都在一页中
*/ */
getTotalPageNum() { getTotalPageNum() {
return Math.ceil(this.data.length / this.pageSize); return 1; // 所有数据都在一页中
} }
/** /**
...@@ -272,15 +265,16 @@ export default class Game { ...@@ -272,15 +265,16 @@ export default class Game {
} }
/** /**
* 获取当前页的卡片信息 * 获取当前卡片信息
* @returns 当前页的选项数据数组 * @returns 当前选项数据
*/ */
getCardInfo() { getCardInfo() {
const currentPageData = this.getPageData(); const allData = this.getPageData();
if (currentPageData.length === 0) { if (allData.length === 0) {
return null; return null;
} }
return currentPageData[0]; // 返回当前页的第一个选项 // 根据当前页码返回对应的选项
return allData[this.page] || null;
} }
/** /**
......
{
"ver": "2.3.5",
"uuid": "087cef1e-4484-4ebb-9b61-1c585ad0d429",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 1280,
"height": 716,
"platformSettings": {},
"subMetas": {
"标注 弹出文字样式-短单词 字号": {
"ver": "1.0.4",
"uuid": "fb2c7ec2-630f-481b-b871-329f74b4a806",
"rawTextureUuid": "087cef1e-4484-4ebb-9b61-1c585ad0d429",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 1280,
"height": 716,
"rawWidth": 1280,
"rawHeight": 716,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
...@@ -4588,6 +4588,7 @@ declare namespace cc { ...@@ -4588,6 +4588,7 @@ declare namespace cc {
/** !#en Returns a normalized vector representing the forward direction (Z axis) of the node in world space. /** !#en Returns a normalized vector representing the forward direction (Z axis) of the node in world space.
!#zh 获取节点正前方(z 轴)面对的方向,返回值为世界坐标系下的归一化向量 */ !#zh 获取节点正前方(z 轴)面对的方向,返回值为世界坐标系下的归一化向量 */
forward: Vec3; forward: Vec3;
data: any;
/** /**
@param name name @param name name
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment