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
f7592cc1
Commit
f7592cc1
authored
Jul 14, 2023
by
Tt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
空格文字支持
parent
ca481740
Changes
5
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
1134 additions
and
701 deletions
+1134
-701
.DS_Store
.DS_Store
+0
-0
Alibaba_PuHuiTi_Bold_hy04_pinci.ttf
...nci/common/layer_back/Alibaba_PuHuiTi_Bold_hy04_pinci.ttf
+0
-0
hy04_pinci.fire
assets/hy04_pinci/scene/hy04_pinci.fire
+1040
-668
hy04_pinci.ts
assets/hy04_pinci/scene/hy04_pinci.ts
+87
-26
defaultData_hy04_pinci.ts
assets/hy04_pinci/script/defaultData_hy04_pinci.ts
+7
-7
No files found.
.DS_Store
View file @
f7592cc1
No preview for this file type
assets/hy04_pinci/common/layer_back/Alibaba_PuHuiTi_Bold_hy04_pinci.ttf
View file @
f7592cc1
No preview for this file type
assets/hy04_pinci/scene/hy04_pinci.fire
View file @
f7592cc1
This diff is collapsed.
Click to expand it.
assets/hy04_pinci/scene/hy04_pinci.ts
View file @
f7592cc1
...
...
@@ -3,6 +3,8 @@ import { MyCocosSceneComponent } from "../script/MyCocosSceneComponent_hy04_pinc
import
pg
from
"
./pg_hy04_pinci
"
;
import
ImgVoice
from
"
../common/script/ImgVoice_hy04_pinci
"
;
import
Candy
from
"
./hy01_candy_hy04_pinci
"
;
// 空格问题
// 尺寸大小问题
const
{
ccclass
,
property
}
=
cc
.
_decorator
;
enum
WORD_TYPE
{
...
...
@@ -12,20 +14,25 @@ enum WORD_TYPE {
@
ccclass
export
default
class
SceneComponent
extends
MyCocosSceneComponent
{
addPreloadImage
()
{
// TODO 根据自己的配置预加载图片资源
this
.
_imageResList
.
push
({
url
:
this
.
data
.
pic_url
});
this
.
_imageResList
.
push
({
url
:
this
.
data
.
pic_url_2
});
//
//
TODO 根据自己的配置预加载图片资源
//
this._imageResList.push({ url: this.data.pic_url });
//
this._imageResList.push({ url: this.data.pic_url_2 });
}
addPreloadAudio
()
{
// TODO 根据自己的配置预加载音频资源
let
data
=
this
.
data
;
let
arr
=
[];
arr
.
push
(
data
.
npcAudio
);
data
.
questions
.
forEach
(
question
=>
{
arr
.
push
(
question
.
audio
)
})
this
.
_audioResList
=
this
.
_animaResList
.
concat
(
arr
);
let
audios
=
[];
function
checkAudio
(
obj
)
{
for
(
let
idx
in
obj
)
{
if
(
typeof
obj
[
idx
]
==
"
object
"
)
{
checkAudio
(
obj
[
idx
]);
}
else
if
(
typeof
obj
[
idx
]
==
"
string
"
)
{
if
(
obj
[
idx
].
indexOf
(
"
.mp3
"
)
>
-
1
)
audios
.
push
(
obj
[
idx
]);
}
}
}
checkAudio
(
this
.
data
)
this
.
_audioResList
=
audios
;
}
addPreloadAnima
()
{
...
...
@@ -121,10 +128,21 @@ export default class SceneComponent extends MyCocosSceneComponent {
this
.
showWord
();
}
gameOver
()
{
pg
.
event
.
once
(
'
layer_ending_touch_replay
'
,
()
=>
{
this
.
replay
();
})
pg
.
event
.
emit
(
'
layer_ending_show
'
,
{
coin
:
this
.
wordDataList
.
length
*
3
})
this
.
onDestroy
();
const
middleLayer
=
cc
.
find
(
'
middleLayer
'
);
if
(
!
middleLayer
)
return
;
const
middleLayerComponent
=
middleLayer
.
getComponent
(
'
middleLayer
'
);
if
(
!
middleLayerComponent
)
return
;
const
{
index
,
length
}
=
middleLayerComponent
.
getPageInfo
();
// 返回 length:有多少页; index: 当前第几页(从0开始)
if
(
index
==
length
-
1
)
{
middleLayerComponent
.
goNextCross
();
// 跳转到下一关卡
}
else
{
middleLayerComponent
.
goNextPage
();
// 跳转到下一页
}
// pg.event.once('layer_ending_touch_replay', () => {
// this.replay();
// })
// pg.event.emit('layer_ending_show', { coin: this.wordDataList.length * 3 })
}
private
wordBgList
:
Array
<
cc
.
Node
>
;
...
...
@@ -184,6 +202,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
initQuestion
()
{
this
.
layer_question
=
pg
.
view
.
find
(
this
,
'
layer_question
'
);
let
img
=
pg
.
view
.
find
(
this
.
layer_question
,
'
img
'
);
img
.
active
=
true
;
pg
.
view
.
setNetImg
(
img
,
this
.
CurrentWord
.
img
,
{
w
:
230
,
h
:
230
})
let
img_voice
=
pg
.
view
.
find
(
this
.
layer_question
,
'
img_voice
'
);
...
...
@@ -218,16 +237,26 @@ export default class SceneComponent extends MyCocosSceneComponent {
initWordBg
()
{
let
ansArr
=
this
.
CurrentWord
.
answerArr
;
let
count
=
-
1
;
// 长度大于一需要做拆分
let
scale
=
1
;
// let allWord = "";
// ansArr.forEach(ar => {
// allWord += ar.text
// })
// if (allWord.length > 1) {
// scale = 1 - (allWord.length - 1) * 0.1;
// }
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
:
group
,
index
:
m
}
this
.
successGroupIds
[
`
${
i
}
`
]
=
false
;
let
child
=
this
.
getWordBgNodeByStr
(
str
,
scale
);
child
.
data
=
{
count
:
count
,
group
:
group
,
index
:
m
,
value
:
str
}
this
.
successGroupIds
[
`
${
i
}
`
]
=
!
str
.
trim
()
;
let
pos
=
this
.
getWordBgPosByAns
(
ansArr
.
map
(
ans
=>
ans
.
text
),
[
str
],
child
.
data
)
child
.
x
=
pos
.
x
;
child
.
y
=
pos
.
y
;
...
...
@@ -238,10 +267,23 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
initWord
()
{
let
ansArr
=
this
.
CurrentWord
.
answerRand
;
ansArr
=
ansArr
.
filter
(
ans
=>
!!
ans
.
text
.
trim
());
let
itemPrefab
=
pg
.
view
.
find
(
this
.
layer_word
,
'
item
'
);
let
count
=
-
1
;
// 长度大于一需要做拆分
let
scale
=
1
;
// let allWord = "";
// ansArr.forEach(ar => {
// allWord += ar.text
// })
// if (allWord.length > 5) {
// scale = 1 - (allWord.length - 5) * 0.1;
// }
ansArr
.
forEach
((
ansObj
)
=>
{
let
ans
=
ansObj
.
text
;
ans
=
ans
.
trim
();
let
group
=
ansObj
.
group
;
let
ansStrArr
=
ans
.
split
(
''
);
// 利用单一节点存储多字母
...
...
@@ -257,13 +299,11 @@ export default class SceneComponent extends MyCocosSceneComponent {
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
);
// 长度大于一需要做拆分
let
arr
=
[];
ansStrArr
.
forEach
((
str
,
m
)
=>
{
count
++
;
let
child
=
this
.
getWordNodeByStr
(
str
);
child
.
data
=
{
group
:
group
,
index
:
m
,
count
:
count
};
let
child
=
this
.
getWordNodeByStr
(
str
,
scale
);
child
.
data
=
{
group
:
group
,
index
:
m
,
count
:
count
,
value
:
str
};
let
pos
=
this
.
getWordPosByAns
(
ansArr
.
map
(
ans
=>
ans
.
text
),
[
str
],
child
.
data
);
child
.
x
=
pos
.
x
;
child
.
y
=
pos
.
y
;
...
...
@@ -357,35 +397,43 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
getWordNodeWidth
(
type
,
str
)
{
str
=
str
.
trim
();
// if (!str) return 0;
const
reg
=
/^
[
A-Z
]
+$/
;
const
lower
=
str
.
toLowerCase
()
if
(
type
===
WORD_TYPE
.
TOUCH
)
{
let
prefabNode
=
reg
.
test
(
str
)
?
pg
.
view
.
find
(
this
.
upper_word
,
`
${
lower
}
2`
)
:
pg
.
view
.
find
(
this
.
lower_word
,
`
${
lower
}
`
)
let
prefabNode
=
reg
.
test
(
str
)
?
pg
.
view
.
find
(
this
.
upper_word
,
`
${
lower
}
2`
)
:
pg
.
view
.
find
(
this
.
lower_word
,
`
${
lower
}
1
`
)
return
prefabNode
.
width
+
20
;
}
else
{
let
prefabNode
=
reg
.
test
(
str
)
?
pg
.
view
.
find
(
this
.
upper_shadow
,
`
${
lower
}
2_di`
)
:
pg
.
view
.
find
(
this
.
lower_shadow
,
`
${
lower
}
_di`
);
return
prefabNode
.
width
+
30
;
}
}
getWordNodeByStr
(
str
)
{
getWordNodeByStr
(
str
,
scale
)
{
str
=
str
.
trim
();
const
reg
=
/^
[
A-Z
]
+$/
;
const
lower
=
str
.
toLowerCase
()
let
wordNode
=
pg
.
view
.
find
(
this
.
layer_word
,
'
word
'
);
let
item
=
pg
.
view
.
clone
(
wordNode
);
let
prefabNode
=
reg
.
test
(
str
)
?
pg
.
view
.
find
(
this
.
upper_word
,
`
${
lower
}
2`
)
:
pg
.
view
.
find
(
this
.
lower_word
,
`
${
lower
}
`
)
let
prefabNode
=
reg
.
test
(
str
)
?
pg
.
view
.
find
(
this
.
upper_word
,
`
${
lower
}
2`
)
:
pg
.
view
.
find
(
this
.
lower_word
,
`
${
lower
}
1
`
)
let
child
=
pg
.
view
.
clone
(
prefabNode
)
child
.
x
=
0
;
child
.
y
=
0
;
child
.
width
*=
scale
;
child
.
height
*=
scale
;
child
.
active
=
true
;
let
width
=
this
.
getItemWordWidth
(
WORD_TYPE
.
TOUCH
,
[
str
])
item
.
x
=
0
;
item
.
y
=
0
;
item
.
width
=
width
;
item
.
width
*=
scale
;
item
.
height
*=
scale
;
item
.
active
=
true
;
item
.
getChildByName
(
"
icon
"
).
addChild
(
child
);
return
item
;
}
getWordBgNodeByStr
(
str
)
{
getWordBgNodeByStr
(
str
,
scale
)
{
str
=
str
.
trim
();
const
reg
=
/^
[
A-Z
]
+$/
;
const
lower
=
str
.
toLowerCase
()
let
prefabNode
=
reg
.
test
(
str
)
?
pg
.
view
.
find
(
this
.
upper_shadow
,
`
${
lower
}
2_di`
)
:
pg
.
view
.
find
(
this
.
lower_shadow
,
`
${
lower
}
_di`
);
...
...
@@ -394,6 +442,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
child
.
active
=
true
child
.
x
=
0
;
child
.
y
=
0
;
child
.
width
*=
scale
;
child
.
height
*=
scale
;
return
child
;
}
getWordBgByGroup
(
group
)
{
...
...
@@ -457,8 +507,19 @@ export default class SceneComponent extends MyCocosSceneComponent {
this
.
currentItem
=
null
;
// 跟字母区域进行碰撞检测
let
groupId
=
this
.
collider
(
node
);
let
colliderList
=
this
.
getWordBgByGroup
(
groupId
);
let
colliderStr
=
''
;
if
(
colliderList
)
{
colliderList
.
forEach
(
nd
=>
{
colliderStr
+=
nd
.
data
.
value
;
})
}
let
str
=
""
;
node
.
data
.
forEach
(
nd
=>
{
str
+=
nd
.
data
.
value
;
})
// 获取当前待碰撞区域
if
((
groupId
||
groupId
==
0
)
&&
node
.
data
[
0
].
data
.
group
==
groupId
)
{
if
((
groupId
||
groupId
==
0
)
&&
!
this
.
successGroupIds
[
`
${
groupId
}
`
]
&&
(
node
.
data
[
0
].
data
.
group
==
groupId
||
str
==
colliderStr
)
)
{
console
.
log
(
groupId
)
// 正确了 需要处理效果
pg
.
audio
.
playLocalAudio
(
pg
.
view
.
find
(
this
.
res_audio
,
"
right
"
))
...
...
assets/hy04_pinci/script/defaultData_hy04_pinci.ts
View file @
f7592cc1
...
...
@@ -10,28 +10,28 @@ export const defaultData =
"
questionAudio
"
:
""
,
"
duration
"
:
120
,
"
type
"
:
"
img
"
,
"
image
"
:
"
http://staging-teach.cdn.ireadabc.com/e184e067fc931d55fce93c9937a26c51.png
"
,
"
image
"
:
"
"
,
//http://staging-teach.cdn.ireadabc.com/e184e067fc931d55fce93c9937a26c51.png
"
audio
"
:
""
,
"
text
"
:
""
,
"
right
"
:
false
,
"
letterList
"
:
[
{
"
text
"
:
"
m
"
"
text
"
:
"
g
"
},
{
"
text
"
:
"
o
"
"
text
"
:
"
et
"
},
{
"
text
"
:
"
n
"
"
text
"
:
"
"
},
{
"
text
"
:
"
k
"
"
text
"
:
"
s
"
},
{
"
text
"
:
"
e
"
"
text
"
:
"
tu
"
},
{
"
text
"
:
"
y
"
"
text
"
:
"
ck
"
}
]
},
...
...
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