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
3ab9a267
Commit
3ab9a267
authored
Jun 23, 2023
by
张子元
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:产生气泡并上移
parent
175b3d93
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
20 deletions
+48
-20
hy01_danci.ts
assets/hy01_danci/scene/hy01_danci.ts
+48
-20
No files found.
assets/hy01_danci/scene/hy01_danci.ts
View file @
3ab9a267
...
...
@@ -20,12 +20,25 @@ export default class SceneComponent extends MyCocosSceneComponent {
addPreloadAnima
()
{
}
private
speed
:
number
;
async
onLoadEnd
()
{
// TODO 加载完成后的逻辑写在这里, 下面的代码仅供参考
this
.
initData
()
this
.
initView
()
this
.
initEvent
()
this
.
initGame
()
}
initView
()
{
initData
()
{
this
.
speed
=
30
}
initView
()
{}
initEvent
()
{
let
bottom_megaphone
=
pg
.
view
.
find
(
this
,
'
layer_game/bg/bottom_megaphone
'
)
// 底部海螺点击事件
pg
.
view
.
touchOn
(
bottom_megaphone
,
this
.
create_bubbles
,
this
)
}
initGame
()
{
// 底部海螺
let
bottom_megaphone
=
pg
.
view
.
find
(
this
,
'
layer_game/bg/bottom_megaphone
'
)
// 开始海螺从底部升起
...
...
@@ -36,44 +49,59 @@ export default class SceneComponent extends MyCocosSceneComponent {
this
.
create_bubbles
()
})
btn
.
start
()
pg
.
view
.
touchOn
(
bottom_megaphone
,
this
.
create_bubbles
,
this
)
let
paoaParent
=
pg
.
view
.
find
(
this
,
'
layer_game/bg/paopao/bubble
'
)
// 点击泡泡
pg
.
view
.
touchOn
(
paoaParent
,
this
.
touchPaoPao
,
this
)
}
// 制造气泡
create_bubbles
()
{
let
bottom_megaphone
=
pg
.
view
.
find
(
this
,
'
layer_game/bg/bottom_megaphone
'
)
let
newPaoPao
=
cc
.
instantiate
(
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
)
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
(()
=>
{
let
paoaoParent
=
pg
.
view
.
find
(
this
,
'
layer_game/bg/paopao
'
)
let
paopao
=
pg
.
view
.
find
(
this
,
'
layer_game/bg/paopao/bubble
'
)
let
broken
=
pg
.
view
.
find
(
this
,
'
layer_game/bg/paopao/bubble_broken
'
)
paoaoParent
.
x
=
135
paoaoParent
.
y
=
-
450
newPaoPao
.
x
=
135
newPaoPao
.
y
=
-
450
paopao
.
width
=
70
paopao
.
height
=
70
paoaoParent
.
opacity
=
0
pg
.
view
.
visible
(
paoaoParent
,
true
)
newPaoPao
.
opacity
=
0
pg
.
view
.
visible
(
newPaoPao
,
true
)
pg
.
view
.
visible
(
broken
,
false
)
cc
.
tween
(
paoaoParent
).
to
(
0.8
,
{
opacity
:
255
}).
call
(()
=>
{
cc
.
tween
(
paoaoParent
).
to
(
2
,
{
x
:
Math
.
floor
(
Math
.
random
()
*
900
),
y
:
Math
.
floor
(
Math
.
random
()
*
300
),
scale
:
3
}).
start
()
// 点击泡泡
pg
.
view
.
touchOn
(
newPaoPao
,
this
.
touchPaoPao
,
this
)
cc
.
tween
(
newPaoPao
).
to
(
0.8
,
{
opacity
:
255
}).
call
(()
=>
{
let
positionY
=
Math
.
floor
(
Math
.
random
()
*
300
)
let
positionX
=
this
.
getPositionX
()
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
()
})
btn
.
start
()
}
getPositionX
()
{
if
(
Math
.
random
()
<
0.5
)
{
return
-
Math
.
floor
(
Math
.
random
()
*
900
)
}
else
{
return
Math
.
floor
(
Math
.
random
()
*
900
)
}
}
// 点击泡泡
touchPaoPao
()
{
touchPaoPao
(
e
:
any
)
{
// 成功 泡泡破碎 里面的内容消失
// 失败 泡泡左右微晃两次
let
fail
=
pg
.
view
.
find
(
this
,
'
layer_game/bg/paopao/bubble
'
)
let
fail
=
e
.
target
let
btn
=
cc
.
tween
(
fail
)
btn
.
to
(
0.1
,
{
x
:
-
5
}).
by
(
0.1
,
{
x
:
0
}).
by
(
0.1
,
{
x
:
5
}).
by
(
0.1
,
{
x
:
0
})
btn
.
to
(
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
})
btn
.
by
(
0.1
,
{
x
:
-
5
}).
by
(
0.1
,
{
x
:
0
}).
by
(
0.1
,
{
x
:
5
}).
by
(
0.1
,
{
x
:
0
})
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