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
53d83a1e
Commit
53d83a1e
authored
Aug 03, 2025
by
Tt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
a6e36294
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
154 additions
and
44 deletions
+154
-44
SSAPP2501.ts
assets/SSAPP2501/scene/SSAPP2501.ts
+120
-19
defaultData.ts
assets/SSAPP2501/script/defaultData.ts
+34
-25
No files found.
assets/SSAPP2501/scene/SSAPP2501.ts
View file @
53d83a1e
...
@@ -162,6 +162,14 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -162,6 +162,14 @@ export default class SceneComponent extends MyCocosSceneComponent {
private
inactiveTimer
:
number
=
0
;
private
inactiveTimer
:
number
=
0
;
/** 提示动画显示的时间阈值(秒) */
/** 提示动画显示的时间阈值(秒) */
private
hintThreshold
:
number
=
3
;
private
hintThreshold
:
number
=
3
;
/** 糖果区域滚动速度 */
private
scrollSpeed
:
number
=
100
;
/** 是否需要滚动糖果区域 */
private
needScroll
:
boolean
=
false
;
/** 糖果节点宽度 */
private
candyNodeWidth
:
number
=
0
;
/** 待添加的糖果数据队列 */
private
pendingCandyData
:
Option
[]
=
[];
// 移除了提示动画相关的变量
// 移除了提示动画相关的变量
/**
/**
...
@@ -304,6 +312,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -304,6 +312,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
* 显示当前页面
* 显示当前页面
* 移除了与页面a和页面b相关的逻辑
* 移除了与页面a和页面b相关的逻辑
* 添加了将糖果节点克隆到糖果区域的逻辑
* 添加了将糖果节点克隆到糖果区域的逻辑
* 添加了糖果区域滚动逻辑
*/
*/
showPage
()
{
showPage
()
{
// 获取当前页码
// 获取当前页码
...
@@ -313,6 +322,11 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -313,6 +322,11 @@ export default class SceneComponent extends MyCocosSceneComponent {
// 获取当前页的数据
// 获取当前页的数据
const
pageData
=
Game
.
getIns
().
getPageData
();
const
pageData
=
Game
.
getIns
().
getPageData
();
// 重置滚动状态
this
.
layout
.
x
=
0
;
this
.
needScroll
=
false
;
this
.
pendingCandyData
=
[];
// 清空活跃火苗节点数组
// 清空活跃火苗节点数组
this
.
activeFireNodes
=
[];
this
.
activeFireNodes
=
[];
...
@@ -321,22 +335,74 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -321,22 +335,74 @@ export default class SceneComponent extends MyCocosSceneComponent {
// 根据当前数据,将糖果节点克隆到糖果区域
// 根据当前数据,将糖果节点克隆到糖果区域
if
(
pageData
&&
pageData
.
length
>
0
)
{
if
(
pageData
&&
pageData
.
length
>
0
)
{
// 遍历页面数据
// 确定是否需要滚动
pageData
.
forEach
((
data
,
index
)
=>
{
if
(
pageData
.
length
>
5
)
{
// 克隆糖果节点
this
.
needScroll
=
true
;
const
candyNode
=
cc
.
instantiate
(
this
.
item
)
as
CandyNode
;
// 将前5个数据显示在屏幕上,其余放入待添加队列
const
visibleData
=
pageData
.
slice
(
0
,
5
);
this
.
pendingCandyData
=
pageData
.
slice
(
5
);
// 使用updateItem方法更新节点内容,传入索引以显示对应的糖果图标
// 遍历可见数据
this
.
updateItem
(
candyNode
,
data
,
index
);
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
.
activeFireNodes
.
push
(
candyNode
);
// 将糖果节点添加到糖果区域
// 将糖果节点添加到糖果区域
this
.
layout
.
addChild
(
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
);
});
}
}
}
}
}
/**
* 添加新的糖果节点到布局的最后位置
*/
private
addNewCandyNode
()
{
if
(
this
.
pendingCandyData
.
length
===
0
||
!
this
.
item
)
return
;
// 获取待添加的第一个数据
const
data
=
this
.
pendingCandyData
.
shift
();
// 克隆糖果节点
const
candyNode
=
cc
.
instantiate
(
this
.
item
)
as
CandyNode
;
// 使用updateItem方法更新节点内容
// 使用当前显示的节点数量作为索引
const
index
=
this
.
layout
.
childrenCount
;
this
.
updateItem
(
candyNode
,
data
,
index
);
// 将新节点放在布局的最后位置
this
.
layout
.
addChild
(
candyNode
);
// 将糖果节点添加到活跃火苗节点数组
this
.
activeFireNodes
.
push
(
candyNode
);
}
/**
/**
* 移除了消防车点击事件处理方法
* 移除了消防车点击事件处理方法
*/
*/
...
@@ -364,14 +430,6 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -364,14 +430,6 @@ export default class SceneComponent extends MyCocosSceneComponent {
onFireSuccess
()
{
onFireSuccess
()
{
const
fireNode
=
this
.
currentFireNode
;
const
fireNode
=
this
.
currentFireNode
;
// 从活跃火苗列表中移除当前火苗 --- 答题后操作
const
index
=
this
.
activeFireNodes
.
indexOf
(
fireNode
);
if
(
index
!==
-
1
)
{
this
.
activeFireNodes
.
splice
(
index
,
1
);
}
// 隐藏对应的fire节点
fireNode
.
active
=
false
;
// 更新糖果背景状态:隐藏bg_full,显示bg_broken
// 更新糖果背景状态:隐藏bg_full,显示bg_broken
const
bgFullNode
=
fireNode
.
getChildByName
(
'
bg_full
'
);
const
bgFullNode
=
fireNode
.
getChildByName
(
'
bg_full
'
);
...
@@ -383,6 +441,22 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -383,6 +441,22 @@ export default class SceneComponent extends MyCocosSceneComponent {
if
(
bgBrokenNode
)
{
if
(
bgBrokenNode
)
{
bgBrokenNode
.
active
=
true
;
bgBrokenNode
.
active
=
true
;
}
}
// 如果不需要滚动,则直接从活跃列表中移除并隐藏节点
if
(
!
this
.
needScroll
)
{
// 从活跃火苗列表中移除当前火苗
const
index
=
this
.
activeFireNodes
.
indexOf
(
fireNode
);
if
(
index
!==
-
1
)
{
this
.
activeFireNodes
.
splice
(
index
,
1
);
}
// 隐藏对应的fire节点
fireNode
.
active
=
false
;
}
else
{
// 如果需要滚动,标记节点为已点击但保持显示状态
// 将节点设置为不可交互,防止重复点击
fireNode
.
off
(
cc
.
Node
.
EventType
.
TOUCH_END
,
this
.
onTouchFireNode
,
this
);
}
// 移除了与页面a和页面b相关的逻辑
// 移除了与页面a和页面b相关的逻辑
// 移除了与消防车冲水动画相关的代码
// 移除了与消防车冲水动画相关的代码
...
@@ -749,6 +823,33 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -749,6 +823,33 @@ 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
)
{
// 从活跃节点数组中移除第一个节点
if
(
this
.
activeFireNodes
.
includes
(
firstCandy
))
{
const
index
=
this
.
activeFireNodes
.
indexOf
(
firstCandy
);
if
(
index
!==
-
1
)
{
this
.
activeFireNodes
.
splice
(
index
,
1
);
}
}
// 从布局中移除第一个节点
firstCandy
.
removeFromParent
();
firstCandy
.
destroy
();
// 如果有待添加的糖果数据,添加新的糖果节点
if
(
this
.
pendingCandyData
.
length
>
0
)
{
this
.
addNewCandyNode
();
}
}
}
// 移除了提示动画逻辑
// 移除了提示动画逻辑
}
}
...
...
assets/SSAPP2501/script/defaultData.ts
View file @
53d83a1e
...
@@ -10,29 +10,38 @@
...
@@ -10,29 +10,38 @@
*/
*/
export
const
defaultData
=
{
export
const
defaultData
=
{
"
score
"
:
0
,
"
title
"
:
""
,
"
questionText
"
:
""
,
"
questionType
"
:
"
read
"
,
"
score
"
:
0
,
"
title
"
:
""
,
"
questionText
"
:
""
,
"
questionType
"
:
"
read
"
,
"
questionTextAudio
"
:
""
,
"
bgAudio
"
:
""
,
"
questions
"
:
[{
"
questionTextAudio
"
:
""
,
"
bgAudio
"
:
""
,
"
questions
"
:
[
"
type
"
:
"
img
"
,
{
"
audio
"
:
"
http://staging-teach.cdn.ireadabc.com/ae2538a7ef5de1b4836a882d625271af_l.mp3
"
,
"
type
"
:
"
img
"
,
"
text
"
:
"
left
"
,
"
audio
"
:
"
http://staging-teach.cdn.ireadabc.com/ae2538a7ef5de1b4836a882d625271af_l.mp3
"
,
"
image
"
:
"
http://staging-teach.cdn.ireadabc.com/41b95f47d23e0712f825eec9e718caed.png
"
,
"
text
"
:
"
left
"
,
"
time
"
:
null
,
"
image
"
:
"
http://staging-teach.cdn.ireadabc.com/41b95f47d23e0712f825eec9e718caed.png
"
,
"
duration
"
:
30
,
"
audioName
"
:
"
heal_money.mp3
"
"
time
"
:
null
,
},
{
"
duration
"
:
30
,
"
audioName
"
:
"
heal_money.mp3
"
"
type
"
:
"
img
"
,
},
{
"
audio
"
:
"
http://staging-teach.cdn.ireadabc.com/4f3bb8f8fa048f40c1bb5d6d2f6d9a33_l.mp3
"
,
"
type
"
:
"
img
"
,
"
text
"
:
"
down
"
,
"
audio
"
:
"
http://staging-teach.cdn.ireadabc.com/4f3bb8f8fa048f40c1bb5d6d2f6d9a33_l.mp3
"
,
"
image
"
:
"
http://staging-teach.cdn.ireadabc.com/fbe3d792ce2a72310e5298e1d75d0d71.png
"
,
"
time
"
:
null
,
"
text
"
:
"
down
"
,
"
duration
"
:
30
,
"
image
"
:
"
http://staging-teach.cdn.ireadabc.com/fbe3d792ce2a72310e5298e1d75d0d71.png
"
,
"
time
"
:
null
,
"
audioName
"
:
"
shoot.MP3
"
"
duration
"
:
30
,
},
{
"
audioName
"
:
"
shoot.MP3
"
"
type
"
:
"
img
"
,
},
{
"
audio
"
:
"
http://staging-teach.cdn.ireadabc.com/a6fb6452f0e383808cd056939ed81917_l.mp3
"
,
"
text
"
:
"
circle
"
,
"
image
"
:
"
http://staging-teach.cdn.ireadabc.com/d0652838333e892b5e495fbdd8746fa0.png
"
,
"
type
"
:
"
img
"
,
"
time
"
:
null
,
"
duration
"
:
30
,
"
audio
"
:
"
http://staging-teach.cdn.ireadabc.com/a6fb6452f0e383808cd056939ed81917_l.mp3
"
,
"
text
"
:
"
circle
"
,
"
image
"
:
"
http://staging-teach.cdn.ireadabc.com/d0652838333e892b5e495fbdd8746fa0.png
"
,
"
audioName
"
:
"
levelup.MP3
"
"
time
"
:
null
,
"
duration
"
:
30
,
},
{
"
audioName
"
:
"
levelup.MP3
"
"
type
"
:
"
txt
"
,
},
{
"
audio
"
:
"
http://staging-teach.cdn.ireadabc.com/e8d058205a1bc894c55a9dc46d60717f_l.mp3
"
,
"
text
"
:
"
shoot
"
,
"
image
"
:
""
,
"
type
"
:
"
txt
"
,
"
time
"
:
null
,
"
duration
"
:
30
,
"
audio
"
:
"
http://staging-teach.cdn.ireadabc.com/e8d058205a1bc894c55a9dc46d60717f_l.mp3
"
,
"
text
"
:
"
shoot
"
,
"
image
"
:
""
,
"
audioName
"
:
"
yasuo.mp3
"
"
time
"
:
null
,
"
duration
"
:
30
,
},
{
"
type
"
:
"
txt
"
,
"
audio
"
:
""
,
"
text
"
:
"
apple
"
,
"
image
"
:
""
,
"
time
"
:
null
,
"
duration
"
:
30
,
"
audioName
"
:
""
},
{
"
type
"
:
"
txt
"
,
"
audio
"
:
""
,
"
text
"
:
"
international
"
,
"
image
"
:
""
,
"
time
"
:
null
,
"
duration
"
:
30
,
"
audioName
"
:
""
},
{
"
type
"
:
"
txt
"
,
"
audio
"
:
""
,
"
text
"
:
"
deep
"
,
"
image
"
:
""
,
"
time
"
:
null
,
"
duration
"
:
30
,
"
audioName
"
:
""
},
{
"
type
"
:
"
txt
"
,
"
audio
"
:
""
,
"
text
"
:
"
fun
"
,
"
image
"
:
""
,
"
time
"
:
null
,
"
duration
"
:
10
,
"
audioName
"
:
""
}]
"
audioName
"
:
"
yasuo.mp3
"
},
{
"
type
"
:
"
txt
"
,
"
audio
"
:
""
,
"
text
"
:
"
apple
"
,
"
image
"
:
""
,
"
time
"
:
null
,
"
duration
"
:
30
,
"
audioName
"
:
""
},
{
"
type
"
:
"
txt
"
,
"
audio
"
:
""
,
"
text
"
:
"
international
"
,
"
image
"
:
""
,
"
time
"
:
null
,
"
duration
"
:
30
,
"
audioName
"
:
""
},
{
"
type
"
:
"
txt
"
,
"
audio
"
:
""
,
"
text
"
:
"
deep
"
,
"
image
"
:
""
,
"
time
"
:
null
,
"
duration
"
:
30
,
"
audioName
"
:
""
},
{
"
type
"
:
"
txt
"
,
"
audio
"
:
""
,
"
text
"
:
"
fun
"
,
"
image
"
:
""
,
"
time
"
:
null
,
"
duration
"
:
10
,
"
audioName
"
:
""
}]
}
}
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