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
b07e2306
Commit
b07e2306
authored
Jun 16, 2023
by
Tt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
b0f51c7b
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
730 additions
and
803 deletions
+730
-803
hy01_danci.fire
assets/hy01_danci/scene/hy01_danci.fire
+701
-737
hy01_danci.ts
assets/hy01_danci/scene/hy01_danci.ts
+29
-66
No files found.
assets/hy01_danci/scene/hy01_danci.fire
View file @
b07e2306
This diff is collapsed.
Click to expand it.
assets/hy01_danci/scene/hy01_danci.ts
View file @
b07e2306
...
...
@@ -33,8 +33,6 @@ export default class SceneComponent extends MyCocosSceneComponent {
private
static
Word_List_Len
:
number
=
8
;
private
word_area
:
cc
.
Node
;
private
answer_area
:
cc
.
Node
;
private
answer_word
:
cc
.
Node
;
private
upper_shadow
:
cc
.
Node
;
private
lower_shadow
:
cc
.
Node
;
private
lower_word
:
cc
.
Node
;
...
...
@@ -104,8 +102,6 @@ export default class SceneComponent extends MyCocosSceneComponent {
this
.
layer_word
=
pg
.
view
.
find
(
this
,
'
layer_word
'
)
this
.
word_area
=
pg
.
view
.
find
(
this
.
layer_word
,
"
word_area
"
);
this
.
answer_area
=
pg
.
view
.
find
(
this
.
layer_word
,
"
answer_area
"
);
this
.
answer_word
=
pg
.
view
.
find
(
this
.
layer_word
,
"
answer_area/answer_word
"
);
this
.
layer_back
=
pg
.
view
.
find
(
this
,
"
layer_back
"
);
this
.
back_board
=
pg
.
view
.
find
(
this
.
layer_back
,
"
board
"
);
...
...
@@ -139,54 +135,36 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
private
wordBgList
:
Array
<
cc
.
Node
>
;
private
wordList
:
Array
<
cc
.
Node
>
;
//单词的展示
showWord
()
{
pg
.
view
.
removChildren
(
this
.
word_area
)
pg
.
view
.
removChildren
(
this
.
answer_word
)
this
.
initWordBg
();
this
.
initWord
();
}
initWordBg
()
{
let
curWord
=
this
.
word_list
[
this
.
cur_index
];
let
ansArr
=
curWord
[
'
answer
'
];
// 大写的正则
const
reg
=
/^
[
A-Z
]
+$/
;
let
strArr
=
curWord
[
'
word
'
].
split
(
''
);
if
(
!
strArr
)
{
console
.
log
(
"
error->curWord
"
)
return
;
}
ansArr
.
forEach
((
ans
,
i
)
=>
{
// // 为大写
// let child = this.getWordBgNodeByStr(str);
// child.data = {
// group: i
// };
// //为小写
// pg.view.addChild(this.word_area, child)
if
(
ans
.
length
>
1
)
{
// 长度大于一需要做拆分
let
ansStrArr
=
ans
.
split
(
''
);
ansStrArr
.
forEach
((
str
,
m
)
=>
{
let
child
=
this
.
getWordBgNodeByStr
(
str
);
child
.
data
=
{
group
:
i
,
index
:
m
}
pg
.
view
.
addChild
(
this
.
word_area
,
child
)
})
}
else
{
let
child
=
this
.
getWordBgNodeByStr
(
ans
);
// 长度大于一需要做拆分
let
ansStrArr
=
ans
.
split
(
''
);
ansStrArr
.
forEach
((
str
,
m
)
=>
{
let
child
=
this
.
getWordBgNodeByStr
(
str
);
child
.
data
=
{
group
:
i
,
index
:
0
index
:
m
}
this
.
wordBgList
.
push
(
child
);
pg
.
view
.
addChild
(
this
.
word_area
,
child
)
}
}
)
});
if
(
!
ansArr
.
length
)
{
console
.
log
(
"
error->curWord
"
)
return
;
}
}
initWord
()
{
let
curWord
=
this
.
word_list
[
this
.
cur_index
];
let
ansArr
=
curWord
[
'
answer
'
];
let
itemPrefab
=
pg
.
view
.
find
(
this
.
layer_word
,
'
item
'
);
ansArr
.
forEach
((
ans
,
i
)
=>
{
// 利用单一节点存储多字母
...
...
@@ -197,34 +175,25 @@ export default class SceneComponent extends MyCocosSceneComponent {
itemClone
.
y
=
pos
.
y
;
itemClone
.
orgPos
=
cc
.
v2
(
pos
);
itemClone
.
active
=
true
;
pg
.
view
.
addChild
(
this
.
answer_word
,
itemClone
);
pg
.
view
.
addChild
(
this
.
word_area
,
itemClone
);
itemClone
.
on
(
cc
.
Node
.
EventType
.
TOUCH_START
,
this
.
onTouchStart
,
this
);
itemClone
.
on
(
cc
.
Node
.
EventType
.
TOUCH_MOVE
,
this
.
onTouchMove
,
this
);
itemClone
.
on
(
cc
.
Node
.
EventType
.
TOUCH_END
,
this
.
onTouchEnd
,
this
);
if
(
ans
.
length
>
1
)
{
// 长度大于一需要做拆分
let
ansStrArr
=
ans
.
split
(
''
);
ansStrArr
.
forEach
((
str
,
m
)
=>
{
let
child
=
this
.
getWordNodeByStr
(
str
);
child
.
data
=
{
group
:
i
,
index
:
m
}
pg
.
view
.
addChild
(
itemClone
,
child
)
})
}
else
{
let
child
=
this
.
getWordNodeByStr
(
ans
);
child
.
data
=
{
group
:
i
,
index
:
0
}
// 长度大于一需要做拆分
let
ansStrArr
=
ans
.
split
(
''
);
ansStrArr
.
forEach
((
str
,
m
)
=>
{
let
child
=
this
.
getWordNodeByStr
(
str
);
child
.
data
=
{
group
:
i
,
index
:
m
};
this
.
wordList
.
push
(
child
)
pg
.
view
.
addChild
(
itemClone
,
child
)
}
}
)
});
}
getItemPosByAns
(
ansArr
,
ans
)
{
let
pos
=
cc
.
v2
(
0
,
0
)
let
count
=
ansArr
.
indexOf
(
ans
);
...
...
@@ -300,12 +269,6 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
else
{
let
data
=
colliderNode
.
data
;
console
.
log
(
JSON
.
stringify
(
data
));
// 找到目标坐标
// let groupNode = this.word_area.children.find(node => {
// return node.data.group == data.group && node.data.index == 0;
// })
// let pos1 = cc.v2(groupNode.x - groupNode.width / 2);
// cc.tween(node).to(0.3, { x: pos1.x, y: pos1.y, scale: 1 }).start();
// nd运动到对应的节点
let
list
=
[]
...
...
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