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
127b7fa0
Commit
127b7fa0
authored
Aug 03, 2025
by
Tt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
处理结束
parent
53d83a1e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
64 deletions
+28
-64
SSAPP2501.ts
assets/SSAPP2501/scene/SSAPP2501.ts
+28
-64
No files found.
assets/SSAPP2501/scene/SSAPP2501.ts
View file @
127b7fa0
...
...
@@ -260,10 +260,9 @@ export default class SceneComponent extends MyCocosSceneComponent {
candyNode
.
x
=
index
*
320
+
150
;
// 获取子节点
const
iconNode
=
candyNode
.
getChildByName
(
'
icon
'
);
const
labelNode
=
candyNode
.
getChildByName
(
'
label
'
);
const
bgFullNode
=
candyNode
.
getChildByName
(
'
bg_full
'
);
const
bgBrokenNode
=
candyNode
.
getChildByName
(
'
bg_broken
'
);
// 设置背景状态:默认显示bg_full,隐藏bg_broken
if
(
bgFullNode
)
{
bgFullNode
.
active
=
true
;
...
...
@@ -271,43 +270,22 @@ export default class SceneComponent extends MyCocosSceneComponent {
if
(
bgBrokenNode
)
{
bgBrokenNode
.
active
=
false
;
}
// 根据索引设置糖果图标(candy_0 ~ candy_4)
if
(
iconNode
)
{
// 确保索引在有效范围内(0-4)
const
candyIndex
=
Math
.
min
(
Math
.
max
(
index
,
0
),
4
)
;
const
candyIndex
=
index
%
5
;
const
candyIconName
=
`candy_
${
candyIndex
}
`
;
// 使用pg.view.setImg加载对应的糖果图标
pg
.
view
.
set
Img
(
iconNode
,
candyIconName
);
pg
.
view
.
set
NodeImg
(
iconNode
,
pg
.
view
.
find
(
this
,
`res/img/
${
candyIconName
}
`
)
);
iconNode
.
active
=
true
;
}
// 根据数据类型设置显示内容
if
(
data
.
type
===
'
img
'
&&
data
.
picUrl
)
{
// 如果有图片URL,使用网络图片
if
(
iconNode
)
{
pg
.
view
.
setNetImg
(
iconNode
,
data
.
picUrl
,
{
w
:
200
,
h
:
200
});
iconNode
.
active
=
true
;
}
if
(
labelNode
)
{
labelNode
.
active
=
false
;
}
}
else
if
(
data
.
txt
)
{
// 显示文本,保持图标显示
if
(
labelNode
)
{
pg
.
view
.
setString
(
labelNode
,
data
.
txt
);
labelNode
.
active
=
true
;
}
}
// 添加点击事件(如果节点上没有该事件)
if
(
!
candyNode
.
hasEventListener
(
cc
.
Node
.
EventType
.
TOUCH_END
))
{
candyNode
.
on
(
cc
.
Node
.
EventType
.
TOUCH_END
,
this
.
onTouchFireNode
,
this
);
}
pg
.
view
.
touchOn
(
candyNode
,
this
.
onTouchFireNode
,
this
);
}
/**
* 显示当前页面
* 移除了与页面a和页面b相关的逻辑
...
...
@@ -336,20 +314,21 @@ export default class SceneComponent extends MyCocosSceneComponent {
// 根据当前数据,将糖果节点克隆到糖果区域
if
(
pageData
&&
pageData
.
length
>
0
)
{
// 确定是否需要滚动
if
(
pageData
.
length
>
5
)
{
const
len
=
10
;
if
(
pageData
.
length
>
len
)
{
this
.
needScroll
=
true
;
// 将前5个数据显示在屏幕上,其余放入待添加队列
const
visibleData
=
pageData
.
slice
(
0
,
5
);
this
.
pendingCandyData
=
pageData
.
slice
(
5
);
const
visibleData
=
pageData
.
slice
(
0
,
len
);
this
.
pendingCandyData
=
pageData
.
slice
(
len
);
// 遍历可见数据
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
;
...
...
@@ -366,7 +345,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
pageData
.
forEach
((
data
,
index
)
=>
{
// 克隆糖果节点
const
candyNode
=
cc
.
instantiate
(
this
.
item
)
as
CandyNode
;
// 使用updateItem方法更新节点内容,传入索引以显示对应的糖果图标
this
.
updateItem
(
candyNode
,
data
,
index
);
...
...
@@ -379,34 +358,19 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
}
}
/**
* 添加新的糖果节点到布局的最后位置
*/
private
addNewCandyNode
()
{
if
(
this
.
pendingCandyData
.
length
===
0
||
!
this
.
item
)
return
;
// 获取待添加的第一个数据
const
data
=
this
.
pendingCandyData
.
shift
();
// 克隆糖果节点
const
candyNode
=
cc
.
instantiate
(
this
.
item
)
as
CandyNode
;
// 使用updateItem方法更新节点内容
// 使用当前显示的节点数量作为索引
this
.
layout
.
addChild
(
candyNode
);
const
index
=
this
.
layout
.
childrenCount
;
this
.
updateItem
(
candyNode
,
data
,
index
);
// 将新节点放在布局的最后位置
this
.
layout
.
addChild
(
candyNode
);
// 将糖果节点添加到活跃火苗节点数组
this
.
activeFireNodes
.
push
(
candyNode
);
}
/**
* 移除了消防车点击事件处理方法
*/
/**
* 火苗点击事件处理
* 保存触摸数据并显示卡片
...
...
@@ -430,18 +394,18 @@ export default class SceneComponent extends MyCocosSceneComponent {
onFireSuccess
()
{
const
fireNode
=
this
.
currentFireNode
;
// 更新糖果背景状态:隐藏bg_full,显示bg_broken
const
bgFullNode
=
fireNode
.
getChildByName
(
'
bg_full
'
);
const
bgBrokenNode
=
fireNode
.
getChildByName
(
'
bg_broken
'
);
if
(
bgFullNode
)
{
bgFullNode
.
active
=
false
;
}
if
(
bgBrokenNode
)
{
bgBrokenNode
.
active
=
true
;
}
// 如果不需要滚动,则直接从活跃列表中移除并隐藏节点
if
(
!
this
.
needScroll
)
{
// 从活跃火苗列表中移除当前火苗
...
...
@@ -449,7 +413,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
if
(
index
!==
-
1
)
{
this
.
activeFireNodes
.
splice
(
index
,
1
);
}
// 隐藏对应的fire节点
fireNode
.
active
=
false
;
}
else
{
...
...
@@ -486,11 +450,11 @@ export default class SceneComponent extends MyCocosSceneComponent {
// 确保火苗节点保持显示状态
if
(
fireNode
)
{
fireNode
.
active
=
true
;
// 更新糖果背景状态:显示bg_full,隐藏bg_broken
const
bgFullNode
=
fireNode
.
getChildByName
(
'
bg_full
'
);
const
bgBrokenNode
=
fireNode
.
getChildByName
(
'
bg_broken
'
);
if
(
bgFullNode
)
{
bgFullNode
.
active
=
true
;
}
...
...
@@ -827,7 +791,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
if
(
this
.
needScroll
&&
this
.
layout
&&
this
.
layout
.
childrenCount
>
0
)
{
// 移动糖果区域
this
.
layout
.
x
-=
this
.
scrollSpeed
*
dt
;
// 检查第一个糖果节点是否已经移出视图
const
firstCandy
=
this
.
layout
.
children
[
0
];
if
(
firstCandy
&&
firstCandy
.
x
+
this
.
layout
.
x
+
firstCandy
.
width
/
2
<
-
this
.
layout
.
parent
.
width
/
2
)
{
...
...
@@ -838,18 +802,18 @@ export default class SceneComponent extends MyCocosSceneComponent {
this
.
activeFireNodes
.
splice
(
index
,
1
);
}
}
// 从布局中移除第一个节点
firstCandy
.
removeFromParent
();
firstCandy
.
destroy
();
// 如果有待添加的糖果数据,添加新的糖果节点
if
(
this
.
pendingCandyData
.
length
>
0
)
{
this
.
addNewCandyNode
();
}
}
}
// 移除了提示动画逻辑
}
...
...
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