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
8ce7dc3b
Commit
8ce7dc3b
authored
Jun 23, 2023
by
张子元
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:添加气泡内数据
parent
5396b7b4
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
480 additions
and
266 deletions
+480
-266
hy01_danci.fire
assets/hy01_danci/scene/hy01_danci.fire
+428
-233
hy01_danci.ts
assets/hy01_danci/scene/hy01_danci.ts
+52
-33
No files found.
assets/hy01_danci/scene/hy01_danci.fire
View file @
8ce7dc3b
This diff is collapsed.
Click to expand it.
assets/hy01_danci/scene/hy01_danci.ts
View file @
8ce7dc3b
...
...
@@ -23,6 +23,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
private
speed
:
number
;
private
isCorrect
:
boolean
;
private
targetPosition
:
number
;
private
touchNumber
:
number
=
1
;
async
onLoadEnd
()
{
// TODO 加载完成后的逻辑写在这里, 下面的代码仅供参考
...
...
@@ -33,6 +34,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
initData
()
{
this
.
speed
=
30
console
.
log
(
this
.
data
)
}
initView
()
{
}
initEvent
()
{
...
...
@@ -54,40 +56,57 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
// 制造气泡
create_bubbles
()
{
let
bottom_megaphone
=
pg
.
view
.
find
(
this
,
'
layer_game/bg/bottom_megaphone
'
)
let
layer_paopao
=
pg
.
view
.
find
(
this
,
'
layer_game/bg/layer_paopao
'
)
let
paoaoParent
=
pg
.
view
.
find
(
this
,
'
layer_game/bg/paopao
'
)
let
newPaoPao
=
cc
.
instantiate
(
paoaoParent
)
pg
.
view
.
touchOn
(
newPaoPao
,
this
.
touchPaoPao
,
this
)
let
paopao
=
newPaoPao
.
getChildByName
(
"
bubble
"
)
let
broken
=
newPaoPao
.
getChildByName
(
"
bubble_broken
"
)
let
btn
=
cc
.
tween
(
bottom_megaphone
)
layer_paopao
.
addChild
(
newPaoPao
)
btn
.
to
(
0.1
,
{
x
:
-
5
}).
to
(
0.1
,
{
x
:
0
}).
to
(
0.1
,
{
x
:
5
}).
to
(
0.1
,
{
x
:
0
})
btn
.
to
(
0.1
,
{
x
:
-
5
}).
to
(
0.1
,
{
x
:
0
}).
to
(
0.1
,
{
x
:
5
}).
to
(
0.1
,
{
x
:
0
})
.
call
(()
=>
{
newPaoPao
.
x
=
135
newPaoPao
.
y
=
-
450
paopao
.
width
=
70
paopao
.
height
=
70
newPaoPao
.
opacity
=
0
pg
.
view
.
visible
(
newPaoPao
,
true
)
pg
.
view
.
visible
(
broken
,
false
)
// 点击泡泡
cc
.
tween
(
newPaoPao
).
to
(
0.8
,
{
opacity
:
255
}).
call
(()
=>
{
let
positionY
=
Math
.
floor
(
Math
.
random
()
*
300
)
let
positionX
=
this
.
getPositionX
()
this
.
targetPosition
=
positionY
cc
.
tween
(
newPaoPao
).
to
(
positionY
/
this
.
speed
,
{
x
:
positionX
,
y
:
positionY
,
scale
:
3
}).
call
(()
=>
{
if
(
newPaoPao
.
y
<
cc
.
winSize
.
height
+
105
)
{
cc
.
tween
(
newPaoPao
).
to
((
750
-
newPaoPao
.
y
)
/
this
.
speed
,
{
y
:
cc
.
winSize
.
height
+
105
}).
call
(()
=>
{
newPaoPao
.
destroy
()
}).
start
()
}
if
(
this
.
touchNumber
>
this
.
data
.
questions
[
0
].
options
.
length
)
{
console
.
log
(
'
此题结束
'
)
}
else
{
let
bottom_megaphone
=
pg
.
view
.
find
(
this
,
'
layer_game/bg/bottom_megaphone
'
)
let
layer_paopao
=
pg
.
view
.
find
(
this
,
'
layer_game/bg/layer_paopao
'
)
let
paoaoParent
=
pg
.
view
.
find
(
this
,
'
layer_game/bg/paopao
'
)
let
newPaoPao
=
cc
.
instantiate
(
paoaoParent
)
// 点击泡泡
pg
.
view
.
touchOn
(
newPaoPao
,
this
.
touchPaoPao
,
this
)
let
paopao
=
newPaoPao
.
getChildByName
(
"
bubble
"
)
let
broken
=
newPaoPao
.
getChildByName
(
"
bubble_broken
"
)
let
img
=
newPaoPao
.
getChildByName
(
"
img
"
)
let
text
=
newPaoPao
.
getChildByName
(
"
text
"
)
// 判断是显示图片还是文字
if
(
this
.
data
.
questions
[
0
].
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
})
}
else
{
pg
.
view
.
visible
(
img
,
false
)
pg
.
view
.
visible
(
text
,
true
)
pg
.
view
.
setString
(
text
,
this
.
data
.
questions
[
0
].
options
[
this
.
touchNumber
-
1
].
text
)
}
let
btn
=
cc
.
tween
(
bottom_megaphone
)
layer_paopao
.
addChild
(
newPaoPao
)
btn
.
to
(
0.1
,
{
x
:
-
5
}).
to
(
0.1
,
{
x
:
0
}).
to
(
0.1
,
{
x
:
5
}).
to
(
0.1
,
{
x
:
0
})
btn
.
to
(
0.1
,
{
x
:
-
5
}).
to
(
0.1
,
{
x
:
0
}).
to
(
0.1
,
{
x
:
5
}).
to
(
0.1
,
{
x
:
0
})
.
call
(()
=>
{
newPaoPao
.
x
=
135
newPaoPao
.
y
=
-
450
paopao
.
width
=
70
paopao
.
height
=
70
newPaoPao
.
opacity
=
0
pg
.
view
.
visible
(
newPaoPao
,
true
)
pg
.
view
.
visible
(
broken
,
false
)
cc
.
tween
(
newPaoPao
).
to
(
0.8
,
{
opacity
:
255
}).
call
(()
=>
{
let
positionY
=
Math
.
floor
(
Math
.
random
()
*
300
)
let
positionX
=
this
.
getPositionX
()
this
.
targetPosition
=
positionY
cc
.
tween
(
newPaoPao
).
to
(
positionY
/
this
.
speed
,
{
x
:
positionX
,
y
:
positionY
,
scale
:
3
}).
call
(()
=>
{
if
(
newPaoPao
.
y
<
cc
.
winSize
.
height
+
105
)
{
cc
.
tween
(
newPaoPao
).
to
((
750
-
newPaoPao
.
y
)
/
this
.
speed
,
{
y
:
cc
.
winSize
.
height
+
105
}).
call
(()
=>
{
newPaoPao
.
destroy
()
}).
start
()
}
}).
start
()
}).
start
()
}).
start
()
})
btn
.
start
()
})
btn
.
start
()
}
this
.
touchNumber
++
;
}
getPositionX
()
{
...
...
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