Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
SSIWB2504
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
SSIWB2504
Commits
8799433b
Commit
8799433b
authored
Aug 08, 2025
by
Tt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(游戏组件): 添加发音按钮并优化游戏阶段逻辑
parent
7b63c40f
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
93 additions
and
73 deletions
+93
-73
interfaces.ts
src/app/play/interfaces.ts
+0
-6
play.component.ts
src/app/play/play.component.ts
+91
-66
resources.js
src/app/play/resources.js
+2
-0
fa_yin.png
src/assets/game/fa_yin.png
+0
-0
流程.md
流程.md
+0
-1
No files found.
src/app/play/interfaces.ts
View file @
8799433b
...
@@ -47,12 +47,6 @@ export interface FormData {
...
@@ -47,12 +47,6 @@ export interface FormData {
questions
:
Question
[];
questions
:
Question
[];
/** 类型 */
/** 类型 */
type
?:
number
;
type
?:
number
;
/** 第一部分数据 */
part_1
?:
any
[];
/** 第二部分数据 */
part_2
?:
any
[];
/** 第三部分数据 */
part_3
?:
any
[];
/** 数据数组(兼容旧版数据结构) */
/** 数据数组(兼容旧版数据结构) */
dataArray
?:
any
[];
dataArray
?:
any
[];
}
}
...
...
src/app/play/play.component.ts
View file @
8799433b
...
@@ -268,6 +268,9 @@ export class PlayComponent implements OnInit, OnDestroy {
...
@@ -268,6 +268,9 @@ export class PlayComponent implements OnInit, OnDestroy {
this
.
initListPage
();
this
.
initListPage
();
this
.
initFishGame
();
this
.
initFishGame
();
// 初始化发音按钮
this
.
initFaYinBtn
();
// 初始化退出按钮
// 初始化退出按钮
// this.initBtnBack();
// this.initBtnBack();
// // 初始化标题
// // 初始化标题
...
@@ -484,6 +487,7 @@ export class PlayComponent implements OnInit, OnDestroy {
...
@@ -484,6 +487,7 @@ export class PlayComponent implements OnInit, OnDestroy {
// 添加点击事件
// 添加点击事件
this
.
m_mapDownQueue
[
'
check_btn
'
]
=
()
=>
{
this
.
m_mapDownQueue
[
'
check_btn
'
]
=
()
=>
{
if
(
!
this
.
layoutPage
.
ref
.
visible
)
return
// 播放点击音效
// 播放点击音效
this
.
g_cartoon
.
playAudio
(
'
sm-click
'
);
this
.
g_cartoon
.
playAudio
(
'
sm-click
'
);
...
@@ -773,6 +777,11 @@ export class PlayComponent implements OnInit, OnDestroy {
...
@@ -773,6 +777,11 @@ export class PlayComponent implements OnInit, OnDestroy {
// 修改鱼的生成逻辑,使用当前阶段的随机问题列表
// 修改鱼的生成逻辑,使用当前阶段的随机问题列表
this
.
m_fishInterval
=
3000
;
// 设置鱼的生成间隔为3秒
this
.
m_fishInterval
=
3000
;
// 设置鱼的生成间隔为3秒
this
.
m_lastFishTime
=
0
;
// 重置上次生成鱼的时间,使下一帧立即生成鱼
this
.
m_lastFishTime
=
0
;
// 重置上次生成鱼的时间,使下一帧立即生成鱼
// 每一个stage开始的时候播放一次正确问题的音频
if
(
currentStage
.
correctQuestion
&&
currentStage
.
correctQuestion
.
audio
)
{
this
.
g_cartoon
.
playAudio
(
currentStage
.
correctQuestion
.
audio
);
}
}
}
initVsView
()
{
initVsView
()
{
...
@@ -1181,6 +1190,44 @@ export class PlayComponent implements OnInit, OnDestroy {
...
@@ -1181,6 +1190,44 @@ export class PlayComponent implements OnInit, OnDestroy {
/**
* 初始化发音按钮
* 创建发音按钮并放置在右下角
*/
initFaYinBtn
()
{
// 创建发音按钮元素
const
faYinBtn
=
this
.
g_cartoon
.
createCartoonElement
(
'
fa_yin_btn
'
,
'
MySprite
'
);
// 初始化按钮图像,使用resources.js中的fa_yin资源
faYinBtn
.
ref
.
init
(
this
.
g_cartoon
.
images
.
get
(
'
fa_yin
'
));
// 设置按钮X方向和Y方向的缩放比例
faYinBtn
.
ref
.
scaleX
=
this
.
g_mapScale
;
faYinBtn
.
ref
.
scaleY
=
this
.
g_mapScale
;
// 获取按钮尺寸信息
const
buttonWidth
=
91
*
this
.
g_mapScale
;
// fa_yin的宽度是91
const
buttonHeight
=
94
*
this
.
g_mapScale
;
// fa_yin的高度是94
// 设置按钮位置 - 屏幕右下角
faYinBtn
.
ref
.
x
=
this
.
g_canvasWidth
-
buttonWidth
/
2
-
50
*
this
.
g_mapScale
;
// 距离右边50像素
faYinBtn
.
ref
.
y
=
this
.
g_canvasHeight
-
buttonHeight
/
2
-
50
*
this
.
g_mapScale
;
// 距离底部150像素,避免与其他按钮重叠
// 渲染按钮元素(使用较高的zIndex确保按钮显示在上层)
this
.
render
(
faYinBtn
.
ref
,
zIndexMap
.
card
+
3
);
// 为发音按钮添加点击事件
this
.
m_mapDownQueue
[
'
fa_yin_btn
'
]
=
()
=>
{
this
.
g_enableMapDown
=
true
;
// 如果当前有游戏阶段且有正确问题,播放其音频
const
currentStage
=
this
.
gameStages
[
this
.
currentStageIndex
];
console
.
log
(
"
btn_fa_yin
"
,
currentStage
)
if
(
currentStage
&&
currentStage
.
correctQuestion
&&
currentStage
.
correctQuestion
.
audio
)
{
// 播放当前正确问题的音频
this
.
g_cartoon
.
playAudio
(
currentStage
.
correctQuestion
.
audio
);
}
};
}
/**
/**
* 初始化退出按钮
* 初始化退出按钮
* 创建退出按钮并放置在标题背景的最左侧
* 创建退出按钮并放置在标题背景的最左侧
...
@@ -1456,33 +1503,11 @@ export class PlayComponent implements OnInit, OnDestroy {
...
@@ -1456,33 +1503,11 @@ export class PlayComponent implements OnInit, OnDestroy {
return
;
return
;
}
}
// 添加字母音频资源
contentObj
.
questions
.
forEach
(
question
=>
{
// 处理part_1数据中的音频
if
(
question
.
audio
)
{
if
(
contentObj
.
part_1
&&
contentObj
.
part_1
.
length
>
0
)
{
this
.
g_cartoon
.
addAudio
(
question
.
audio
,
question
.
audio
);
contentObj
.
part_1
.
forEach
(
item
=>
{
if
(
item
.
audio
)
{
this
.
g_cartoon
.
addAudio
(
item
.
audio
,
item
.
audio
);
}
});
}
// 处理part_2数据中的音频
if
(
contentObj
.
part_2
&&
contentObj
.
part_2
.
length
>
0
)
{
contentObj
.
part_2
.
forEach
(
item
=>
{
if
(
item
.
audio
)
{
this
.
g_cartoon
.
addAudio
(
item
.
audio
,
item
.
audio
);
}
});
}
// 处理part_3数据中的音频
if
(
contentObj
.
part_3
&&
contentObj
.
part_3
.
length
>
0
)
{
contentObj
.
part_3
.
forEach
(
item
=>
{
if
(
item
.
audio
)
{
this
.
g_cartoon
.
addAudio
(
item
.
audio
,
item
.
audio
);
}
});
}
}
})
// 兼容旧版数据结构
// 兼容旧版数据结构
const
arr
=
contentObj
.
dataArray
;
const
arr
=
contentObj
.
dataArray
;
...
...
src/app/play/resources.js
View file @
8799433b
...
@@ -7,6 +7,7 @@ const localImages = {
...
@@ -7,6 +7,7 @@ const localImages = {
'
bei_jing___jiao_shi
'
:
'
assets/game/bei_jing___jiao_shi.png
'
,
'
bei_jing___jiao_shi
'
:
'
assets/game/bei_jing___jiao_shi.png
'
,
'
bei_jing
'
:
'
assets/game/bei_jing.jpg
'
,
'
bei_jing
'
:
'
assets/game/bei_jing.jpg
'
,
'
chuan
'
:
'
assets/game/chuan.png
'
,
'
chuan
'
:
'
assets/game/chuan.png
'
,
'
fa_yin
'
:
'
assets/game/fa_yin.png
'
,
'
fa_yin_an_niu
'
:
'
assets/game/fa_yin_an_niu.png
'
,
'
fa_yin_an_niu
'
:
'
assets/game/fa_yin_an_niu.png
'
,
'
fa_yin_an_niu___fa_yin
'
:
'
assets/game/fa_yin_an_niu___fa_yin.png
'
,
'
fa_yin_an_niu___fa_yin
'
:
'
assets/game/fa_yin_an_niu___fa_yin.png
'
,
'
fa_yin_an_niu___la_ba
'
:
'
assets/game/fa_yin_an_niu___la_ba.png
'
,
'
fa_yin_an_niu___la_ba
'
:
'
assets/game/fa_yin_an_niu___la_ba.png
'
,
...
@@ -155,6 +156,7 @@ const localImagesSize = {
...
@@ -155,6 +156,7 @@ const localImagesSize = {
'
bei_jing
'
:
{
width
:
1280
,
height
:
720
},
'
bei_jing
'
:
{
width
:
1280
,
height
:
720
},
'
bei_jing___jiao_shi
'
:
{
width
:
1280
,
height
:
173
},
'
bei_jing___jiao_shi
'
:
{
width
:
1280
,
height
:
173
},
'
chuan
'
:
{
width
:
320
,
height
:
77
},
'
chuan
'
:
{
width
:
320
,
height
:
77
},
'
fa_yin
'
:
{
width
:
91
,
height
:
94
},
'
fa_yin_an_niu
'
:
{
width
:
91
,
height
:
94
},
'
fa_yin_an_niu
'
:
{
width
:
91
,
height
:
94
},
'
fa_yin_an_niu___fa_yin
'
:
{
width
:
32
,
height
:
38
},
'
fa_yin_an_niu___fa_yin
'
:
{
width
:
32
,
height
:
38
},
'
fa_yin_an_niu___la_ba
'
:
{
width
:
46
,
height
:
46
},
'
fa_yin_an_niu___la_ba
'
:
{
width
:
46
,
height
:
46
},
...
...
src/assets/game/fa_yin.png
0 → 100644
View file @
8799433b
4.96 KB
流程.md
View file @
8799433b
1.
本局开始 播放音频
2.
点击鱼 正确 播放音频
2.
点击鱼 正确 播放音频
3.
获取星星表示当前进度
3.
获取星星表示当前进度
...
...
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