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
aa363c89
Commit
aa363c89
authored
Aug 03, 2025
by
Tt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
d744c78f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
120 additions
and
44 deletions
+120
-44
SSAPP2501.fire
assets/SSAPP2501/scene/SSAPP2501.fire
+1
-1
SSAPP2501.ts
assets/SSAPP2501/scene/SSAPP2501.ts
+119
-43
No files found.
assets/SSAPP2501/scene/SSAPP2501.fire
View file @
aa363c89
...
@@ -3553,7 +3553,7 @@
...
@@ -3553,7 +3553,7 @@
"__type__": "TypedArray",
"__type__": "TypedArray",
"ctor": "Float64Array",
"ctor": "Float64Array",
"array": [
"array": [
0,
-35
0,
0,
0,
0,
0,
0,
0,
...
...
assets/SSAPP2501/scene/SSAPP2501.ts
View file @
aa363c89
...
@@ -151,7 +151,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -151,7 +151,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
/** 是否播放背景音乐 */
/** 是否播放背景音乐 */
private
isPlayBgAudio
:
boolean
;
private
isPlayBgAudio
:
boolean
;
/** 当前页面上存在的火苗节点数组 */
/** 当前页面上存在的火苗节点数组 */
private
active
Fire
Nodes
:
cc
.
Node
[]
=
[];
private
activeNodes
:
cc
.
Node
[]
=
[];
/** 是否正在触摸中 */
/** 是否正在触摸中 */
private
touching
:
boolean
=
false
;
private
touching
:
boolean
=
false
;
/** 录音开始的时间(秒) */
/** 录音开始的时间(秒) */
...
@@ -170,6 +170,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -170,6 +170,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
private
candyNodeWidth
:
number
=
0
;
private
candyNodeWidth
:
number
=
0
;
/** 待添加的糖果数据队列 */
/** 待添加的糖果数据队列 */
private
pendingCandyData
:
Option
[]
=
[];
private
pendingCandyData
:
Option
[]
=
[];
/** 滚动距离累计 */
private
scrollDistance
:
number
=
0
;
// 移除了提示动画相关的变量
// 移除了提示动画相关的变量
/**
/**
...
@@ -185,7 +187,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -185,7 +187,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
this
.
touchData
=
null
;
this
.
touchData
=
null
;
this
.
isPlayBgAudio
=
true
;
this
.
isPlayBgAudio
=
true
;
// 初始化活跃火苗节点数组
// 初始化活跃火苗节点数组
this
.
active
Fire
Nodes
=
[];
this
.
activeNodes
=
[];
// 初始化触摸状态
// 初始化触摸状态
this
.
touching
=
false
;
this
.
touching
=
false
;
}
}
...
@@ -282,28 +284,45 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -282,28 +284,45 @@ export default class SceneComponent extends MyCocosSceneComponent {
pg
.
view
.
touchOn
(
candyNode
,
this
.
onTouchItemNode
,
this
);
pg
.
view
.
touchOn
(
candyNode
,
this
.
onTouchItemNode
,
this
);
}
}
/**
* 获取未回答过的题目
* 根据Game.getIns().player.voices中存储的已回答正确的题目ID,过滤出未回答的题目
* @returns {Array<Option>} 未回答的题目数组
*/
private
getUnansweredQuestions
():
Option
[]
{
// 获取所有题目数据
const
allQuestions
=
Game
.
getIns
().
getPageData
();
// 获取已回答正确的题目ID列表
const
answeredIds
=
Game
.
getIns
().
player
.
voices
.
map
(
voice
=>
voice
.
questionId
);
// 过滤出未回答的题目
return
allQuestions
.
filter
(
question
=>
!
answeredIds
.
includes
(
question
.
id
));
}
/**
/**
* 显示当前页面
* 显示当前页面
* 移除了与页面a和页面b相关的逻辑
* 实现无限滚动逻辑,初始化糖果区域
* 添加了将糖果节点克隆到糖果区域的逻辑
* 添加了糖果区域滚动逻辑
*/
*/
showPage
()
{
showPage
()
{
// 获取
当前页的
数据
// 获取
未回答的题目
数据
const
pageData
=
Game
.
getIns
().
getPageData
();
const
unansweredQuestions
=
this
.
getUnansweredQuestions
();
// 重置滚动状态
// 重置滚动状态
this
.
layout
.
x
=
0
;
this
.
layout
.
x
=
0
;
this
.
needScroll
=
false
;
this
.
scrollDistance
=
0
;
this
.
pendingCandyData
=
[];
this
.
needScroll
=
unansweredQuestions
.
length
>
5
;
// 如果有超过5个未回答题目,启用滚动
this
.
activeFireNodes
=
[];
// 初始化数据队列
const
initialVisibleCount
=
Math
.
min
(
5
,
unansweredQuestions
.
length
);
const
visibleData
=
unansweredQuestions
.
slice
(
0
,
initialVisibleCount
);
this
.
pendingCandyData
=
unansweredQuestions
.
slice
(
initialVisibleCount
);
// 清空现有节点
this
.
activeNodes
=
[];
this
.
layout
.
removeAllChildren
();
this
.
layout
.
removeAllChildren
();
const
len
=
5
;
// 添加初始可见的糖果节点
// this.needScroll = true;
const
visibleData
=
pageData
.
slice
(
0
,
len
);
this
.
pendingCandyData
=
pageData
.
slice
(
len
);
visibleData
.
forEach
((
data
,
index
)
=>
{
visibleData
.
forEach
((
data
,
index
)
=>
{
const
candyNode
=
cc
.
instantiate
(
this
.
item
)
as
CandyNode
;
const
candyNode
=
cc
.
instantiate
(
this
.
item
)
as
CandyNode
;
this
.
layout
.
addChild
(
candyNode
);
this
.
layout
.
addChild
(
candyNode
);
...
@@ -311,21 +330,46 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -311,21 +330,46 @@ export default class SceneComponent extends MyCocosSceneComponent {
if
(
index
===
0
)
{
if
(
index
===
0
)
{
this
.
candyNodeWidth
=
candyNode
.
width
;
this
.
candyNodeWidth
=
candyNode
.
width
;
}
}
this
.
active
Fire
Nodes
.
push
(
candyNode
);
this
.
activeNodes
.
push
(
candyNode
);
});
});
}
}
/**
/**
* 添加新的糖果节点到布局的最后位置
* 添加新的糖果节点到布局的最后位置
* 如果待添加队列为空,会重新获取未回答的题目
*/
*/
private
addNewCandyNode
()
{
private
addNewCandyNode
()
{
if
(
this
.
pendingCandyData
.
length
===
0
||
!
this
.
item
)
return
;
// 检查是否有糖果节点模板
if
(
!
this
.
item
)
return
;
// 如果待添加队列为空,重新获取未回答的题目
if
(
this
.
pendingCandyData
.
length
===
0
)
{
const
unansweredQuestions
=
this
.
getUnansweredQuestions
();
// 如果没有未回答的题目,则不添加新节点
if
(
unansweredQuestions
.
length
===
0
)
{
this
.
needScroll
=
false
;
// 停止滚动
return
;
}
// 将未回答的题目添加到待添加队列
this
.
pendingCandyData
=
unansweredQuestions
;
}
// 从待添加队列中取出一个数据
const
data
=
this
.
pendingCandyData
.
shift
();
const
data
=
this
.
pendingCandyData
.
shift
();
if
(
!
data
)
return
;
// 创建新的糖果节点
const
candyNode
=
cc
.
instantiate
(
this
.
item
)
as
CandyNode
;
const
candyNode
=
cc
.
instantiate
(
this
.
item
)
as
CandyNode
;
this
.
layout
.
addChild
(
candyNode
);
this
.
layout
.
addChild
(
candyNode
);
const
index
=
this
.
layout
.
childrenCount
;
this
.
updateItem
(
candyNode
,
data
,
this
.
addCount
+
4
);
this
.
updateItem
(
candyNode
,
data
,
index
);
this
.
activeNodes
.
push
(
candyNode
);
this
.
activeFireNodes
.
push
(
candyNode
);
// 如果有足够的节点,启用滚动
if
(
this
.
activeNodes
.
length
>
5
)
{
this
.
needScroll
=
true
;
}
}
}
/**
/**
* 火苗点击事件处理
* 火苗点击事件处理
...
@@ -354,11 +398,6 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -354,11 +398,6 @@ export default class SceneComponent extends MyCocosSceneComponent {
// 保存锤子原始位置和旋转角度
// 保存锤子原始位置和旋转角度
const
originalPos
=
cc
.
v2
(
this
.
btn_hammer
.
x
,
this
.
btn_hammer
.
y
);
const
originalPos
=
cc
.
v2
(
this
.
btn_hammer
.
x
,
this
.
btn_hammer
.
y
);
const
originalRotation
=
this
.
btn_hammer
.
angle
;
const
originalRotation
=
this
.
btn_hammer
.
angle
;
// 保存当前滚动状态,并暂停滚动
const
originalScrollState
=
this
.
needScroll
;
this
.
needScroll
=
false
;
// 播放锤子移动到目标位置的动画
// 播放锤子移动到目标位置的动画
cc
.
tween
(
this
.
btn_hammer
)
cc
.
tween
(
this
.
btn_hammer
)
.
to
(
0.2
,
{
x
:
hammerWorldPos
.
x
,
y
:
hammerWorldPos
.
y
})
.
to
(
0.2
,
{
x
:
hammerWorldPos
.
x
,
y
:
hammerWorldPos
.
y
})
...
@@ -374,8 +413,6 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -374,8 +413,6 @@ export default class SceneComponent extends MyCocosSceneComponent {
.
delay
(
0.3
)
// 等待0.3秒
.
delay
(
0.3
)
// 等待0.3秒
.
to
(
0.2
,
{
x
:
originalPos
.
x
,
y
:
originalPos
.
y
,
angle
:
originalRotation
})
// 锤子回到原位
.
to
(
0.2
,
{
x
:
originalPos
.
x
,
y
:
originalPos
.
y
,
angle
:
originalRotation
})
// 锤子回到原位
.
call
(()
=>
{
.
call
(()
=>
{
// 恢复原来的滚动状态
this
.
needScroll
=
originalScrollState
;
})
})
.
start
();
.
start
();
})
})
...
@@ -388,14 +425,19 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -388,14 +425,19 @@ export default class SceneComponent extends MyCocosSceneComponent {
onRecordSuccess
()
{
onRecordSuccess
()
{
const
fireNode
=
this
.
currentTouchNode
;
const
fireNode
=
this
.
currentTouchNode
;
const
index
=
this
.
active
Fire
Nodes
.
indexOf
(
fireNode
);
const
index
=
this
.
activeNodes
.
indexOf
(
fireNode
);
if
(
index
!==
-
1
)
this
.
active
Fire
Nodes
.
splice
(
index
,
1
);
if
(
index
!==
-
1
)
this
.
activeNodes
.
splice
(
index
,
1
);
fireNode
.
active
=
false
;
fireNode
.
active
=
false
;
this
.
touching
=
false
;
this
.
touching
=
false
;
// 重置无操作计时器
// 重置无操作计时器
this
.
inactiveTimer
=
0
;
this
.
inactiveTimer
=
0
;
// 更新待添加的糖果数据队列,获取最新的未回答题目
// 这样在无限滚动时会排除刚刚回答正确的题目
this
.
pendingCandyData
=
this
.
getUnansweredQuestions
();
// 检查当前页面是否所有火苗都已处理完毕
// 检查当前页面是否所有火苗都已处理完毕
if
(
this
.
active
Fire
Nodes
.
length
===
0
)
{
if
(
this
.
activeNodes
.
length
===
0
)
{
// 延迟一段时间后检查是否需要切换到下一页
// 延迟一段时间后检查是否需要切换到下一页
this
.
scheduleOnce
(()
=>
{
this
.
scheduleOnce
(()
=>
{
// 检查是否需要进入下一页
// 检查是否需要进入下一页
...
@@ -407,8 +449,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -407,8 +449,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
const
fireNode
=
this
.
currentTouchNode
;
const
fireNode
=
this
.
currentTouchNode
;
// 将火苗节点重新添加到活跃列表中,以便再次尝试
// 将火苗节点重新添加到活跃列表中,以便再次尝试
if
(
fireNode
&&
!
this
.
active
Fire
Nodes
.
includes
(
fireNode
))
{
if
(
fireNode
&&
!
this
.
activeNodes
.
includes
(
fireNode
))
{
this
.
active
Fire
Nodes
.
push
(
fireNode
);
this
.
activeNodes
.
push
(
fireNode
);
}
}
// 确保火苗节点保持显示状态
// 确保火苗节点保持显示状态
...
@@ -433,9 +475,25 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -433,9 +475,25 @@ export default class SceneComponent extends MyCocosSceneComponent {
// 重置无操作计时器
// 重置无操作计时器
this
.
inactiveTimer
=
0
;
this
.
inactiveTimer
=
0
;
}
}
/**
* 切换到下一页
* 在无限滚动模式下,更新未回答题目列表并重新显示页面
*/
nextPage
()
{
nextPage
()
{
// 切换到下一页
// 切换到下一页
Game
.
getIns
().
addPage
();
Game
.
getIns
().
addPage
();
// 获取最新的未回答题目
this
.
pendingCandyData
=
this
.
getUnansweredQuestions
();
// 如果没有未回答的题目,游戏结束
if
(
this
.
pendingCandyData
.
length
===
0
)
{
// 可以在这里添加游戏结束逻辑
this
.
gameOver
();
return
;
}
// 重新显示页面
this
.
showPage
();
this
.
showPage
();
}
}
...
@@ -723,6 +781,9 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -723,6 +781,9 @@ export default class SceneComponent extends MyCocosSceneComponent {
// 如果没有录音数据,默认失败
// 如果没有录音数据,默认失败
this
.
onRecordFail
();
this
.
onRecordFail
();
}
}
// 更新滚动状态,根据剩余未回答题目数量决定是否继续滚动
this
.
needScroll
=
this
.
activeNodes
.
length
>
5
||
this
.
pendingCandyData
.
length
>
0
;
}
}
/**
/**
...
@@ -731,6 +792,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -731,6 +792,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
* 移除了提示手指动画相关的代码
* 移除了提示手指动画相关的代码
* @param dt 帧间隔时间(秒)
* @param dt 帧间隔时间(秒)
*/
*/
private
addCount
:
number
;
update
(
dt
)
{
update
(
dt
)
{
// 只在游戏运行状态下更新
// 只在游戏运行状态下更新
if
(
Game
.
getIns
().
state
!=
GAME_STATE
.
RUNNING
)
return
;
if
(
Game
.
getIns
().
state
!=
GAME_STATE
.
RUNNING
)
return
;
...
@@ -753,17 +815,36 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -753,17 +815,36 @@ export default class SceneComponent extends MyCocosSceneComponent {
// 处理糖果区域滚动
// 处理糖果区域滚动
if
(
this
.
needScroll
&&
!
this
.
touching
&&
this
.
layout
&&
this
.
layout
.
childrenCount
>
0
)
{
if
(
this
.
needScroll
&&
!
this
.
touching
&&
this
.
layout
&&
this
.
layout
.
childrenCount
>
0
)
{
// 计算本帧滚动距离
const
frameScrollDistance
=
this
.
scrollSpeed
*
dt
;
// 移动糖果区域
// 移动糖果区域
this
.
layout
.
x
-=
this
.
scrollSpeed
*
dt
;
this
.
layout
.
x
-=
frameScrollDistance
;
// 累计滚动距离
this
.
scrollDistance
=
Math
.
abs
(
this
.
layout
.
x
)
-
this
.
addCount
*
200
;
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
();
// 添加新节点
}
// 检查第一个糖果节点是否已经移出视图
// 检查第一个糖果节点是否已经移出视图
const
firstCandy
=
this
.
layout
.
children
[
0
];
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
<
-
this
.
layout
.
parent
.
width
/
2
)
{
// 从活跃节点数组中移除第一个节点
// 从活跃节点数组中移除第一个节点
if
(
this
.
active
Fire
Nodes
.
includes
(
firstCandy
))
{
if
(
this
.
activeNodes
.
includes
(
firstCandy
))
{
const
index
=
this
.
active
Fire
Nodes
.
indexOf
(
firstCandy
);
const
index
=
this
.
activeNodes
.
indexOf
(
firstCandy
);
if
(
index
!==
-
1
)
{
if
(
index
!==
-
1
)
{
this
.
active
Fire
Nodes
.
splice
(
index
,
1
);
this
.
activeNodes
.
splice
(
index
,
1
);
}
}
}
}
...
@@ -771,14 +852,9 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -771,14 +852,9 @@ export default class SceneComponent extends MyCocosSceneComponent {
firstCandy
.
removeFromParent
();
firstCandy
.
removeFromParent
();
firstCandy
.
destroy
();
firstCandy
.
destroy
();
// 如果有待添加的糖果数据,添加新的糖果节点
console
.
log
(
"
当前节点数量
"
+
this
.
layout
.
childrenCount
);
if
(
this
.
pendingCandyData
.
length
>
0
)
{
this
.
addNewCandyNode
();
}
}
}
}
}
// 移除了提示动画逻辑
}
}
...
@@ -999,8 +1075,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -999,8 +1075,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
this
.
tryAgain
=
true
;
this
.
tryAgain
=
true
;
// 将火苗节点重新添加到活跃列表中,以便再次尝试
// 将火苗节点重新添加到活跃列表中,以便再次尝试
if
(
this
.
touchData
&&
this
.
touchData
.
parent
&&
!
this
.
active
Fire
Nodes
.
includes
(
this
.
touchData
.
parent
))
{
if
(
this
.
touchData
&&
this
.
touchData
.
parent
&&
!
this
.
activeNodes
.
includes
(
this
.
touchData
.
parent
))
{
this
.
active
Fire
Nodes
.
push
(
this
.
touchData
.
parent
);
this
.
activeNodes
.
push
(
this
.
touchData
.
parent
);
}
}
}
}
}
}
...
...
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