Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
TXZS_G_002
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
TXZS_G_002
Commits
557f923c
Commit
557f923c
authored
Feb 17, 2023
by
李维
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
完成数据转换
parent
bc9a5e25
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
65 additions
and
0 deletions
+65
-0
TXZS_G_002.ts
assets/TXZS_G_002/scene/TXZS_G_002.ts
+65
-0
No files found.
assets/TXZS_G_002/scene/TXZS_G_002.ts
View file @
557f923c
...
@@ -88,6 +88,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -88,6 +88,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
// 所有全局变量 默认都是null
// 所有全局变量 默认都是null
//
//
// this.scheduleOnce(()=>{
// this.scheduleOnce(()=>{
// 把听写助手传来的数据 转换为游戏需要的数据
this
.
data
=
this
.
translateData
(
this
.
data
);
this
.
asyncPlayAudioByUrl
(
this
.
data
.
questionTextAudio
)
this
.
asyncPlayAudioByUrl
(
this
.
data
.
questionTextAudio
)
// },1)
// },1)
cc
.
find
(
"
Canvas/uiP/bg_tip
"
).
active
=
true
;
cc
.
find
(
"
Canvas/uiP/bg_tip
"
).
active
=
true
;
...
@@ -103,6 +105,69 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -103,6 +105,69 @@ export default class SceneComponent extends MyCocosSceneComponent {
this
.
btn_audio_on
.
on
(
cc
.
Node
.
EventType
.
TOUCH_END
,
this
.
onAudioOn
,
this
);
this
.
btn_audio_on
.
on
(
cc
.
Node
.
EventType
.
TOUCH_END
,
this
.
onAudioOn
,
this
);
}
}
// 数据转换 - 把听写助手传进来的数据转换成这个模板需要的游戏数据
private
translateData
(
data
)
{
// 把数组分割为4个一组
function
getQuestionGroupData
(
list
)
{
let
len
=
list
.
length
let
newList
=
[]
if
(
len
)
{
var
chunk
=
4
for
(
var
i
=
0
,
j
=
len
;
i
<
j
;
i
+=
chunk
)
{
newList
.
push
(
list
.
slice
(
i
,
i
+
chunk
))
}
}
console
.
log
(
newList
)
return
newList
}
// 把数据组装为成对数据
function
getPairData
(
itemData
,
index
)
{
return
[
{
pairIdx
:
index
+
1
,
audio
:
itemData
.
audio_url
,
type
:
"
text
"
,
text
:
itemData
.
text_en
},
{
pairIdx
:
index
+
1
,
audio
:
itemData
.
audio_url
,
type
:
"
text
"
,
text
:
itemData
.
text_cn
}
]
}
// data = [ { "id": 20, "pid": 19, "text_en": "what", "text_cn": "什么", "audio_url": "http://teach.cdn.ireadabc.com/36b5e5d9a5240bff453e95e2d74cece0.mp3", "audio_cn_url": "http://teach.cdn.ireadabc.com/27a5b4d9525a299e3806ccd991a8e5f9.mp3", "image_url": "[\"http://teach.cdn.ireadabc.com/b9b759a25cafbadc3130201e50cf4f85.jpeg\"]", "phonetic": "[wɒt]", "description": null, "mlk": null, "data": null, "seq": 1, "has_child": 0, "depth": 4, "created_date": "2023-02-01T10:07:13.000Z", "updated_date": "2023-02-10T03:31:34.000Z", "del": 0 }, { "id": 21, "pid": 19, "text_en": "is", "text_cn": "是", "audio_url": "http://teach.cdn.ireadabc.com/d7f9276c7ff13b734c74358d7580a193.mp3", "audio_cn_url": "http://teach.cdn.ireadabc.com/45100afa502326955d0f03cac87f1a5b.mp3", "image_url": null, "phonetic": "[ɪz]", "description": null, "mlk": null, "data": null, "seq": 2, "has_child": 0, "depth": 4, "created_date": "2023-02-01T10:07:13.000Z", "updated_date": "2023-02-10T03:31:34.000Z", "del": 0 }, { "id": 22, "pid": 19, "text_en": "what’s", "text_cn": "是什么", "audio_url": "http://teach.cdn.ireadabc.com/383082bc329464ae1580fffcd5e85d54.mp3", "audio_cn_url": "http://teach.cdn.ireadabc.com/244d88fbd98972865959d1c0fe50bdac.mp3", "image_url": null, "phonetic": "[wɒts]", "description": null, "mlk": null, "data": null, "seq": 3, "has_child": 0, "depth": 4, "created_date": "2023-02-01T10:07:13.000Z", "updated_date": "2023-02-10T03:31:34.000Z", "del": 0 }, { "id": 23, "pid": 19, "text_en": "your", "text_cn": "你的", "audio_url": "http://teach.cdn.ireadabc.com/09b268cd4e201e12f4f8af377308689b.mp3", "audio_cn_url": "http://teach.cdn.ireadabc.com/f723a8c809b4c910b416a9a6c9e34eb8.mp3", "image_url": "[\"http://teach.cdn.ireadabc.com/808504438919f5d2849dff97f7fb0ffd.jpg\",\"http://teach.cdn.ireadabc.com/fc9d5a0d4eba960aecae0d88b0c39acd.jpg\"]", "phonetic": "[jɔː(r)]", "description": null, "mlk": null, "data": null, "seq": 4, "has_child": 0, "depth": 4, "created_date": "2023-02-01T10:07:13.000Z", "updated_date": "2023-02-14T01:48:59.000Z", "del": 0 }, { "id": 24, "pid": 19, "text_en": "name", "text_cn": "名字", "audio_url": "http://teach.cdn.ireadabc.com/60bf983a10741a0796a3a71d1c0b5907.mp3", "audio_cn_url": "http://teach.cdn.ireadabc.com/0fa9f2cc4c971d870889d7b80976654f.mp3", "image_url": "[\"http://teach.cdn.ireadabc.com/a0d9907a44d617784b533dc920647dee.jpg\"]", "phonetic": "[neɪm]", "description": null, "mlk": null, "data": null, "seq": 5, "has_child": 0, "depth": 4, "created_date": "2023-02-01T10:07:13.000Z", "updated_date": "2023-02-10T03:31:34.000Z", "del": 0 }, { "id": 25, "pid": 19, "text_en": "please", "text_cn": "请", "audio_url": "http://teach.cdn.ireadabc.com/ee1c7821c46b49ba850ebefc598cdb5b.mp3", "audio_cn_url": "http://teach.cdn.ireadabc.com/ac372008acb6236b6a1428a334c7f0a5.mp3", "image_url": "[\"http://teach.cdn.ireadabc.com/a42594ef6c4fc5b1987d2b073ae675dd.webp\",\"http://teach.cdn.ireadabc.com/7fc1972331756f74dbcf7ae0215a809b.png\"]", "phonetic": "[pliːz]", "description": null, "mlk": null, "data": null, "seq": 6, "has_child": 0, "depth": 4, "created_date": "2023-02-01T10:07:13.000Z", "updated_date": "2023-02-10T03:31:34.000Z", "del": 0 }, { "id": 26, "pid": 19, "text_en": "good", "text_cn": "好的", "audio_url": "http://teach.cdn.ireadabc.com/3aeaf5c3884ad3f00a92900ed478c77e.mp3", "audio_cn_url": "http://teach.cdn.ireadabc.com/403ba0be9e118b5325e3ae8acbdd3743.mp3", "image_url": "[\"http://teach.cdn.ireadabc.com/42946cef3972cc2ddaded63ba0fc20c1.webp\"]", "phonetic": "[ɡʊd]", "description": null, "mlk": null, "data": null, "seq": 7, "has_child": 0, "depth": 4, "created_date": "2023-02-01T10:07:13.000Z", "updated_date": "2023-02-14T01:49:00.000Z", "del": 0 }, { "id": 27, "pid": 19, "text_en": "morning", "text_cn": "早晨,上午", "audio_url": "http://teach.cdn.ireadabc.com/382d219f6339f5e0980cb9b716dbac8d.mp3", "audio_cn_url": "http://teach.cdn.ireadabc.com/2c9c57ed86a6ca438c486543bc8bcb88.mp3", "image_url": "[\"http://teach.cdn.ireadabc.com/ffbf1f05334754e42deff6f8f2f96d3e.jpg\",\"http://teach.cdn.ireadabc.com/b8e68519a23841f248a09293a879ffe9.jpg\",\"http://teach.cdn.ireadabc.com/d72d4b2d838e91570a3e777eaa5f9420.jpg\"]", "phonetic": "['mɔːnɪŋ]", "description": null, "mlk": null, "data": null, "seq": 8, "has_child": 0, "depth": 4, "created_date": "2023-02-01T10:07:13.000Z", "updated_date": "2023-02-14T01:49:00.000Z", "del": 0 }, { "id": 28, "pid": 19, "text_en": "Ms.", "text_cn": "女士", "audio_url": "http://teach.cdn.ireadabc.com/81c51b5b602e3687c6b220727c5e5f55.mp3", "audio_cn_url": "http://teach.cdn.ireadabc.com/5476bff8440fc49bebad504a0bd86eba.mp3", "image_url": null, "phonetic": "[miz]", "description": null, "mlk": "Ms", "data": null, "seq": 9, "has_child": 0, "depth": 4, "created_date": "2023-02-01T10:07:13.000Z", "updated_date": "2023-02-14T07:46:34.000Z", "del": 0 }, { "id": 29, "pid": 19, "text_en": "my", "text_cn": "我的", "audio_url": "http://teach.cdn.ireadabc.com/d4463b448d966353c3c19ae9b9e6ca71.mp3", "audio_cn_url": "http://teach.cdn.ireadabc.com/cfbc278fb514c0bc9ca690f1c4df0950.mp3", "image_url": "[\"http://teach.cdn.ireadabc.com/a2c2888111d4c18015a7d01d55fe93fb.jpg\",\"http://teach.cdn.ireadabc.com/98aa7a0d3243e8a361fd2973e4563f93.jpg\",\"http://teach.cdn.ireadabc.com/8a8b042372a3304b66495039eb7a92ff.jpg\",\"http://teach.cdn.ireadabc.com/da793b5cf93ae8915574f42d837dbae3.jpg\",\"http://teach.cdn.ireadabc.com/56857caeabb7b5bd49fa3054b2e45a52.webp\"]", "phonetic": "[maɪ]", "description": null, "mlk": null, "data": null, "seq": 10, "has_child": 0, "depth": 4, "created_date": "2023-02-01T10:07:13.000Z", "updated_date": "2023-02-10T03:31:34.000Z", "del": 0 }, { "id": 30, "pid": 19, "text_en": "bird", "text_cn": "鸟", "audio_url": "http://teach.cdn.ireadabc.com/1ef04de98ddc59957edbc709901c60c7.mp3", "audio_cn_url": "http://teach.cdn.ireadabc.com/fae76ae6e1bcb53d63d6f38838587ae0.mp3", "image_url": "[\"http://teach.cdn.ireadabc.com/7cf3efe3d56e7fe69d6a1809b567d1ae.jpeg\",\"http://teach.cdn.ireadabc.com/64b0eb3286053f0bf7672f61f9e5565a.jpeg\",\"http://teach.cdn.ireadabc.com/deb296c3696ee0940dc91ee18eb68d27.webp\"]", "phonetic": "[bɜːd]", "description": null, "mlk": null, "data": null, "seq": 11, "has_child": 0, "depth": 4, "created_date": "2023-02-01T10:07:13.000Z", "updated_date": "2023-02-10T03:31:34.000Z", "del": 0 }, { "id": 31, "pid": 19, "text_en": "tweet", "text_cn": "小鸟啼叫", "audio_url": "http://teach.cdn.ireadabc.com/db4b0511e318b0725532aeba6181bd51.mp3", "audio_cn_url": "http://teach.cdn.ireadabc.com/867865f1650f3512adba56c83bcb9f3e.mp3", "image_url": null, "phonetic": "[twi:t]", "description": null, "mlk": null, "data": null, "seq": 12, "has_child": 0, "depth": 4, "created_date": "2023-02-01T10:07:13.000Z", "updated_date": "2023-02-10T03:31:34.000Z", "del": 0 }, { "id": 32, "pid": 19, "text_en": "a(n)", "text_cn": "一个", "audio_url": "http://teach.cdn.ireadabc.com/81eec7df521de5f8b0704fa114bc0aff.mp3", "audio_cn_url": "http://teach.cdn.ireadabc.com/618b7d333097f2e96b35bb9135231918.mp3", "image_url": null, "phonetic": "[ə][ən]", "description": null, "mlk": null, "data": null, "seq": 13, "has_child": 0, "depth": 4, "created_date": "2023-02-01T10:07:13.000Z", "updated_date": "2023-02-10T03:31:34.000Z", "del": 0 }, { "id": 33, "pid": 19, "text_en": "boy", "text_cn": "男孩", "audio_url": "http://teach.cdn.ireadabc.com/6c60ff7775afbb0b454f23151719e9d0.mp3", "audio_cn_url": "http://teach.cdn.ireadabc.com/e27330597469d5e81f0037c5846aca48.mp3", "image_url": "[\"http://teach.cdn.ireadabc.com/1f042535eef57f88054d46f903d87e80.jpeg\"]", "phonetic": "[bɔɪ]", "description": null, "mlk": null, "data": null, "seq": 14, "has_child": 0, "depth": 4, "created_date": "2023-02-01T10:07:13.000Z", "updated_date": "2023-02-10T03:31:34.000Z", "del": 0 }, { "id": 34, "pid": 19, "text_en": "girl", "text_cn": "女孩", "audio_url": "http://teach.cdn.ireadabc.com/d038b562b0c7781e718eb08550849143.mp3", "audio_cn_url": "http://teach.cdn.ireadabc.com/9ad553f6e10ddc1bfeb851082f9f1d25.mp3", "image_url": "[\"http://teach.cdn.ireadabc.com/896d19830863cfc1561553ebf3b6ecbe.webp\",\"http://teach.cdn.ireadabc.com/92354ec729582b3bb2ea05851e9d0806.webp\"]", "phonetic": "[ɡɜːl]", "description": null, "mlk": null, "data": null, "seq": 15, "has_child": 0, "depth": 4, "created_date": "2023-02-01T10:07:13.000Z", "updated_date": "2023-02-10T03:31:34.000Z", "del": 0 }, { "id": 35, "pid": 19, "text_en": "afternoon", "text_cn": "下午", "audio_url": "http://teach.cdn.ireadabc.com/1f70fe441cdca82832cdf7bc286796f7.mp3", "audio_cn_url": "http://teach.cdn.ireadabc.com/0ab162e708e2ba9991398f10107504ab.mp3", "image_url": "[\"http://teach.cdn.ireadabc.com/e4b9c73c31c47a7441bb6ac04d558c02.jpg\",\"http://teach.cdn.ireadabc.com/d2914aad9ce834ebb057b04400609a17.jpg\",\"http://teach.cdn.ireadabc.com/0ad04d2a371a51af723a2fae92ebbf10.jpg\"]", "phonetic": "[ˌɑːftə'nuːn]", "description": null, "mlk": null, "data": null, "seq": 16, "has_child": 0, "depth": 4, "created_date": "2023-02-01T10:07:13.000Z", "updated_date": "2023-02-10T03:31:34.000Z", "del": 0 }, { "id": 36, "pid": 19, "text_en": "panda", "text_cn": "熊猫", "audio_url": "http://teach.cdn.ireadabc.com/99b59a21ea78955c7e593c2f38ef31de.mp3", "audio_cn_url": "http://teach.cdn.ireadabc.com/a30d8dc936cbe5e1324b293faaa6e3ce.mp3", "image_url": "[\"http://teach.cdn.ireadabc.com/e32c4771a53e118e25fc0c16de7deccb.jpg\",\"http://teach.cdn.ireadabc.com/e79e9d8a7b391b55aabeb54281ccf5a7.jpg\"]", "phonetic": "['pændə]", "description": null, "mlk": null, "data": null, "seq": 17, "has_child": 0, "depth": 4, "created_date": "2023-02-01T10:07:13.000Z", "updated_date": "2023-02-10T03:31:34.000Z", "del": 0 } ];
// 按照需要的结构进行组装
const
tData
=
{
title
:
"
标题标题
"
,
questionText
:
"
题目说明题目说明题目说明题目说明题目说明题目说明题目说明
"
,
questionTextAudio
:
"
http://staging-teach.cdn.ireadabc.com/92ddbc65e9af775f7a8450a5bef1a732.mp3
"
,
bgAudio
:
"
https://staging-teach.cdn.ireadabc.com/ed84c18cc5f696ceaaf488ff98c228fe_l.mp3
"
,
questions
:
[]
}
const
groupData
=
getQuestionGroupData
(
data
);
groupData
.
forEach
((
group
,
gIndex
)
=>
{
const
qNum
=
group
.
length
;
const
configItem
=
{
watchTime
:
5
*
qNum
,
// 看题时间(秒)
gameTime
:
10
*
qNum
,
// 游戏时间(秒)
options
:
[]
}
group
.
forEach
((
item
,
index
)
=>
{
const
pairData
=
getPairData
(
item
,
index
);
configItem
.
options
=
configItem
.
options
.
concat
(
pairData
)
});
tData
.
questions
.
push
(
configItem
);
})
return
tData
;
}
private
onAudioOn
()
{
private
onAudioOn
()
{
this
.
btn_audio_off
.
active
=
true
;
this
.
btn_audio_off
.
active
=
true
;
this
.
btn_audio_on
.
active
=
false
;
this
.
btn_audio_on
.
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