Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
SSAPP2501
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
SSAPP2501
Commits
71f00d52
Commit
71f00d52
authored
Aug 02, 2025
by
Tt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
页面点击增加
parent
ebca1c4b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
101 additions
and
75 deletions
+101
-75
SSAPP2501.fire
assets/SSAPP2501/scene/SSAPP2501.fire
+12
-6
SSAPP2501.ts
assets/SSAPP2501/scene/SSAPP2501.ts
+89
-69
No files found.
assets/SSAPP2501/scene/SSAPP2501.fire
View file @
71f00d52
...
@@ -1623,9 +1623,6 @@
...
@@ -1623,9 +1623,6 @@
},
},
{
{
"__id__": 71
"__id__": 71
},
{
"__id__": 76
}
}
],
],
"_active": true,
"_active": true,
...
@@ -3533,6 +3530,9 @@
...
@@ -3533,6 +3530,9 @@
},
},
{
{
"__id__": 74
"__id__": 74
},
{
"__id__": 76
}
}
],
],
"_active": true,
"_active": true,
...
@@ -3794,7 +3794,7 @@
...
@@ -3794,7 +3794,7 @@
"_name": "btn_finger",
"_name": "btn_finger",
"_objFlags": 0,
"_objFlags": 0,
"_parent": {
"_parent": {
"__id__":
34
"__id__":
71
},
},
"_children": [],
"_children": [],
"_active": true,
"_active": true,
...
@@ -3826,8 +3826,8 @@
...
@@ -3826,8 +3826,8 @@
"__type__": "TypedArray",
"__type__": "TypedArray",
"ctor": "Float64Array",
"ctor": "Float64Array",
"array": [
"array": [
-
476.03
6,
-
57.52
6,
-212.486
,
315.152
,
0,
0,
0,
0,
0,
0,
...
@@ -9313,6 +9313,12 @@
...
@@ -9313,6 +9313,12 @@
"btn_finger": {
"btn_finger": {
"__id__": 76
"__id__": 76
},
},
"page_a": {
"__id__": 35
},
"page_b": {
"__id__": 53
},
"_id": "db3L+4L+FH/5MIRcKcfiq+"
"_id": "db3L+4L+FH/5MIRcKcfiq+"
}
}
]
]
\ No newline at end of file
assets/SSAPP2501/scene/SSAPP2501.ts
View file @
71f00d52
...
@@ -139,6 +139,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -139,6 +139,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
@
property
({
displayName
:
"
消防车动画节点
"
,
type
:
cc
.
Node
})
node_firetruck_anim
:
cc
.
Node
=
null
;
@
property
({
displayName
:
"
消防车动画节点
"
,
type
:
cc
.
Node
})
node_firetruck_anim
:
cc
.
Node
=
null
;
@
property
({
displayName
:
"
消防车冲水动画节点
"
,
type
:
cc
.
Node
})
node_firetruck_flush
:
cc
.
Node
=
null
;
@
property
({
displayName
:
"
消防车冲水动画节点
"
,
type
:
cc
.
Node
})
node_firetruck_flush
:
cc
.
Node
=
null
;
@
property
({
displayName
:
"
提示手指节点
"
,
type
:
cc
.
Node
})
btn_finger
:
cc
.
Node
=
null
;
@
property
({
displayName
:
"
提示手指节点
"
,
type
:
cc
.
Node
})
btn_finger
:
cc
.
Node
=
null
;
@
property
({
displayName
:
"
页面a
"
,
type
:
cc
.
Node
})
page_a
:
cc
.
Node
=
null
;
@
property
({
displayName
:
"
页面b
"
,
type
:
cc
.
Node
})
page_b
:
cc
.
Node
=
null
;
// 游戏数据相关变量
// 游戏数据相关变量
/** 当前触摸的选项数据 */
/** 当前触摸的选项数据 */
...
@@ -208,7 +210,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -208,7 +210,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
pg
.
audio
.
playBgAudioByUrl
(
Game
.
getIns
().
bgAudio
);
pg
.
audio
.
playBgAudioByUrl
(
Game
.
getIns
().
bgAudio
);
// 显示问题
// 显示问题
this
.
show
Questions
();
this
.
show
Page
();
this
.
aniCarEnter
();
this
.
aniCarEnter
();
}
}
...
@@ -249,81 +251,81 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -249,81 +251,81 @@ export default class SceneComponent extends MyCocosSceneComponent {
.
start
();
.
start
();
}
}
/**
/**
* 显示问题选项
* 显示当前页面
* 创建并显示蛋壳,添加点击事件
* 根据当前页码决定使用page_a还是page_b
* 并设置fire_0到fire_5这6个交互点
*/
*/
private
showQuestions
()
{
showPage
()
{
return
;
// 获取当前页码
const
currentPage
=
Game
.
getIns
().
getCurrentPageNum
();
// 根据页码的奇偶性决定使用哪个页面
// 偶数页使用page_a,奇数页使用page_b
const
currentPageNode
=
currentPage
%
2
===
0
?
this
.
page_a
:
this
.
page_b
;
const
otherPageNode
=
currentPage
%
2
===
0
?
this
.
page_b
:
this
.
page_a
;
// 显示当前页面,隐藏另一个页面
currentPageNode
.
active
=
true
;
otherPageNode
.
active
=
false
;
// 获取当前页的数据
// 获取当前页的数据
const
pageData
=
Game
.
getIns
().
getPageData
();
const
pageData
=
Game
.
getIns
().
getPageData
();
// 获取问题数量
let
len
=
pageData
.
length
;
// 遍历fire_0到fire_5这6个交互点
// 最多显示4个选项
for
(
let
i
=
0
;
i
<
6
;
i
++
)
{
let
count
=
len
>=
4
?
4
:
len
;
// 查找当前页面下的fire节点
const
fireNode
=
cc
.
find
(
`fire_
${
i
}
`
,
currentPageNode
);
// 创建每个蛋壳
if
(
!
fireNode
)
{
for
(
let
i
=
0
;
i
<
count
;
i
++
)
{
this
.
log
(
`找不到节点: fire_
${
i
}
`
);
// 获取问题数据
continue
;
let
eggData
=
pageData
[
i
];
}
// 获取蛋壳节点
let
egg
=
cc
.
find
(
"
layout_egg/egg
"
+
i
,
this
.
layout_game
);
// 设置节点可见性
// 设置数据和显示状态
if
(
i
<
pageData
.
length
)
{
egg
.
data
=
eggData
;
// 有数据,显示节点
egg
.
active
=
true
;
fireNode
.
active
=
true
;
// 保存题目数据到节点
// 添加点击事件
fireNode
.
data
=
pageData
[
i
];
egg
.
on
(
cc
.
Node
.
EventType
.
TOUCH_END
,
()
=>
{
// 停止箭头动画
// 查找并设置完整蛋壳可见,破碎蛋壳不可见
this
.
stopArrowAction
();
const
intact
=
cc
.
find
(
"
intact
"
,
fireNode
);
// 播放锤子动画
const
broken
=
cc
.
find
(
"
broken
"
,
fireNode
);
this
.
hammerAction
(
egg
.
getPosition
()).
then
(
async
()
=>
{
const
di
=
cc
.
find
(
"
di
"
,
fireNode
);
// 获取蛋壳的各个部分
let
di
=
cc
.
find
(
"
di
"
,
egg
);
if
(
intact
)
intact
.
active
=
true
;
let
intact
=
cc
.
find
(
"
intact
"
,
egg
);
if
(
broken
)
broken
.
active
=
false
;
let
broken
=
cc
.
find
(
"
broken
"
,
egg
);
if
(
di
)
di
.
active
=
false
;
// 显示底部,隐藏完整蛋壳
// 添加触摸事件
di
.
active
=
true
;
fireNode
.
off
(
cc
.
Node
.
EventType
.
TOUCH_END
);
intact
.
active
=
false
;
fireNode
.
on
(
cc
.
Node
.
EventType
.
TOUCH_END
,
()
=>
{
// 如果正在触摸中,不响应新的触摸
// 保存当前选中的数据
if
(
this
.
touching
)
return
;
this
.
touchData
=
egg
.
data
;
this
.
touching
=
true
;
this
.
touchData
.
parent
=
egg
;
// 保存触摸数据
// 延迟显示卡片
this
.
touchData
=
fireNode
.
data
;
await
pg
.
time
.
delay
(
0.7
);
this
.
touchData
.
parent
=
fireNode
;
// 显示卡片
this
.
playCard
(
this
.
touchData
);
this
.
playCard
(
this
.
touchData
);
// 更新录音界面
this
.
updateLayoutSpeak
();
this
.
updateLayoutSpeak
();
// 显示破碎的蛋壳,隐藏底部
// 播放锤子动画
broken
.
active
=
true
;
this
.
hammerAction
(
fireNode
);
di
.
active
=
false
;
});
})
}
else
{
});
// 没有数据,隐藏节点
fireNode
.
active
=
false
;
// 添加箭头动画
}
this
.
eggArrowAction
(
egg
);
}
}
}
// 调整布局
let
layout_egg
=
cc
.
find
(
"
layout_egg
"
,
this
.
layout_game
);
layout_egg
.
getComponent
(
cc
.
Layout
).
updateLayout
();
// 根据选项数量调整间距
if
(
count
==
2
)
{
layout_egg
.
getComponent
(
cc
.
Layout
).
spacingX
=
200
;
}
else
if
(
count
==
3
)
{
layout_egg
.
getComponent
(
cc
.
Layout
).
spacingX
=
150
;
}
else
{
layout_egg
.
getComponent
(
cc
.
Layout
).
spacingX
=
40
;
}
// 更新并禁用自动布局
layout_egg
.
getComponent
(
cc
.
Layout
).
updateLayout
();
layout_egg
.
getComponent
(
cc
.
Layout
).
enabled
=
false
;
}
/**
/**
* 游戏帧更新函数
* 游戏帧更新函数
* 主要用于更新倒计时显示
* 主要用于更新倒计时显示
...
@@ -819,7 +821,9 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -819,7 +821,9 @@ export default class SceneComponent extends MyCocosSceneComponent {
/**
/**
* 检查游戏是否结束
* 检查游戏是否结束
* 通过检查是否所有蛋壳都已隐藏来判断
* 通过检查是否所有蛋壳都已隐藏来判断
* @returns 如果所有蛋壳都已隐藏,返回true;否则返回false
* 如果当前页面完成,切换到下一页
* 如果所有页面都完成,游戏结束
* @returns 如果所有页面都完成,返回true;否则返回false
*/
*/
private
checkIsOver
()
{
private
checkIsOver
()
{
// 计数活动的蛋壳数量
// 计数活动的蛋壳数量
...
@@ -831,8 +835,24 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -831,8 +835,24 @@ export default class SceneComponent extends MyCocosSceneComponent {
if
(
ch
.
active
)
count
++
;
if
(
ch
.
active
)
count
++
;
})
})
// 如果没有显示的蛋壳,游戏结束
// 如果没有显示的蛋壳,当前页面完成
return
count
==
0
;
if
(
count
==
0
)
{
// 增加页码
Game
.
getIns
().
addPage
();
// 检查是否所有页面都完成
if
(
Game
.
getIns
().
isOver
)
{
// 所有页面都完成,游戏结束
return
true
;
}
else
{
// 还有下一页,显示下一页
this
.
showPage
();
return
false
;
}
}
// 当前页面还有蛋壳,游戏未结束
return
false
;
}
}
/**
/**
...
...
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