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
3fd50703
Commit
3fd50703
authored
Aug 03, 2025
by
Tt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
127b7fa0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
58 deletions
+14
-58
SSAPP2501.ts
assets/SSAPP2501/scene/SSAPP2501.ts
+14
-58
No files found.
assets/SSAPP2501/scene/SSAPP2501.ts
View file @
3fd50703
...
@@ -264,12 +264,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -264,12 +264,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
const
bgBrokenNode
=
candyNode
.
getChildByName
(
'
bg_broken
'
);
const
bgBrokenNode
=
candyNode
.
getChildByName
(
'
bg_broken
'
);
// 设置背景状态:默认显示bg_full,隐藏bg_broken
// 设置背景状态:默认显示bg_full,隐藏bg_broken
if
(
bgFullNode
)
{
pg
.
view
.
visible
(
bgFullNode
,
true
);
bgFullNode
.
active
=
true
;
pg
.
view
.
visible
(
bgBrokenNode
,
false
);
}
if
(
bgBrokenNode
)
{
bgBrokenNode
.
active
=
false
;
}
// 根据索引设置糖果图标(candy_0 ~ candy_4)
// 根据索引设置糖果图标(candy_0 ~ candy_4)
if
(
iconNode
)
{
if
(
iconNode
)
{
...
@@ -293,10 +289,6 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -293,10 +289,6 @@ export default class SceneComponent extends MyCocosSceneComponent {
* 添加了糖果区域滚动逻辑
* 添加了糖果区域滚动逻辑
*/
*/
showPage
()
{
showPage
()
{
// 获取当前页码
const
currentPage
=
Game
.
getIns
().
getCurrentPageNum
();
const
prevPage
=
currentPage
-
1
;
// 获取当前页的数据
// 获取当前页的数据
const
pageData
=
Game
.
getIns
().
getPageData
();
const
pageData
=
Game
.
getIns
().
getPageData
();
...
@@ -305,58 +297,22 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -305,58 +297,22 @@ export default class SceneComponent extends MyCocosSceneComponent {
this
.
needScroll
=
false
;
this
.
needScroll
=
false
;
this
.
pendingCandyData
=
[];
this
.
pendingCandyData
=
[];
// 清空活跃火苗节点数组
this
.
activeFireNodes
=
[];
this
.
activeFireNodes
=
[];
// 清空糖果区域
this
.
layout
.
removeAllChildren
();
this
.
layout
.
removeAllChildren
();
// 根据当前数据,将糖果节点克隆到糖果区域
const
len
=
5
;
if
(
pageData
&&
pageData
.
length
>
0
)
{
this
.
needScroll
=
true
;
// 确定是否需要滚动
const
visibleData
=
pageData
.
slice
(
0
,
len
);
const
len
=
10
;
this
.
pendingCandyData
=
pageData
.
slice
(
len
);
if
(
pageData
.
length
>
len
)
{
visibleData
.
forEach
((
data
,
index
)
=>
{
this
.
needScroll
=
true
;
const
candyNode
=
cc
.
instantiate
(
this
.
item
)
as
CandyNode
;
// 将前5个数据显示在屏幕上,其余放入待添加队列
this
.
layout
.
addChild
(
candyNode
);
const
visibleData
=
pageData
.
slice
(
0
,
len
);
this
.
updateItem
(
candyNode
,
data
,
index
);
this
.
pendingCandyData
=
pageData
.
slice
(
len
);
if
(
index
===
0
)
{
this
.
candyNodeWidth
=
candyNode
.
width
;
// 遍历可见数据
visibleData
.
forEach
((
data
,
index
)
=>
{
// 克隆糖果节点
const
candyNode
=
cc
.
instantiate
(
this
.
item
)
as
CandyNode
;
// 使用updateItem方法更新节点内容,传入索引以显示对应的糖果图标
this
.
updateItem
(
candyNode
,
data
,
index
);
// 记录糖果节点宽度(用于滚动计算)
if
(
index
===
0
)
{
this
.
candyNodeWidth
=
candyNode
.
width
;
}
// 将糖果节点添加到活跃火苗节点数组
this
.
activeFireNodes
.
push
(
candyNode
);
// 将糖果节点添加到糖果区域
this
.
layout
.
addChild
(
candyNode
);
});
}
else
{
// 数量不超过5个,正常显示所有节点
pageData
.
forEach
((
data
,
index
)
=>
{
// 克隆糖果节点
const
candyNode
=
cc
.
instantiate
(
this
.
item
)
as
CandyNode
;
// 使用updateItem方法更新节点内容,传入索引以显示对应的糖果图标
this
.
updateItem
(
candyNode
,
data
,
index
);
// 将糖果节点添加到活跃火苗节点数组
this
.
activeFireNodes
.
push
(
candyNode
);
// 将糖果节点添加到糖果区域
this
.
layout
.
addChild
(
candyNode
);
});
}
}
}
this
.
activeFireNodes
.
push
(
candyNode
);
});
}
}
/**
/**
...
...
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