Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
H
hy11_paopao
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
hy11_paopao
Commits
f99454e0
Commit
f99454e0
authored
Jun 23, 2023
by
Tt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
封装当前题目获取方式,拓展出下一题和游戏结束判断
parent
8ce7dc3b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
8 deletions
+21
-8
hy01_danci.ts
assets/hy01_danci/scene/hy01_danci.ts
+21
-8
No files found.
assets/hy01_danci/scene/hy01_danci.ts
View file @
f99454e0
...
...
@@ -33,8 +33,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
this
.
initGame
()
}
initData
()
{
this
.
speed
=
30
console
.
log
(
this
.
data
)
this
.
current
=
-
1
;
}
initView
()
{
}
initEvent
()
{
...
...
@@ -43,6 +42,13 @@ export default class SceneComponent extends MyCocosSceneComponent {
pg
.
view
.
touchOn
(
bottom_megaphone
,
this
.
create_bubbles
,
this
)
}
initGame
()
{
this
.
current
++
;
// 自动切换下一题
if
(
!
this
.
currentQuestion
)
{
this
.
gameOver
();
return
;
}
this
.
speed
=
30
console
.
log
(
this
.
data
)
// 底部海螺
let
bottom_megaphone
=
pg
.
view
.
find
(
this
,
'
layer_game/bg/bottom_megaphone
'
)
// 开始海螺从底部升起
...
...
@@ -54,9 +60,16 @@ export default class SceneComponent extends MyCocosSceneComponent {
})
btn
.
start
()
}
gameOver
()
{
console
.
log
(
"
游戏结束
"
);
}
private
current
:
number
;
get
currentQuestion
()
{
return
this
.
data
.
questions
[
this
.
current
];
}
// 制造气泡
create_bubbles
()
{
if
(
this
.
touchNumber
>
this
.
data
.
questions
[
0
]
.
options
.
length
)
{
if
(
this
.
touchNumber
>
this
.
currentQuestion
.
options
.
length
)
{
console
.
log
(
'
此题结束
'
)
}
else
{
let
bottom_megaphone
=
pg
.
view
.
find
(
this
,
'
layer_game/bg/bottom_megaphone
'
)
...
...
@@ -70,14 +83,14 @@ export default class SceneComponent extends MyCocosSceneComponent {
let
img
=
newPaoPao
.
getChildByName
(
"
img
"
)
let
text
=
newPaoPao
.
getChildByName
(
"
text
"
)
// 判断是显示图片还是文字
if
(
this
.
data
.
questions
[
0
]
.
options
[
this
.
touchNumber
-
1
].
type
===
'
img
'
)
{
if
(
this
.
currentQuestion
.
options
[
this
.
touchNumber
-
1
].
type
===
'
img
'
)
{
pg
.
view
.
visible
(
img
,
true
)
pg
.
view
.
visible
(
text
,
false
)
pg
.
view
.
setNetImg
(
img
,
this
.
data
.
questions
[
0
].
options
[
this
.
touchNumber
-
1
].
image
,
{
w
:
60
,
h
:
60
})
pg
.
view
.
setNetImg
(
img
,
this
.
currentQuestion
.
options
[
this
.
touchNumber
-
1
].
image
,
{
w
:
60
,
h
:
60
})
}
else
{
pg
.
view
.
visible
(
img
,
false
)
pg
.
view
.
visible
(
text
,
true
)
pg
.
view
.
setString
(
text
,
this
.
data
.
questions
[
0
]
.
options
[
this
.
touchNumber
-
1
].
text
)
pg
.
view
.
setString
(
text
,
this
.
currentQuestion
.
options
[
this
.
touchNumber
-
1
].
text
)
}
let
btn
=
cc
.
tween
(
bottom_megaphone
)
layer_paopao
.
addChild
(
newPaoPao
)
...
...
@@ -119,8 +132,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
// 点击泡泡
touchPaoPao
(
e
:
any
)
{
// 如果泡泡没有到指定位置不允许点击
if
(
this
.
targetPosition
>
e
.
target
.
y
)
return
if
(
this
.
isCorrect
)
{
if
(
this
.
targetPosition
>
e
.
target
.
y
)
return
if
(
this
.
isCorrect
)
{
// 成功 泡泡破碎 里面的内容消失
let
paopao
=
e
.
target
.
getChildByName
(
"
bubble
"
)
let
broken
=
e
.
target
.
getChildByName
(
"
bubble_broken
"
)
...
...
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