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
5396b7b4
Commit
5396b7b4
authored
Jun 23, 2023
by
张子元
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:添加泡泡点击事件
parent
6d367c3d
Changes
2
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
258 additions
and
319 deletions
+258
-319
hy01_danci.fire
assets/hy01_danci/scene/hy01_danci.fire
+238
-312
hy01_danci.ts
assets/hy01_danci/scene/hy01_danci.ts
+20
-7
No files found.
assets/hy01_danci/scene/hy01_danci.fire
View file @
5396b7b4
This diff is collapsed.
Click to expand it.
assets/hy01_danci/scene/hy01_danci.ts
View file @
5396b7b4
...
@@ -21,6 +21,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -21,6 +21,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
}
private
speed
:
number
;
private
speed
:
number
;
private
isCorrect
:
boolean
;
private
targetPosition
:
number
;
async
onLoadEnd
()
{
async
onLoadEnd
()
{
// TODO 加载完成后的逻辑写在这里, 下面的代码仅供参考
// TODO 加载完成后的逻辑写在这里, 下面的代码仅供参考
...
@@ -75,6 +77,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -75,6 +77,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
cc
.
tween
(
newPaoPao
).
to
(
0.8
,
{
opacity
:
255
}).
call
(()
=>
{
cc
.
tween
(
newPaoPao
).
to
(
0.8
,
{
opacity
:
255
}).
call
(()
=>
{
let
positionY
=
Math
.
floor
(
Math
.
random
()
*
300
)
let
positionY
=
Math
.
floor
(
Math
.
random
()
*
300
)
let
positionX
=
this
.
getPositionX
()
let
positionX
=
this
.
getPositionX
()
this
.
targetPosition
=
positionY
cc
.
tween
(
newPaoPao
).
to
(
positionY
/
this
.
speed
,
{
x
:
positionX
,
y
:
positionY
,
scale
:
3
}).
call
(()
=>
{
cc
.
tween
(
newPaoPao
).
to
(
positionY
/
this
.
speed
,
{
x
:
positionX
,
y
:
positionY
,
scale
:
3
}).
call
(()
=>
{
if
(
newPaoPao
.
y
<
cc
.
winSize
.
height
+
105
)
{
if
(
newPaoPao
.
y
<
cc
.
winSize
.
height
+
105
)
{
cc
.
tween
(
newPaoPao
).
to
((
750
-
newPaoPao
.
y
)
/
this
.
speed
,
{
y
:
cc
.
winSize
.
height
+
105
}).
call
(()
=>
{
cc
.
tween
(
newPaoPao
).
to
((
750
-
newPaoPao
.
y
)
/
this
.
speed
,
{
y
:
cc
.
winSize
.
height
+
105
}).
call
(()
=>
{
...
@@ -96,13 +99,23 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -96,13 +99,23 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
}
// 点击泡泡
// 点击泡泡
touchPaoPao
(
e
:
any
)
{
touchPaoPao
(
e
:
any
)
{
// 如果泡泡没有到指定位置不允许点击
if
(
this
.
targetPosition
>
e
.
target
.
y
)
return
if
(
this
.
isCorrect
)
{
// 成功 泡泡破碎 里面的内容消失
// 成功 泡泡破碎 里面的内容消失
let
paopao
=
e
.
target
.
getChildByName
(
"
bubble
"
)
let
broken
=
e
.
target
.
getChildByName
(
"
bubble_broken
"
)
broken
.
width
=
70
broken
.
height
=
70
pg
.
view
.
visible
(
paopao
,
false
)
pg
.
view
.
visible
(
broken
,
true
)
}
else
{
// 失败 泡泡左右微晃两次
// 失败 泡泡左右微晃两次
let
fail
=
e
.
target
let
obj
=
cc
.
tween
(
e
.
target
)
let
btn
=
cc
.
tween
(
fail
)
obj
.
by
(
0.1
,
{
x
:
-
5
}).
by
(
0.1
,
{
x
:
0
}).
by
(
0.1
,
{
x
:
5
}).
by
(
0.1
,
{
x
:
0
}
)
btn
.
by
(
0.1
,
{
x
:
-
5
}).
by
(
0.1
,
{
x
:
0
}).
by
(
0.1
,
{
x
:
5
}).
by
(
0.1
,
{
x
:
0
})
obj
.
by
(
0.1
,
{
x
:
-
5
}).
by
(
0.1
,
{
x
:
0
}).
by
(
0.1
,
{
x
:
5
}).
by
(
0.1
,
{
x
:
0
})
btn
.
by
(
0.1
,
{
x
:
-
5
}).
by
(
0.1
,
{
x
:
0
}).
by
(
0.1
,
{
x
:
5
}).
by
(
0.1
,
{
x
:
0
}
)
obj
.
start
(
)
btn
.
start
()
}
}
}
}
}
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