Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
PU21
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
PU21
Commits
082b2e0c
Commit
082b2e0c
authored
May 24, 2021
by
jeff
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更新audio
parent
ee97fab7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
22 deletions
+33
-22
audioItem.js
play/assets/scene/scene/audioItem.js
+31
-21
scene.fire
play/assets/scene/scene/scene.fire
+1
-1
scene.js
play/assets/scene/scene/scene.js
+1
-0
No files found.
play/assets/scene/scene/audioItem.js
View file @
082b2e0c
...
@@ -8,16 +8,16 @@ cc.Class({
...
@@ -8,16 +8,16 @@ cc.Class({
tiao
:
cc
.
Node
,
tiao
:
cc
.
Node
,
moveBtn
:
cc
.
Node
moveBtn
:
cc
.
Node
},
},
on
l
oad
()
{
on
L
oad
()
{
this
.
_clip
=
null
this
.
_clip
=
null
this
.
_play
=
false
this
.
_play
=
false
this
.
_audioId
=
null
this
.
_totoalTime
=
null
this
.
_totoalTime
=
null
this
.
_nowTime
=
null
this
.
_nowTime
=
0
this
.
_pause
=
false
this
.
_pause
=
false
this
.
node
.
active
=
false
this
.
clip
=
null
},
},
onEnable
()
{
onEnable
()
{
this
.
_nowTime
=
0
cc
.
systemEvent
.
on
(
'
stopBgMusic
'
,
this
.
onEvent
,
this
)
cc
.
systemEvent
.
on
(
'
stopBgMusic
'
,
this
.
onEvent
,
this
)
this
.
moveBtn
.
on
(
cc
.
Node
.
EventType
.
TOUCH_START
,
this
.
onTouchStart
,
this
)
this
.
moveBtn
.
on
(
cc
.
Node
.
EventType
.
TOUCH_START
,
this
.
onTouchStart
,
this
)
this
.
moveBtn
.
on
(
cc
.
Node
.
EventType
.
TOUCH_MOVE
,
this
.
onTouchMove
,
this
)
this
.
moveBtn
.
on
(
cc
.
Node
.
EventType
.
TOUCH_MOVE
,
this
.
onTouchMove
,
this
)
...
@@ -37,38 +37,38 @@ cc.Class({
...
@@ -37,38 +37,38 @@ cc.Class({
init
(
url
)
{
init
(
url
)
{
if
(
!
this
.
au
)
{
this
.
au
=
new
cc
.
AudioSource
()
}
this
.
onEvent
()
this
.
onEvent
()
this
.
playBtn
.
active
=
true
this
.
node
.
active
=
false
this
.
pauseBtn
.
active
=
false
this
.
node
.
active
=
false
cc
.
assetManager
.
loadRemote
(
url
,
(
err
,
audioClip
)
=>
{
cc
.
assetManager
.
loadRemote
(
url
,
(
err
,
audioClip
)
=>
{
if
(
err
)
return
if
(
err
)
return
this
.
clip
=
audioClip
this
.
clip
=
audioClip
this
.
_nowTime
=
0
this
.
_totoalTime
=
audioClip
.
duration
this
.
_totoalTime
=
audioClip
.
duration
this
.
label
.
string
=
'
0:00/
'
+
this
.
transTime
(
this
.
_totoalTime
)
this
.
label
.
string
=
'
0:00/
'
+
this
.
transTime
(
this
.
_totoalTime
)
this
.
tiao
.
children
[
0
].
getComponent
(
cc
.
Sprite
).
fillRange
=
0
this
.
tiao
.
children
[
0
].
getComponent
(
cc
.
Sprite
).
fillRange
=
0
this
.
tiao
.
children
[
1
].
x
=
12
this
.
tiao
.
children
[
1
].
x
=
12
this
.
onAudioFinish
()
this
.
au
.
clip
=
this
.
clip
this
.
node
.
active
=
true
this
.
node
.
active
=
true
})
})
},
},
onAudioFinish
()
{
onAudioFinish
()
{
if
(
this
.
_
audioId
!=
null
)
{
if
(
this
.
_
play
)
{
this
.
pauseBtn
.
active
=
false
this
.
pauseBtn
.
active
=
false
this
.
playBtn
.
active
=
true
this
.
playBtn
.
active
=
true
this
.
_play
=
false
}
}
this
.
_play
=
false
this
.
_nowTime
=
0
this
.
_nowTime
=
0
this
.
_audioId
=
cc
.
audioEngine
.
play
(
this
.
clip
)
cc
.
audioEngine
.
pause
(
this
.
_audioId
)
cc
.
audioEngine
.
setFinishCallback
(
this
.
_audioId
,
this
.
onAudioFinish
.
bind
(
this
))
},
},
onTouchStart
()
{
onTouchStart
()
{
if
(
this
.
_play
)
{
if
(
this
.
_play
)
{
this
.
_pause
=
true
this
.
_pause
=
true
this
.
_play
=
false
this
.
_play
=
false
cc
.
audioEngine
.
pause
(
this
.
_audioId
)
this
.
au
.
pause
(
)
}
}
},
},
...
@@ -90,24 +90,28 @@ cc.Class({
...
@@ -90,24 +90,28 @@ cc.Class({
if
(
this
.
_pause
)
{
if
(
this
.
_pause
)
{
this
.
_play
=
true
this
.
_play
=
true
this
.
_pause
=
false
this
.
_pause
=
false
cc
.
audioEngine
.
resume
(
this
.
_audioId
)
this
.
au
.
play
(
)
}
}
cc
.
audioEngine
.
setCurrentTime
(
this
.
_audioId
,
this
.
_totoalTime
*
(
this
.
moveBtn
.
x
-
12
)
/
364
)
this
.
_nowTime
=
this
.
_totoalTime
*
(
this
.
moveBtn
.
x
-
12
)
/
364
this
.
au
.
setCurrentTime
(
this
.
_nowTime
)
},
},
onPlay
()
{
onPlay
()
{
if
(
this
.
_play
)
return
this
.
_play
=
true
this
.
pauseBtn
.
active
=
true
this
.
pauseBtn
.
active
=
true
this
.
playBtn
.
active
=
false
this
.
playBtn
.
active
=
false
this
.
_play
=
true
this
.
au
.
play
()
cc
.
audioEngine
.
resume
(
this
.
_audioId
)
this
.
au
.
setCurrentTime
(
this
.
_nowTime
)
cc
.
systemEvent
.
emit
(
'
stopWordsMusic
'
)
cc
.
systemEvent
.
emit
(
'
stopWordsMusic
'
)
},
},
onPause
()
{
onPause
()
{
if
(
!
this
.
_play
)
return
this
.
_play
=
false
this
.
pauseBtn
.
active
=
false
this
.
pauseBtn
.
active
=
false
this
.
playBtn
.
active
=
true
this
.
playBtn
.
active
=
true
this
.
_play
=
false
this
.
au
.
stop
()
cc
.
audioEngine
.
pause
(
this
.
_audioId
)
},
},
/** 定时回调 */
/** 定时回调 */
...
@@ -115,10 +119,16 @@ cc.Class({
...
@@ -115,10 +119,16 @@ cc.Class({
if
(
!
this
.
_play
)
return
if
(
!
this
.
_play
)
return
this
.
_nowTime
+=
dt
this
.
_nowTime
+=
dt
this
.
label
.
string
=
this
.
transTime
(
this
.
_nowTime
)
+
'
/
'
+
this
.
transTime
(
this
.
_totoalTime
)
this
.
label
.
string
=
this
.
transTime
(
this
.
_nowTime
)
+
'
/
'
+
this
.
transTime
(
this
.
_totoalTime
)
if
(
this
.
_nowTime
>
this
.
_totoalTime
)
this
.
_nowTime
=
this
.
_totoalTime
if
(
this
.
_nowTime
>
this
.
_totoalTime
)
{
this
.
_nowTime
=
this
.
_totoalTime
}
let
scale
=
this
.
_nowTime
/
this
.
_totoalTime
let
scale
=
this
.
_nowTime
/
this
.
_totoalTime
this
.
tiao
.
children
[
0
].
getComponent
(
cc
.
Sprite
).
fillRange
=
scale
this
.
tiao
.
children
[
0
].
getComponent
(
cc
.
Sprite
).
fillRange
=
scale
this
.
tiao
.
children
[
1
].
x
=
12
+
364
*
scale
this
.
tiao
.
children
[
1
].
x
=
12
+
364
*
scale
if
(
this
.
_nowTime
==
this
.
_totoalTime
)
{
this
.
onPause
()
this
.
_nowTime
=
0
}
},
},
onEvent
()
{
onEvent
()
{
...
...
play/assets/scene/scene/scene.fire
View file @
082b2e0c
...
@@ -1948,7 +1948,7 @@
...
@@ -1948,7 +1948,7 @@
"__id__": 57
"__id__": 57
}
}
],
],
"_active":
tru
e,
"_active":
fals
e,
"_components": [
"_components": [
{
{
"__id__": 59
"__id__": 59
...
...
play/assets/scene/scene/scene.js
View file @
082b2e0c
...
@@ -295,6 +295,7 @@ cc.Class({
...
@@ -295,6 +295,7 @@ cc.Class({
let
url
=
data
.
bgItem
.
bgAudioUrl
let
url
=
data
.
bgItem
.
bgAudioUrl
if
(
url
&&
url
!=
''
)
{
if
(
url
&&
url
!=
''
)
{
this
.
bgAudioNode
.
active
=
true
this
.
bgAudioNode
.
getComponent
(
'
audioItem
'
).
init
(
url
)
this
.
bgAudioNode
.
getComponent
(
'
audioItem
'
).
init
(
url
)
}
else
{
}
else
{
this
.
bgAudioNode
.
active
=
false
this
.
bgAudioNode
.
active
=
false
...
...
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