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
528f51a3
Commit
528f51a3
authored
Aug 04, 2025
by
Tt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(play): 添加检查按钮并根据选择状态更新
parent
6f6e8bc1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
72 additions
and
1 deletion
+72
-1
play.component.ts
src/app/play/play.component.ts
+72
-1
No files found.
src/app/play/play.component.ts
View file @
528f51a3
...
...
@@ -143,6 +143,7 @@ export class PlayComponent implements OnInit, OnDestroy {
m_moveElementArray
=
[]
m_gameOver
=
false
;
// 游戏结束标志
selectList
=
[];
// 选中的项目列表
checkBtnElement
=
null
;
// 检查按钮元素引用
// ------------------------------------
...
...
@@ -357,6 +358,7 @@ export class PlayComponent implements OnInit, OnDestroy {
this
.
initListItem
();
this
.
initCheckBtn
();
// 渲染layout_page
this
.
render
(
layoutPage
.
ref
,
zIndexMap
.
card
);
...
...
@@ -387,6 +389,9 @@ export class PlayComponent implements OnInit, OnDestroy {
}
}
// 更新按钮状态
this
.
updateCheckBtnState
();
console
.
log
(
'
当前选中项目:
'
,
this
.
selectList
);
}
...
...
@@ -402,7 +407,7 @@ export class PlayComponent implements OnInit, OnDestroy {
// 设置背景图片位置 - 水平居中,垂直在顶部
titleBgElement
.
ref
.
x
=
this
.
g_canvasWidth
/
2
;
titleBgElement
.
ref
.
y
=
40
*
this
.
g_mapScale
;
// 距离顶部100像素
titleBgElement
.
ref
.
y
=
40
*
this
.
g_mapScale
;
// 距离顶部100像素
// 创建标题文字元素
const
titleTextElement
=
this
.
g_cartoon
.
createCartoonElement
(
'
page_title_text
'
,
'
Label
'
);
...
...
@@ -422,7 +427,73 @@ export class PlayComponent implements OnInit, OnDestroy {
this
.
render
(
titleBgElement
.
ref
,
zIndexMap
.
background
+
1
);
this
.
render
(
titleTextElement
.
ref
,
zIndexMap
.
background
+
2
);
}
initCheckBtn
()
{
// 创建按钮元素
const
checkBtnElement
=
this
.
g_cartoon
.
createCartoonElement
(
'
check_btn
'
,
'
MySprite
'
);
// 根据selectList长度决定显示的按钮图片和文字
const
updateButtonState
=
()
=>
{
if
(
this
.
selectList
.
length
>=
2
)
{
// 显示"开始游戏"按钮
checkBtnElement
.
ref
.
init
(
this
.
g_cartoon
.
images
.
get
(
'
kai_shi
'
));
}
else
{
// 显示"选择单词"按钮
checkBtnElement
.
ref
.
init
(
this
.
g_cartoon
.
images
.
get
(
'
xuan_ze
'
));
}
};
// 初始化按钮状态
updateButtonState
();
// 设置按钮缩放
checkBtnElement
.
ref
.
scaleX
=
this
.
g_mapScale
;
checkBtnElement
.
ref
.
scaleY
=
this
.
g_mapScale
;
// 设置按钮位置 - 屏幕右下角
// kai_shi和xuan_ze的尺寸都是209x65
const
buttonWidth
=
209
*
this
.
g_mapScale
;
const
buttonHeight
=
65
*
this
.
g_mapScale
;
checkBtnElement
.
ref
.
x
=
this
.
g_canvasWidth
-
buttonWidth
/
2
-
50
*
this
.
g_mapScale
;
// 距离右边50像素
checkBtnElement
.
ref
.
y
=
this
.
g_canvasHeight
-
buttonHeight
/
2
-
50
*
this
.
g_mapScale
;
// 距离底部50像素
// 添加点击事件
this
.
m_mapDownQueue
[
'
check_btn
'
]
=
()
=>
{
// 播放点击音效
this
.
g_cartoon
.
playAudio
(
'
sm-click
'
);
if
(
this
.
selectList
.
length
>=
2
)
{
// 开始游戏逻辑
console
.
log
(
'
开始游戏,选中的项目:
'
,
this
.
selectList
);
// 这里可以添加开始游戏的具体逻辑
}
else
{
// 提示需要选择更多单词
console
.
log
(
'
请至少选择2个单词
'
);
// 这里可以添加提示逻辑
}
};
// 保存按钮引用,用于状态更新
this
.
checkBtnElement
=
checkBtnElement
;
// 渲染按钮
this
.
render
(
checkBtnElement
.
ref
,
zIndexMap
.
card
+
2
);
}
/**
* 更新检查按钮状态
* 根据selectList的长度更新按钮显示
*/
updateCheckBtnState
()
{
if
(
this
.
checkBtnElement
)
{
if
(
this
.
selectList
.
length
>=
2
)
{
// 显示"开始游戏"按钮
this
.
checkBtnElement
.
ref
.
init
(
this
.
g_cartoon
.
images
.
get
(
'
kai_shi
'
));
}
else
{
// 显示"选择单词"按钮
this
.
checkBtnElement
.
ref
.
init
(
this
.
g_cartoon
.
images
.
get
(
'
xuan_ze
'
));
}
}
}
initListItem
()
{
// // 创建list_item节点作为滑动列表容器
...
...
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