Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
ls_gramophone
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
ls_gramophone
Commits
225ebf93
Commit
225ebf93
authored
Jun 08, 2022
by
李帅
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
+1
parent
c5834d39
Changes
5
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
250 additions
and
237 deletions
+250
-237
ls_gramophone.fire
assets/ls_gramophone/scene/ls_gramophone.fire
+172
-204
ls_gramophone.ts
assets/ls_gramophone/scene/ls_gramophone.ts
+29
-2
Item.ts
assets/ls_gramophone/script/Item.ts
+37
-1
defaultData.ts
assets/ls_gramophone/script/defaultData.ts
+2
-18
simpleLabel.ts
assets/ls_gramophone/script/simpleLabel.ts
+10
-12
No files found.
assets/ls_gramophone/scene/ls_gramophone.fire
View file @
225ebf93
This diff is collapsed.
Click to expand it.
assets/ls_gramophone/scene/ls_gramophone.ts
View file @
225ebf93
/*
* @Author: ls
* @Date: 2022-05-15 18:22:18
* @LastEditTime: 2022-0
5-31 21:56:35
* @LastEditTime: 2022-0
6-08 23:00:12
* @LastEditors: ls
* @Description:
* @FilePath: \ls_gramophone\assets\ls_gramophone\scene\ls_gramophone.ts
...
...
@@ -236,7 +236,34 @@ export default class SceneComponent extends MyCocosSceneComponent {
this
.
log
(
`录音的音频URL是
${
JSON
.
parse
(
res
).
audioUrl
}
`
);
if
(
idx
!==
-
1
)
{
this
.
content
.
children
[
idx
].
getComponent
(
Item
).
recorded
();
let
it
=
this
.
content
.
children
[
idx
].
getComponent
(
Item
);
it
.
recorded
();
let
arr
=
JSON
.
parse
(
res
).
result
.
sentences
[
0
].
details
;
let
arrOne
=
[];
for
(
let
index
=
0
;
index
<
arr
.
length
;
index
++
)
{
let
e
=
arr
[
index
];
arrOne
.
push
({
key
:
e
.
word
,
value
:
1
});
let
result
=
{};
arrOne
.
forEach
((
item
)
=>
{
if
(
result
[
item
.
key
])
{
result
[
item
.
key
]
+=
item
.
value
;
}
else
{
result
[
item
.
key
]
=
item
.
value
;
}
});
for
(
let
k
in
result
)
{
if
(
k
===
e
.
word
)
{
if
(
e
.
overall
<
40
)
{
it
.
setLow
(
e
.
word
,
result
[
k
]);
}
}
}
}
}
this
.
resetRecord
();
...
...
assets/ls_gramophone/script/Item.ts
View file @
225ebf93
/*
* @Author: ls
* @Date: 2022-05-21 21:59:51
* @LastEditTime: 2022-0
5-31 21:15:1
7
* @LastEditTime: 2022-0
6-08 22:57:2
7
* @LastEditors: ls
* @Description:
* @FilePath: \ls_gramophone\assets\ls_gramophone\script\Item.ts
...
...
@@ -31,6 +31,9 @@ export default class Item extends cc.Component {
@
property
(
cc
.
Node
)
myrecord_play
:
cc
.
Node
=
null
;
@
property
(
cc
.
Node
)
low
:
cc
.
Node
=
null
;
// 录制中
_recording
=
false
;
// 已录音
...
...
@@ -144,6 +147,7 @@ export default class Item extends cc.Component {
this
.
tip
.
active
=
true
;
// this.label.node.color = cc.color(255, 96, 0);
this
.
label
.
node
.
color
=
cc
.
color
(
108
,
185
,
0
);
this
.
hideLow
();
}
/**
...
...
@@ -152,5 +156,37 @@ export default class Item extends cc.Component {
stop
()
{
this
.
tip
.
active
=
false
;
this
.
label
.
node
.
color
=
cc
.
color
(
44
,
77
,
140
);
this
.
showLow
();
}
hideLow
()
{
this
.
label
.
node
.
children
.
forEach
((
e
)
=>
{
e
.
active
=
false
;
});
}
showLow
()
{
this
.
label
.
node
.
children
.
forEach
((
e
)
=>
{
e
.
active
=
true
;
});
}
clearLow
()
{
this
.
label
.
node
.
removeAllChildren
();
}
setLow
(
str
:
string
,
index
:
number
=
1
)
{
let
ps
=
this
.
label
.
getTargetStringPos
(
str
);
if
(
index
>
ps
.
length
)
{
return
;
}
let
p
=
ps
[
index
-
1
];
let
low
=
cc
.
instantiate
(
this
.
low
);
low
.
parent
=
this
.
label
.
node
;
low
.
active
=
true
;
low
.
width
=
p
.
z
;
low
.
getComponentInChildren
(
cc
.
Label
).
string
=
str
;
low
.
setPosition
(
p
.
y
,
(
p
.
x
-
1
)
*
48
);
}
}
assets/ls_gramophone/script/defaultData.ts
View file @
225ebf93
/*
* @Author: ls
* @Date: 2022-05-15 18:22:18
* @LastEditTime: 2022-0
5-22 00:13:54
* @LastEditTime: 2022-0
6-08 21:16:09
* @LastEditors: ls
* @Description:
* @FilePath: \ls_gramophone\assets\ls_gramophone\script\defaultData.ts
...
...
@@ -19,7 +19,7 @@ export const defaultData = {
audio
:
'
http://staging-teach.cdn.ireadabc.com/17edcaecd09a72a64a77480673cdc232.mp3
'
,
},
{
text
:
'
Good morning
'
,
text
:
'
what can i do for you
'
,
audio
:
'
http://staging-teach.cdn.ireadabc.com/17edcaecd09a72a64a77480673cdc232.mp3
'
,
},
{
...
...
@@ -34,21 +34,5 @@ export const defaultData = {
text
:
'
Hello, how dare you, Hello, how dare you
'
,
audio
:
'
http://staging-teach.cdn.ireadabc.com/17edcaecd09a72a64a77480673cdc232.mp3
'
,
},
{
text
:
'
Hello, how dare you, Hello, how dare you
'
,
audio
:
'
http://staging-teach.cdn.ireadabc.com/17edcaecd09a72a64a77480673cdc232.mp3
'
,
},
{
text
:
'
Hello, how dare you, Hello, how dare you
'
,
audio
:
'
http://staging-teach.cdn.ireadabc.com/17edcaecd09a72a64a77480673cdc232.mp3
'
,
},
{
text
:
'
Hello, how dare you, Hello, how dare you
'
,
audio
:
'
http://staging-teach.cdn.ireadabc.com/17edcaecd09a72a64a77480673cdc232.mp3
'
,
},
{
text
:
'
Hello, how dare you, Hello, how dare you
'
,
audio
:
'
http://staging-teach.cdn.ireadabc.com/17edcaecd09a72a64a77480673cdc232.mp3
'
,
},
],
};
assets/ls_gramophone/script/simpleLabel.ts
View file @
225ebf93
/*
* @Author: ls
* @Date: 2022-05-21 18:06:20
* @LastEditTime: 2022-0
5-31 22:45:56
* @LastEditTime: 2022-0
6-08 21:39:12
* @LastEditors: ls
* @Description:
* @FilePath: \ls_gramophone\assets\ls_gramophone\script\simpleLabel.ts
...
...
@@ -142,7 +142,7 @@ export default class simpleLabel extends cc.Component {
getTargetStringPos
(
str
:
string
)
{
let
poss
=
[];
let
rows
=
0
;
let
rows
=
this
.
_rows
;
let
lastString
=
''
;
if
(
this
.
_sourceArray
&&
this
.
_sourceArray
.
length
)
{
for
(
let
index
=
0
;
index
<
this
.
_sourceArray
.
length
;
index
++
)
{
...
...
@@ -162,22 +162,20 @@ export default class simpleLabel extends cc.Component {
// 增加行数
lastString
=
element
;
tempString
=
''
;
rows
++
;
rows
--
;
}
let
temp
=
element
;
if
(
element
.
indexOf
(
'
,
'
)
!==
-
1
)
{
temp
.
substring
(
element
.
indexOf
(
'
,
'
),
1
);
}
else
if
(
element
.
indexOf
(
'
.
'
)
!==
-
1
)
{
temp
.
substring
(
element
.
indexOf
(
'
.
'
),
1
);
}
else
if
(
element
.
indexOf
(
'
!
'
)
!==
-
1
)
{
temp
.
substring
(
element
.
indexOf
(
'
!
'
),
1
);
}
else
if
(
element
.
indexOf
(
'
?
'
)
!==
-
1
)
{
temp
.
substring
(
element
.
indexOf
(
'
?
'
),
1
);
if
(
element
.
indexOf
(
'
,
'
)
!==
-
1
||
element
.
indexOf
(
'
.
'
)
!==
-
1
||
element
.
indexOf
(
'
!
'
)
!==
-
1
||
element
.
indexOf
(
'
?
'
)
!==
-
1
)
{
temp
=
temp
.
substring
(
0
,
temp
.
length
-
1
);
}
if
(
temp
===
str
)
{
poss
.
push
(
rows
,
this
.
getLetterWidth
(
this
.
label
,
tempString
),
this
.
getLetterWidth
(
this
.
label
,
str
));
let
x
=
this
.
getLetterWidth
(
this
.
label
,
tempString
);
if
(
x
!==
0
)
{
x
+=
this
.
getLetterWidth
(
this
.
label
,
'
'
);
}
poss
.
push
(
cc
.
v3
(
rows
,
x
,
this
.
getLetterWidth
(
this
.
label
,
str
)));
}
}
}
...
...
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