Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
SSAPP2502
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
template admin
SSAPP2502
Commits
638eaea4
Commit
638eaea4
authored
Aug 03, 2025
by
Tt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
完美循环
parent
aa363c89
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
62 additions
and
18 deletions
+62
-18
SSAPP2501.ts
assets/SSAPP2501/scene/SSAPP2501.ts
+62
-18
No files found.
assets/SSAPP2501/scene/SSAPP2501.ts
View file @
638eaea4
...
...
@@ -352,6 +352,14 @@ export default class SceneComponent extends MyCocosSceneComponent {
return
;
}
// 如果未回答题目数量小于5,停止滚动并重新刷新列表
if
(
unansweredQuestions
.
length
<
5
)
{
this
.
needScroll
=
false
;
// 停止滚动
// 重新显示页面
this
.
showPage
();
return
;
}
// 将未回答的题目添加到待添加队列
this
.
pendingCandyData
=
unansweredQuestions
;
}
...
...
@@ -434,7 +442,37 @@ export default class SceneComponent extends MyCocosSceneComponent {
// 更新待添加的糖果数据队列,获取最新的未回答题目
// 这样在无限滚动时会排除刚刚回答正确的题目
this
.
pendingCandyData
=
this
.
getUnansweredQuestions
();
const
unansweredQuestions
=
this
.
getUnansweredQuestions
();
this
.
pendingCandyData
=
unansweredQuestions
;
// // 如果未回答题目数量小于5,停止滚动并重新刷新列表
// if (unansweredQuestions.length < 5 && unansweredQuestions.length > 0) {
// this.needScroll = false; // 停止滚动
// // 延迟一段时间后重新显示页面
// this.scheduleOnce(() => {
// this.showPage();
// }, 0.1); // 延迟1秒,给用户时间看到当前页面的完成状态
// return;
// }
// 在滚动列表中查找并隐藏对应题目的节点
if
(
this
.
touchData
&&
this
.
layout
&&
this
.
layout
.
childrenCount
>
0
)
{
const
currentQuestionId
=
this
.
touchData
.
id
;
// 遍历布局中的所有节点
for
(
let
i
=
0
;
i
<
this
.
layout
.
childrenCount
;
i
++
)
{
const
node
=
this
.
layout
.
children
[
i
]
as
CandyNode
;
// 检查节点是否有data属性且id匹配
if
(
node
.
data
&&
node
.
data
.
id
===
currentQuestionId
)
{
// 从活跃节点列表中移除
const
nodeIndex
=
this
.
activeNodes
.
indexOf
(
node
);
if
(
nodeIndex
!==
-
1
)
{
this
.
activeNodes
.
splice
(
nodeIndex
,
1
);
}
// 隐藏节点
node
.
active
=
false
;
}
}
}
// 检查当前页面是否所有火苗都已处理完毕
if
(
this
.
activeNodes
.
length
===
0
)
{
...
...
@@ -484,15 +522,21 @@ export default class SceneComponent extends MyCocosSceneComponent {
Game
.
getIns
().
addPage
();
// 获取最新的未回答题目
this
.
pendingCandyData
=
this
.
getUnansweredQuestions
();
const
unansweredQuestions
=
this
.
getUnansweredQuestions
();
this
.
pendingCandyData
=
unansweredQuestions
;
// 如果没有未回答的题目,游戏结束
if
(
this
.
pendingCandyData
.
length
===
0
)
{
if
(
unansweredQuestions
.
length
===
0
)
{
// 可以在这里添加游戏结束逻辑
this
.
gameOver
();
return
;
}
// 如果未回答题目数量小于5,设置不滚动
if
(
unansweredQuestions
.
length
<
5
)
{
this
.
needScroll
=
false
;
}
// 重新显示页面
this
.
showPage
();
}
...
...
@@ -822,24 +866,24 @@ export default class SceneComponent extends MyCocosSceneComponent {
this
.
layout
.
x
-=
frameScrollDistance
;
// 累计滚动距离
this
.
scrollDistance
=
Math
.
abs
(
this
.
layout
.
x
)
-
this
.
addCount
*
2
00
;
if
(
!
this
.
addCount
)
{
this
.
addCount
=
1
;
this
.
addNewCandyNode
();
// 添加新节点
}
else
if
(
this
.
scrollDistance
>=
200
&&
this
.
pendingCandyData
.
length
>
0
)
{
this
.
addCount
++
;
this
.
addNewCandyNode
();
// 添加新节点
}
else
if
(
this
.
pendingCandyData
.
length
==
0
)
{
let
unansweredQuestions
=
this
.
getUnansweredQuestions
();
this
.
pendingCandyData
=
unansweredQuestions
.
concat
()
;
this
.
addCount
++
;
this
.
addNewCandyNode
();
// 添加新节点
this
.
scrollDistance
=
Math
.
abs
(
this
.
layout
.
x
)
-
this
.
addCount
*
1
00
;
if
(
this
.
layout
.
childrenCount
<=
6
)
{
if
(
!
this
.
addCount
&&
this
.
pendingCandyData
.
length
>
0
)
{
this
.
addCount
=
1
;
this
.
addNewCandyNode
();
// 添加新节点
}
else
{
if
(
this
.
pendingCandyData
.
length
==
0
)
{
let
unansweredQuestions
=
this
.
getUnansweredQuestions
();
this
.
pendingCandyData
=
unansweredQuestions
.
concat
();
}
this
.
addCount
++
;
this
.
addNewCandyNode
();
// 添加新节点
}
}
// 检查第一个糖果节点是否已经移出视图
const
firstCandy
=
this
.
layout
.
children
[
0
];
if
(
firstCandy
&&
firstCandy
.
x
+
this
.
layout
.
x
+
firstCandy
.
width
/
2
<
-
this
.
layout
.
parent
.
width
/
2
)
{
if
(
firstCandy
&&
firstCandy
.
x
+
this
.
layout
.
x
+
firstCandy
.
width
/
2
<
0
)
{
// 从活跃节点数组中移除第一个节点
if
(
this
.
activeNodes
.
includes
(
firstCandy
))
{
const
index
=
this
.
activeNodes
.
indexOf
(
firstCandy
);
...
...
@@ -852,7 +896,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
firstCandy
.
removeFromParent
();
firstCandy
.
destroy
();
console
.
log
(
"
当前节点数量
"
+
this
.
layout
.
childrenCount
);
console
.
log
(
"
当前节点数量
"
+
this
.
layout
.
childrenCount
);
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment