Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
dg29_museum
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
dg29_museum
Commits
83628316
Commit
83628316
authored
Dec 21, 2023
by
Tt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
录音部分完成
parent
4bd56c06
Changes
2
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
900 additions
and
295 deletions
+900
-295
dg18_tianci.fire
assets/dg18_tianci/scene/dg18_tianci.fire
+761
-289
dg18_tianci.ts
assets/dg18_tianci/scene/dg18_tianci.ts
+139
-6
No files found.
assets/dg18_tianci/scene/dg18_tianci.fire
View file @
83628316
This diff is collapsed.
Click to expand it.
assets/dg18_tianci/scene/dg18_tianci.ts
View file @
83628316
...
...
@@ -3,6 +3,8 @@ import { MyCocosSceneComponent } from "../script/MyCocosSceneComponent_dg18_tian
import
pg
from
"
./pg_dg18_tianci
"
;
import
dg_xiaodi
from
"
./dg18_tianci_xiaodi
"
;
let
win
:
any
=
window
;
let
courseware
=
win
.
courseware
;
const
{
ccclass
,
property
}
=
cc
.
_decorator
;
@
ccclass
...
...
@@ -28,10 +30,10 @@ export default class SceneComponent extends MyCocosSceneComponent {
this
.
initData
();
this
.
initView
();
this
.
initEvent
();
pg
.
view
.
find
(
this
,
'
layout_xiaodi
'
).
getComponent
(
dg_xiaodi
).
playEnter
(
this
.
data
.
npcAudio
).
then
(()
=>
{
this
.
initGame
();
})
// pg.view.find(this, 'layout_xiaodi').getComponent(dg_xiaodi).playEnter(this.data.npcAudio).then(() => {
// this.initGame();
// })
this
.
initGame
();
}
_cantouch
=
null
;
...
...
@@ -56,13 +58,24 @@ export default class SceneComponent extends MyCocosSceneComponent {
@
property
(
cc
.
Node
)
question_img
:
cc
.
Node
=
null
;
@
property
(
cc
.
Node
)
label_title
:
cc
.
Node
=
null
;
@
property
(
cc
.
Node
)
btn_vioce
:
cc
.
Node
=
null
;
@
property
(
cc
.
Node
)
btn_restart
:
cc
.
Node
=
null
;
@
property
(
cc
.
Node
)
label_tip_wait
:
cc
.
Node
=
null
;
@
property
(
cc
.
Node
)
label_tip_ing
:
cc
.
Node
=
null
;
@
property
(
cc
.
Node
)
rich_content
:
cc
.
Node
=
null
;
// 初始化页面
initView
()
{
this
.
btn_vioce
.
active
=
false
;
this
.
btn_restart
.
active
=
false
;
this
.
label_tip_wait
.
active
=
false
;
this
.
label_tip_ing
.
active
=
false
;
this
.
rich_content
.
active
=
false
;
}
// 事件监听
initEvent
()
{
pg
.
view
.
touchOn
(
this
.
btn_vioce
,
this
.
onTouchRecord
,
this
);
pg
.
view
.
touchOn
(
pg
.
view
.
find
(
this
.
btn_vioce
,
'
img_ing
'
),
this
.
onTouchRecordEnd
,
this
);
}
// 初始化游戏
initGame
()
{
...
...
@@ -83,17 +96,137 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
this
.
current
++
this
.
successArr
=
[];
this
.
targetTime
=
10
//this.currentQuestion.targetTime
this
.
updateQuestion
();
}
updateQuestion
()
{
// 图片部分
pg
.
view
.
setNetImg
(
this
.
question_img
,
this
.
currentQuestion
.
img
,
{
w
:
1030
,
h
:
720
})
pg
.
view
.
setString
(
this
.
label_title
,
this
.
currentQuestion
.
title
);
pg
.
view
.
setString
(
this
.
label_title
,
this
.
currentQuestion
.
title
);
this
.
btn_vioce
.
active
=
true
;
pg
.
view
.
visible
(
pg
.
view
.
find
(
this
.
btn_vioce
,
'
img_ing
'
),
false
)
this
.
label_tip_wait
.
active
=
true
;
}
//按钮触发,使用的方法
private
targetTime
:
number
;
private
recordAudio
:
string
;
private
startTime
:
number
;
private
recording
:
boolean
;
private
voiceTouchForbid
:
boolean
;
private
count
:
number
;
showTimeStart
()
{
if
(
!
this
.
targetTime
)
return
;
let
nowTime
=
new
Date
().
getTime
();
this
.
startTime
=
nowTime
;
}
showTimeUpdate
()
{
if
(
!
this
.
startTime
)
return
;
let
nowTime
=
new
Date
().
getTime
();
let
subTime
=
this
.
targetTime
-
(
nowTime
-
this
.
startTime
)
/
1000
+
1
;
if
(
subTime
<
0
)
subTime
=
0
;
console
.
log
(
'
subTime->
'
+
subTime
)
this
.
label_tip_wait
.
active
=
false
this
.
label_tip_ing
.
active
=
true
;
pg
.
view
.
visible
(
pg
.
view
.
find
(
this
.
btn_vioce
,
'
img_ing
'
),
true
)
let
img_ing
=
pg
.
view
.
find
(
this
.
btn_vioce
,
'
img_ing
'
)
img_ing
.
getComponent
(
cc
.
Sprite
).
fillRange
=
subTime
/
this
.
targetTime
;
if
(
subTime
==
0
)
{
this
.
onTouchRecordEnd
();
}
}
showTimeEnd
()
{
this
.
startTime
=
null
;
this
.
label_tip_wait
.
active
=
false
this
.
label_tip_ing
.
active
=
false
;
pg
.
view
.
visible
(
pg
.
view
.
find
(
this
.
btn_vioce
,
'
img_ing
'
),
false
)
}
async
onTouchRecord
()
{
if
(
this
.
recording
)
return
;
if
(
this
.
recordAudio
)
return
;
this
.
recording
=
true
;
this
.
recordAudio
=
''
;
this
.
voiceTouchForbid
=
true
;
this
.
showTimeStart
();
this
.
log
(
"
-----------------------startTest
"
)
cc
.
audioEngine
.
stopAllEffects
();
courseware
&&
courseware
.
startRecord
(
1
);
//开始录音
}
async
onTouchRecordEnd
()
{
if
(
!
this
.
recording
)
return
;
this
.
showTimeEnd
();
let
testData
=
{
"
text
"
:
"
Hello every one my name is world
"
,
"
audio
"
:
"
https://staging-teach.cdn.ireadabc.com/6ee3ccaa831a884f02c6a75c6f647cb5.wav
"
}
if
(
!
courseware
)
{
return
this
.
recordEnd
(
testData
)
}
this
.
log
(
"
---------------courseware.stopTest:
"
)
courseware
&&
courseware
.
stopRecord
(
0
,
(
data
)
=>
{
this
.
log
(
"
---------------stopRecord:
"
+
data
)
// res = JSON.parse(res);
// res.exampleAudio = this.currentQuestion.startAudio ? this.currentQuestion.startAudio : "";
// res.exampleText = this.currentQuestion.keyword ? this.currentQuestion.keyword : "";
// this.recrodEnd(isClear, res);
data
=
JSON
.
parse
(
data
);
console
.
log
(
"
data:
"
+
JSON
.
stringify
(
data
));
this
.
recordEnd
(
data
);
});
//结束录音
}
recordEnd
(
data
)
{
const
keyTextArr
=
this
.
currentQuestion
.
keyword
.
split
(
"
,
"
);
const
dataTextArr
=
data
.
text
.
split
(
"
"
);
let
colorNormal
=
'
#313131
'
;
let
colorRight
=
'
#1D8B38
'
;
let
str
=
''
;
let
isRight
=
false
;
for
(
let
i
=
0
;
i
<
dataTextArr
.
length
;
i
++
)
{
const
word
=
dataTextArr
[
i
];
let
color
=
colorNormal
;
if
(
keyTextArr
.
indexOf
(
word
)
!=
-
1
)
{
color
=
colorRight
;
isRight
=
true
;
}
str
+=
`<color=
${
color
}
>
${
word
}
</color> `
}
this
.
rich_content
.
active
=
true
;
const
richText
=
this
.
rich_content
.
getComponent
(
cc
.
RichText
);
richText
.
string
=
str
;
}
showData
(
data
)
{
let
list
=
data
.
result
.
sentences
[
0
].
details
;
// 列表处理
let
str
=
""
;
let
keystr
=
""
;
for
(
let
i
=
0
;
i
<
list
.
length
;
i
++
)
{
let
li
=
list
[
i
];
let
s
=
""
;
if
(
li
.
overall
>
40
)
{
s
=
`<color=#000000>
${
li
.
word
}
</c>`
}
else
{
s
=
`<color=#FF0000>
${
li
.
word
}
</c>`
}
keystr
+=
li
.
word
+
2
str
+=
s
;
}
// this.label_rich.getComponent(cc.RichText).fontSize = num;
// this.label_rich.getComponent(cc.RichText).lineHeight = num;
// this.label_rich.getComponent(cc.RichText).string = str;
}
private
waitTime
:
number
;
update
(
dt
)
{
this
.
showTimeUpdate
();
if
(
!
this
.
waitTime
)
this
.
waitTime
=
8
;
this
.
waitTime
-=
dt
;
if
(
this
.
waitTime
<
0
)
{
...
...
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