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
Show 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,7 +260,6 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -260,7 +260,6 @@ export default class SceneComponent extends MyCocosSceneComponent {
candyNode
.
x
=
index
*
320
+
150
;
candyNode
.
x
=
index
*
320
+
150
;
// 获取子节点
// 获取子节点
const
iconNode
=
candyNode
.
getChildByName
(
'
icon
'
);
const
iconNode
=
candyNode
.
getChildByName
(
'
icon
'
);
const
labelNode
=
candyNode
.
getChildByName
(
'
label
'
);
const
bgFullNode
=
candyNode
.
getChildByName
(
'
bg_full
'
);
const
bgFullNode
=
candyNode
.
getChildByName
(
'
bg_full
'
);
const
bgBrokenNode
=
candyNode
.
getChildByName
(
'
bg_broken
'
);
const
bgBrokenNode
=
candyNode
.
getChildByName
(
'
bg_broken
'
);
...
@@ -275,37 +274,16 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -275,37 +274,16 @@ export default class SceneComponent extends MyCocosSceneComponent {
// 根据索引设置糖果图标(candy_0 ~ candy_4)
// 根据索引设置糖果图标(candy_0 ~ candy_4)
if
(
iconNode
)
{
if
(
iconNode
)
{
// 确保索引在有效范围内(0-4)
// 确保索引在有效范围内(0-4)
const
candyIndex
=
Math
.
min
(
Math
.
max
(
index
,
0
),
4
)
;
const
candyIndex
=
index
%
5
;
const
candyIconName
=
`candy_
${
candyIndex
}
`
;
const
candyIconName
=
`candy_
${
candyIndex
}
`
;
// 使用pg.view.setImg加载对应的糖果图标
// 使用pg.view.setImg加载对应的糖果图标
pg
.
view
.
set
Img
(
iconNode
,
candyIconName
);
pg
.
view
.
set
NodeImg
(
iconNode
,
pg
.
view
.
find
(
this
,
`res/img/
${
candyIconName
}
`
)
);
iconNode
.
active
=
true
;
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
))
{
pg
.
view
.
touchOn
(
candyNode
,
this
.
onTouchFireNode
,
this
);
candyNode
.
on
(
cc
.
Node
.
EventType
.
TOUCH_END
,
this
.
onTouchFireNode
,
this
);
}
}
}
/**
/**
...
@@ -336,11 +314,12 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -336,11 +314,12 @@ export default class SceneComponent extends MyCocosSceneComponent {
// 根据当前数据,将糖果节点克隆到糖果区域
// 根据当前数据,将糖果节点克隆到糖果区域
if
(
pageData
&&
pageData
.
length
>
0
)
{
if
(
pageData
&&
pageData
.
length
>
0
)
{
// 确定是否需要滚动
// 确定是否需要滚动
if
(
pageData
.
length
>
5
)
{
const
len
=
10
;
if
(
pageData
.
length
>
len
)
{
this
.
needScroll
=
true
;
this
.
needScroll
=
true
;
// 将前5个数据显示在屏幕上,其余放入待添加队列
// 将前5个数据显示在屏幕上,其余放入待添加队列
const
visibleData
=
pageData
.
slice
(
0
,
5
);
const
visibleData
=
pageData
.
slice
(
0
,
len
);
this
.
pendingCandyData
=
pageData
.
slice
(
5
);
this
.
pendingCandyData
=
pageData
.
slice
(
len
);
// 遍历可见数据
// 遍历可见数据
visibleData
.
forEach
((
data
,
index
)
=>
{
visibleData
.
forEach
((
data
,
index
)
=>
{
...
@@ -385,28 +364,13 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -385,28 +364,13 @@ export default class SceneComponent extends MyCocosSceneComponent {
*/
*/
private
addNewCandyNode
()
{
private
addNewCandyNode
()
{
if
(
this
.
pendingCandyData
.
length
===
0
||
!
this
.
item
)
return
;
if
(
this
.
pendingCandyData
.
length
===
0
||
!
this
.
item
)
return
;
// 获取待添加的第一个数据
const
data
=
this
.
pendingCandyData
.
shift
();
const
data
=
this
.
pendingCandyData
.
shift
();
// 克隆糖果节点
const
candyNode
=
cc
.
instantiate
(
this
.
item
)
as
CandyNode
;
const
candyNode
=
cc
.
instantiate
(
this
.
item
)
as
CandyNode
;
this
.
layout
.
addChild
(
candyNode
);
// 使用updateItem方法更新节点内容
// 使用当前显示的节点数量作为索引
const
index
=
this
.
layout
.
childrenCount
;
const
index
=
this
.
layout
.
childrenCount
;
this
.
updateItem
(
candyNode
,
data
,
index
);
this
.
updateItem
(
candyNode
,
data
,
index
);
// 将新节点放在布局的最后位置
this
.
layout
.
addChild
(
candyNode
);
// 将糖果节点添加到活跃火苗节点数组
this
.
activeFireNodes
.
push
(
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