Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OP05
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
OP05
Commits
b83b2d6b
Commit
b83b2d6b
authored
Oct 11, 2022
by
李维
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加酷猫讲话动画
parent
9cec5578
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
7 deletions
+60
-7
OP05.js
assets/OP05/scene/OP05.js
+44
-7
util.js
assets/OP05/script/util.js
+16
-0
No files found.
assets/OP05/scene/OP05.js
View file @
b83b2d6b
import
{
onHomeworkFinish
}
from
"
../script/util
"
;
import
{
onHomeworkFinish
,
playDragonBoneAnimation
}
from
"
../script/util
"
;
import
{
defaultData
}
from
"
../script/defaultData
"
;
import
{
defaultData
}
from
"
../script/defaultData
"
;
import
{
itemData
}
from
"
./data
"
;
import
{
itemData
}
from
"
./data
"
;
import
{
hyLoader
}
from
"
./hyLoader
"
;
import
{
hyLoader
}
from
"
./hyLoader
"
;
...
@@ -300,8 +300,10 @@ cc.Class({
...
@@ -300,8 +300,10 @@ cc.Class({
this
.
initLayout
()
//完成后直接进入下一步
this
.
initLayout
()
//完成后直接进入下一步
})
})
}
else
{
}
else
{
this
.
coolCatSpeak
();
pg
.
audio
.
playAudioByUrl
(
this
.
_cat
.
start
).
then
(()
=>
{
pg
.
audio
.
playAudioByUrl
(
this
.
_cat
.
start
).
then
(()
=>
{
this
.
_catStartPlayed
=
true
;
this
.
_catStartPlayed
=
true
;
this
.
coolCatShutOut
();
pg
.
view
.
loadDB
(
carton
,
{
ske
:
this
.
_stageData
.
cartoonSke
,
tex
:
this
.
_stageData
.
cartoonTex
,
png
:
this
.
_stageData
.
cartoonPng
}).
then
((
animationName
)
=>
{
pg
.
view
.
loadDB
(
carton
,
{
ske
:
this
.
_stageData
.
cartoonSke
,
tex
:
this
.
_stageData
.
cartoonTex
,
png
:
this
.
_stageData
.
cartoonPng
}).
then
((
animationName
)
=>
{
this
.
animationName
=
animationName
;
this
.
animationName
=
animationName
;
GameManager
.
getIns
().
setState
(
1
);
GameManager
.
getIns
().
setState
(
1
);
...
@@ -420,9 +422,11 @@ cc.Class({
...
@@ -420,9 +422,11 @@ cc.Class({
let
btn_picture
=
pg
.
view
.
find
(
this
,
"
btn_picture
"
);
let
btn_picture
=
pg
.
view
.
find
(
this
,
"
btn_picture
"
);
// 一局失败弹出tryagain,同时下方录音按钮明亮并出现提示
// 一局失败弹出tryagain,同时下方录音按钮明亮并出现提示
this
.
coolCatSpeak
(
"
wrong
"
)
this
.
playSFX
(
"
audio_tryagain
"
).
then
(()
=>
{
this
.
playSFX
(
"
audio_tryagain
"
).
then
(()
=>
{
pg
.
view
.
visible
(
bg_tryagain
,
false
);
pg
.
view
.
visible
(
bg_tryagain
,
false
);
pg
.
view
.
visible
(
end
,
false
);
pg
.
view
.
visible
(
end
,
false
);
this
.
coolCatShutOut
();
})
})
pg
.
view
.
visible
(
end
,
true
);
pg
.
view
.
visible
(
end
,
true
);
pg
.
view
.
visible
(
bg_tryagain
,
true
);
pg
.
view
.
visible
(
bg_tryagain
,
true
);
...
@@ -433,8 +437,10 @@ cc.Class({
...
@@ -433,8 +437,10 @@ cc.Class({
this
.
_playing
=
true
;
this
.
_playing
=
true
;
this
.
_tryagainCount
++
;
this
.
_tryagainCount
++
;
this
.
_timeoutIds
.
push
(
setTimeout
(()
=>
{
this
.
_timeoutIds
.
push
(
setTimeout
(()
=>
{
this
.
coolCatSpeak
();
if
(
this
.
_tryagainCount
==
1
)
{
if
(
this
.
_tryagainCount
==
1
)
{
pg
.
audio
.
playAudioByUrl
(
this
.
_tryagain
.
one
).
then
(()
=>
{
pg
.
audio
.
playAudioByUrl
(
this
.
_tryagain
.
one
).
then
(()
=>
{
this
.
coolCatShutOut
();
this
.
_playing
=
false
;
this
.
_playing
=
false
;
})
})
// this.playSFX("audio_record");
// this.playSFX("audio_record");
...
@@ -447,6 +453,7 @@ cc.Class({
...
@@ -447,6 +453,7 @@ cc.Class({
action
.
start
();
action
.
start
();
}
else
if
(
this
.
_tryagainCount
==
2
)
{
}
else
if
(
this
.
_tryagainCount
==
2
)
{
pg
.
audio
.
playAudioByUrl
(
this
.
_tryagain
.
two
).
then
(()
=>
{
pg
.
audio
.
playAudioByUrl
(
this
.
_tryagain
.
two
).
then
(()
=>
{
this
.
coolCatShutOut
();
this
.
_playing
=
false
;
this
.
_playing
=
false
;
})
})
// this.playSFX("audio_record");
// this.playSFX("audio_record");
...
@@ -459,6 +466,7 @@ cc.Class({
...
@@ -459,6 +466,7 @@ cc.Class({
action
.
start
();
action
.
start
();
}
else
{
}
else
{
pg
.
audio
.
playAudioByUrl
(
this
.
_tryagain
.
three
).
then
(()
=>
{
pg
.
audio
.
playAudioByUrl
(
this
.
_tryagain
.
three
).
then
(()
=>
{
this
.
coolCatShutOut
();
this
.
_playing
=
false
;
this
.
_playing
=
false
;
this
.
nextStage
();
this
.
nextStage
();
})
})
...
@@ -486,8 +494,10 @@ cc.Class({
...
@@ -486,8 +494,10 @@ cc.Class({
pg
.
view
.
visible
(
end_success
,
false
);
pg
.
view
.
visible
(
end_success
,
false
);
pg
.
view
.
visible
(
bg_tryagain
,
false
);
pg
.
view
.
visible
(
bg_tryagain
,
false
);
this
.
coolCatSpeak
()
pg
.
audio
.
playAudioByUrl
(
this
.
_cat
.
finish
)
pg
.
audio
.
playAudioByUrl
(
this
.
_cat
.
finish
).
then
(()
=>
{
this
.
coolCatShutOut
();
})
// this.playSFX("audio_finish");
// this.playSFX("audio_finish");
// pg.view.visible(btn_picture, true);
// pg.view.visible(btn_picture, true);
pg
.
view
.
visible
(
btn_record
,
false
);
pg
.
view
.
visible
(
btn_record
,
false
);
...
@@ -551,7 +561,9 @@ cc.Class({
...
@@ -551,7 +561,9 @@ cc.Class({
resolve
(
''
);
resolve
(
''
);
}
}
})
})
this
.
coolCatSpeak
();
pg
.
audio
.
playAudioByUrl
(
this
.
_stageData
.
sound
).
then
(()
=>
{
pg
.
audio
.
playAudioByUrl
(
this
.
_stageData
.
sound
).
then
(()
=>
{
this
.
coolCatShutOut
();
audioFinished
=
true
;
audioFinished
=
true
;
if
(
aniFinished
&&
audioFinished
)
{
if
(
aniFinished
&&
audioFinished
)
{
this
.
_playing
=
false
;
this
.
_playing
=
false
;
...
@@ -571,7 +583,9 @@ cc.Class({
...
@@ -571,7 +583,9 @@ cc.Class({
resolve
(
''
);
resolve
(
''
);
}
}
})
})
this
.
coolCatSpeak
();
pg
.
audio
.
playAudioByUrl
(
this
.
_stageData
.
sound
).
then
(()
=>
{
pg
.
audio
.
playAudioByUrl
(
this
.
_stageData
.
sound
).
then
(()
=>
{
this
.
coolCatShutOut
();
audioFinished
=
true
;
audioFinished
=
true
;
if
(
aniFinished
&&
audioFinished
)
{
if
(
aniFinished
&&
audioFinished
)
{
this
.
_playing
=
false
;
this
.
_playing
=
false
;
...
@@ -608,7 +622,9 @@ cc.Class({
...
@@ -608,7 +622,9 @@ cc.Class({
resolve
(
""
);
resolve
(
""
);
}
else
{
}
else
{
this
.
_audio_record
=
true
;
this
.
_audio_record
=
true
;
this
.
coolCatSpeak
();
pg
.
audio
.
playAudioByUrl
(
this
.
_cat
.
record
).
then
(()
=>
{
pg
.
audio
.
playAudioByUrl
(
this
.
_cat
.
record
).
then
(()
=>
{
this
.
coolCatShutOut
();
this
.
_playing
=
false
;
this
.
_playing
=
false
;
resolve
(
''
);
resolve
(
''
);
})
})
...
@@ -708,6 +724,7 @@ cc.Class({
...
@@ -708,6 +724,7 @@ cc.Class({
onTouchRecord
()
{
onTouchRecord
()
{
if
(
this
.
_playing
)
{
if
(
this
.
_playing
)
{
cc
.
audioEngine
.
stopAllEffects
();
cc
.
audioEngine
.
stopAllEffects
();
this
.
coolCatShutOut
();
}
}
this
.
playSFX
(
"
audio_btns
"
);
this
.
playSFX
(
"
audio_btns
"
);
let
end
=
pg
.
view
.
find
(
this
,
"
end
"
);
let
end
=
pg
.
view
.
find
(
this
,
"
end
"
);
...
@@ -797,14 +814,18 @@ cc.Class({
...
@@ -797,14 +814,18 @@ cc.Class({
if
(
GameManager
.
getIns
().
getState
()
>=
5
)
{
if
(
GameManager
.
getIns
().
getState
()
>=
5
)
{
if
(
this
.
_playing
)
return
;
if
(
this
.
_playing
)
return
;
this
.
_playing
=
true
;
this
.
_playing
=
true
;
this
.
coolCatSpeak
(
"
finish
"
);
pg
.
audio
.
playAudioByUrl
(
this
.
_cat
.
finish
).
then
(()
=>
{
pg
.
audio
.
playAudioByUrl
(
this
.
_cat
.
finish
).
then
(()
=>
{
this
.
_playing
=
false
;
this
.
_playing
=
false
;
this
.
coolCatShutOut
();
})
})
}
else
{
}
else
{
if
(
this
.
_playing
)
return
;
if
(
this
.
_playing
)
return
;
this
.
_playing
=
true
;
this
.
_playing
=
true
;
this
.
coolCatSpeak
();
pg
.
audio
.
playAudioByUrl
(
this
.
_cat
.
wait
).
then
(()
=>
{
pg
.
audio
.
playAudioByUrl
(
this
.
_cat
.
wait
).
then
(()
=>
{
this
.
_playing
=
false
;
this
.
_playing
=
false
;
this
.
coolCatShutOut
();
})
})
}
}
},
},
...
@@ -833,10 +854,21 @@ cc.Class({
...
@@ -833,10 +854,21 @@ cc.Class({
this
.
resultArr
.
push
({
word
,
score
,
audio_url
});
this
.
resultArr
.
push
({
word
,
score
,
audio_url
});
},
},
// 酷猫讲话动画
coolCatSpeak
(
aniName
=
"
begin
"
)
{
const
cat
=
cc
.
find
(
'
Canvas/mao_ske
'
);
console
.
log
(
playDragonBoneAnimation
)
playDragonBoneAnimation
(
cat
,
aniName
,
-
1
);
return
()
=>
{
playDragonBoneAnimation
(
cat
,
'
noraml
'
,
-
1
);
}
},
// 酷猫闭嘴
coolCatShutOut
()
{
const
cat
=
cc
.
find
(
'
Canvas/mao_ske
'
);
playDragonBoneAnimation
(
cat
,
'
normal
'
,
-
1
);
},
onTouchIconRecord
()
{
onTouchIconRecord
()
{
...
@@ -929,7 +961,10 @@ cc.Class({
...
@@ -929,7 +961,10 @@ cc.Class({
//
//
onTouchVoice
(
touch
)
{
onTouchVoice
(
touch
)
{
let
item
=
touch
.
target
;
let
item
=
touch
.
target
;
pg
.
audio
.
playAudioByUrl
(
item
.
data
.
audio_url
);
this
.
coolCatSpeak
();
pg
.
audio
.
playAudioByUrl
(
item
.
data
.
audio_url
).
then
(()
=>
{
this
.
coolCatShutOut
();
})
},
},
//回合结束
//回合结束
groupEnd
()
{
groupEnd
()
{
...
@@ -1044,9 +1079,11 @@ cc.Class({
...
@@ -1044,9 +1079,11 @@ cc.Class({
var
anim
=
pg
.
view
.
find
(
item
,
`audio`
).
getComponent
(
cc
.
Animation
);
var
anim
=
pg
.
view
.
find
(
item
,
`audio`
).
getComponent
(
cc
.
Animation
);
anim
.
play
();
anim
.
play
();
//如果没有audio也要能正常走
//如果没有audio也要能正常走
this
.
coolCatSpeak
();
pg
.
audio
.
playAudioByUrl
(
item
.
data
.
audio
).
then
(()
=>
{
pg
.
audio
.
playAudioByUrl
(
item
.
data
.
audio
).
then
(()
=>
{
anim
.
stop
();
anim
.
stop
();
pg
.
view
.
visible
(
pg
.
view
.
find
(
item
,
`audio/btn_laba`
),
true
);
pg
.
view
.
visible
(
pg
.
view
.
find
(
item
,
`audio/btn_laba`
),
true
);
this
.
coolCatShutOut
();
resolve
(
''
);
resolve
(
''
);
});
});
});
});
...
...
assets/OP05/script/util.js
View file @
b83b2d6b
...
@@ -346,4 +346,20 @@ export function onHomeworkFinish(data) {
...
@@ -346,4 +346,20 @@ export function onHomeworkFinish(data) {
}
else
{
}
else
{
console
.
log
(
'
onHomeworkFinish
'
);
console
.
log
(
'
onHomeworkFinish
'
);
}
}
}
export
function
playDragonBoneAnimation
(
node
,
animationName
,
time
=
1
,
onFinish
=
null
,
onFrameEvent
=
null
)
{
const
armatureDisplay
=
node
.
getComponent
(
dragonBones
.
ArmatureDisplay
);
armatureDisplay
.
timeScale
=
1
;
armatureDisplay
.
once
(
dragonBones
.
EventObject
.
COMPLETE
,
()
=>
{
if
(
onFinish
)
{
onFinish
();
}
});
armatureDisplay
.
on
(
dragonBones
.
EventObject
.
FRAME_EVENT
,
(
event
)
=>
{
if
(
onFrameEvent
)
{
onFrameEvent
(
event
);
}
});
armatureDisplay
.
playAnimation
(
animationName
,
time
);
}
}
\ No newline at end of file
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