Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
H
hy04_pinci
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
hy04_pinci
Commits
ba4cbdee
Commit
ba4cbdee
authored
Jun 18, 2023
by
Tt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
随机打乱
parent
1df43fae
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
12 deletions
+27
-12
hy04_pinci.ts
assets/hy04_pinci/scene/hy04_pinci.ts
+27
-12
No files found.
assets/hy04_pinci/scene/hy04_pinci.ts
View file @
ba4cbdee
...
...
@@ -46,7 +46,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
private
list
:
Array
<
{
type
,
text
,
right
,
imgage
,
duration
,
content
,
audio
}
>
;
private
recordFlag
:
boolean
;
//录音模式
// 单词列表
private
wordDataList
:
Array
<
object
>
;
private
wordDataList
:
Array
<
any
>
;
// 当前第几个
private
curIndex
:
number
=
0
;
initData
()
{
...
...
@@ -58,11 +58,22 @@ export default class SceneComponent extends MyCocosSceneComponent {
this
.
layers
=
[];
this
.
wordDataList
=
data
.
questions
.
map
(
question
=>
{
let
arr
=
question
.
letterList
.
map
((
letter
,
i
)
=>
{
letter
.
group
=
i
;
return
letter
;
})
return
{
img
:
question
.
image
,
audio
:
question
.
audio
,
type
:
question
.
type
,
// img
answer
:
question
.
letterList
.
map
(
letter
=>
letter
.
text
)
answerArr
:
arr
,
answerRand
:
arr
.
concat
().
sort
(()
=>
Math
.
random
()
-
0.5
)
.
sort
(()
=>
Math
.
random
()
-
0.5
).
sort
(()
=>
Math
.
random
()
-
0.5
).
sort
(()
=>
Math
.
random
()
-
0.5
)
.
sort
(()
=>
Math
.
random
()
-
0.5
).
sort
(()
=>
Math
.
random
()
-
0.5
)
.
sort
(()
=>
Math
.
random
()
-
0.5
).
sort
(()
=>
Math
.
random
()
-
0.5
)
.
sort
(()
=>
Math
.
random
()
-
0.5
).
sort
(()
=>
Math
.
random
()
-
0.5
)
.
sort
(()
=>
Math
.
random
()
-
0.5
).
sort
(()
=>
Math
.
random
()
-
0.5
)
.
sort
(()
=>
Math
.
random
()
-
0.5
)
}
})
console
.
log
(
data
);
...
...
@@ -127,7 +138,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
pg
.
event
.
once
(
'
layer_right_show_excellent_end
'
,
()
=>
{
this
.
curIndex
++
;
if
(
!
this
.
CurrentWord
)
{
alert
(
"
游戏结束画面暂无
"
)
//
alert("游戏结束画面暂无")
}
else
{
this
.
showWord
();
}
...
...
@@ -173,17 +184,19 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
}
initWordBg
()
{
let
ansArr
=
this
.
CurrentWord
.
answer
;
let
ansArr
=
this
.
CurrentWord
.
answer
Arr
;
let
count
=
-
1
;
ansArr
.
forEach
((
ans
,
i
)
=>
{
ansArr
.
forEach
((
ansObj
,
i
)
=>
{
let
ans
=
ansObj
.
text
;
let
group
=
ansObj
.
group
;
// 长度大于一需要做拆分
let
ansStrArr
=
ans
.
split
(
''
);
ansStrArr
.
forEach
((
str
,
m
)
=>
{
count
++
;
let
child
=
this
.
getWordBgNodeByStr
(
str
);
child
.
data
=
{
count
:
count
,
group
:
i
,
index
:
m
}
child
.
data
=
{
count
:
count
,
group
:
group
,
index
:
m
}
this
.
successGroupIds
[
`
${
i
}
`
]
=
false
;
let
pos
=
this
.
getWordBgPosByAns
(
ansArr
,
[
str
],
child
.
data
)
let
pos
=
this
.
getWordBgPosByAns
(
ansArr
.
map
(
ans
=>
ans
.
text
)
,
[
str
],
child
.
data
)
child
.
x
=
pos
.
x
;
child
.
y
=
pos
.
y
;
this
.
wordBgList
.
push
(
child
);
...
...
@@ -192,15 +205,17 @@ export default class SceneComponent extends MyCocosSceneComponent {
});
}
initWord
()
{
let
ansArr
=
this
.
CurrentWord
.
answer
;
let
ansArr
=
this
.
CurrentWord
.
answer
Rand
;
let
itemPrefab
=
pg
.
view
.
find
(
this
.
layer_word
,
'
item
'
);
let
count
=
-
1
;
ansArr
.
forEach
((
ans
,
i
)
=>
{
ansArr
.
forEach
((
ansObj
)
=>
{
let
ans
=
ansObj
.
text
;
let
group
=
ansObj
.
group
;
let
ansStrArr
=
ans
.
split
(
''
);
// 利用单一节点存储多字母
// 依据字符长度做不同的处理
let
itemClone
=
pg
.
view
.
clone
(
itemPrefab
)
let
{
pos
,
width
}
=
this
.
getItemPosWidthByAns
(
ansArr
,
ansStrArr
,
count
+
1
);
let
{
pos
,
width
}
=
this
.
getItemPosWidthByAns
(
ansArr
.
map
(
ans
=>
ans
.
text
)
,
ansStrArr
,
count
+
1
);
itemClone
.
x
=
pos
.
x
;
itemClone
.
y
=
pos
.
y
;
itemClone
.
orgPos
=
cc
.
v2
(
pos
);
...
...
@@ -216,8 +231,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
ansStrArr
.
forEach
((
str
,
m
)
=>
{
count
++
;
let
child
=
this
.
getWordNodeByStr
(
str
);
child
.
data
=
{
group
:
i
,
index
:
m
,
count
:
count
};
let
pos
=
this
.
getWordPosByAns
(
ansArr
,
[
str
],
child
.
data
);
child
.
data
=
{
group
:
group
,
index
:
m
,
count
:
count
};
let
pos
=
this
.
getWordPosByAns
(
ansArr
.
map
(
ans
=>
ans
.
text
)
,
[
str
],
child
.
data
);
child
.
x
=
pos
.
x
;
child
.
y
=
pos
.
y
;
this
.
wordList
.
push
(
child
)
...
...
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