Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
H
hy01_danci
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
hy01_danci
Commits
2f1813c5
Commit
2f1813c5
authored
Jun 14, 2023
by
Tt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
游戏完成
parent
bddc2368
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
2184 additions
and
300 deletions
+2184
-300
LayerRecord.ts
assets/hy01_danci/common/script/LayerRecord.ts
+1
-1
hy01_danci.fire
assets/hy01_danci/scene/hy01_danci.fire
+1990
-272
hy01_danci.ts
assets/hy01_danci/scene/hy01_danci.ts
+159
-18
pg.ts
assets/hy01_danci/scene/pg.ts
+5
-3
defaultData.ts
assets/hy01_danci/script/defaultData.ts
+29
-6
No files found.
assets/hy01_danci/common/script/LayerRecord.ts
View file @
2f1813c5
...
@@ -104,6 +104,6 @@ export default class LayerRecord extends cc.Component {
...
@@ -104,6 +104,6 @@ export default class LayerRecord extends cc.Component {
}
}
async
recrodEnd
(
data
)
{
async
recrodEnd
(
data
)
{
let
score
=
data
.
result
.
overall
;
let
score
=
data
.
result
.
overall
;
pg
.
event
.
on
(
'
layer_record_score
'
,
score
);
pg
.
event
.
emit
(
'
layer_record_score
'
,
score
);
}
}
}
}
assets/hy01_danci/scene/hy01_danci.fire
View file @
2f1813c5
This diff is collapsed.
Click to expand it.
assets/hy01_danci/scene/hy01_danci.ts
View file @
2f1813c5
...
@@ -27,39 +27,180 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -27,39 +27,180 @@ export default class SceneComponent extends MyCocosSceneComponent {
this
.
initData
();
this
.
initData
();
this
.
initView
();
this
.
initView
();
this
.
initListener
();
this
.
initListener
();
this
.
initGame
();
}
}
_cantouch
=
null
;
_cantouch
=
null
;
private
list
:
Array
<
{
type
,
text
,
right
,
imgage
,
duration
,
content
,
audio
}
>
;
private
recordFlag
:
boolean
;
//录音模式
initData
()
{
initData
()
{
// 所有全局变量 默认都是null
// 所有全局变量 默认都是null
this
.
_cantouch
=
true
;
this
.
_cantouch
=
true
;
let
data
=
this
.
data
;
this
.
recordFlag
=
data
.
recordFlag
;
this
.
list
=
data
.
questions
[
0
].
options
;
this
.
layers
=
[];
}
}
private
layer_record
:
cc
.
Node
;
private
layer_game
:
cc
.
Node
;
private
layer_word
:
cc
.
Node
;
private
layer_word_little
:
cc
.
Node
;
private
layers
:
Array
<
cc
.
Node
>
;
initView
()
{
initView
()
{
// pg.event.on('layer_right_show_excellent_end', () => {
this
.
layer_record
=
pg
.
view
.
find
(
this
,
'
layer_record
'
)
// alert('test')
this
.
layer_game
=
pg
.
view
.
find
(
this
,
'
layer_game
'
)
// })
this
.
layer_word
=
pg
.
view
.
find
(
this
,
'
layer_word
'
)
// pg.event.emit('layer_right_show_excellent')
this
.
layer_word_little
=
pg
.
view
.
find
(
this
,
'
layer_word_little
'
)
// pg.event.on('layer_right_show_good_end', () => {
// alert('test')
// })
// pg.event.emit('layer_right_show_good')
// pg.event.on('layer_right_show_tryagain_end', () => {
// alert('test')
// })
// pg.event.emit('layer_right_show_tryagain')
// pg.event.emit('img_voice_play_voice_start')
// setTimeout(() => {
// pg.event.emit('img_voice_play_voice_end')
// }, 2000)
}
}
initListener
()
{
initListener
()
{
pg
.
event
.
on
(
'
layer_record_score
'
,
(
score
)
=>
{
this
.
onRecorScore
(
score
);
})
}
private
get
CurrentData
()
{
return
this
.
list
[
this
.
count
]
}
private
get
NextData
()
{
return
this
.
list
[
this
.
count
+
1
]
}
private
get
OutData
()
{
return
this
.
list
[
this
.
count
+
2
]
}
private
get
CurrentLayer
()
{
return
this
.
layers
[
0
]
}
private
get
LittleLayer
()
{
return
this
.
layers
[
1
]
}
private
get
OutLayer
()
{
return
this
.
layers
[
2
]
}
private
count
:
number
;
initGame
()
{
this
.
count
=
0
;
let
currentLayer
=
this
.
createLayer
();
this
.
updateLayer
(
currentLayer
,
this
.
CurrentData
)
this
.
layers
.
push
(
currentLayer
)
let
nextLayer
=
this
.
createLittleLayer
();
this
.
updateLayer
(
nextLayer
,
this
.
NextData
)
this
.
layers
.
push
(
nextLayer
)
this
.
startPlay
();
}
startPlay
()
{
if
(
this
.
recordFlag
)
{
this
.
layer_record
.
active
=
true
;
}
else
{
if
(
this
.
CurrentData
.
type
.
indexOf
(
'
audio
'
)
>
-
1
)
{
pg
.
event
.
emit
(
'
img_voice_play_voice_start
'
)
pg
.
audio
.
playAudioByUrl
(
this
.
CurrentData
.
audio
,
()
=>
{
pg
.
event
.
emit
(
'
img_voice_play_voice_end
'
)
this
.
nextLayer
();
})
}
}
}
onRecorScore
(
score
)
{
if
(
score
<
10
)
{
pg
.
event
.
on
(
'
layer_right_show_tryagain_end
'
,
()
=>
{
// alert('test')
})
pg
.
event
.
emit
(
'
layer_right_show_tryagain
'
)
}
else
if
(
score
<
60
)
{
pg
.
event
.
on
(
'
layer_right_show_good_end
'
,
()
=>
{
this
.
nextLayer
();
})
pg
.
event
.
emit
(
'
layer_right_show_good
'
)
}
else
{
pg
.
event
.
on
(
'
layer_right_show_excellent_end
'
,
()
=>
{
this
.
nextLayer
();
})
pg
.
event
.
emit
(
'
layer_right_show_excellent
'
)
}
}
nextLayer
()
{
if
(
!
this
.
NextData
)
{
this
.
gameOver
();
return
;
}
if
(
this
.
OutData
)
{
let
outLayer
=
this
.
createLittleLayer
();
this
.
updateLayer
(
outLayer
,
this
.
OutData
)
outLayer
.
x
=
-
1500
;
this
.
layers
.
push
(
outLayer
)
}
cc
.
tween
(
this
.
CurrentLayer
).
to
(
3
,
{
x
:
2000
}).
start
();
if
(
this
.
LittleLayer
)
{
cc
.
tween
(
this
.
LittleLayer
).
to
(
3
,
{
x
:
0
,
y
:
0
,
scale
:
1
}).
start
();
}
if
(
this
.
OutLayer
)
{
cc
.
tween
(
this
.
OutLayer
).
to
(
3
,
{
x
:
this
.
layer_word_little
.
x
,
y
:
this
.
layer_word_little
.
y
}).
start
();
}
this
.
scheduleOnce
(()
=>
{
this
.
count
++
;
this
.
layers
.
shift
();
this
.
startPlay
();
},
3
)
}
gameOver
()
{
}
}
createLayer
()
{
let
layer
=
pg
.
view
.
clone
(
this
.
layer_word
);
layer
.
active
=
true
;
this
.
layer_game
.
addChild
(
layer
)
return
layer
;
}
createLittleLayer
()
{
let
layer
=
pg
.
view
.
clone
(
this
.
layer_word
);
layer
.
active
=
true
;
layer
.
x
=
this
.
layer_word_little
.
x
;
layer
.
y
=
this
.
layer_word_little
.
y
;
layer
.
scale
=
this
.
layer_word_little
.
scale
;
this
.
layer_game
.
addChild
(
layer
)
return
layer
;
}
updateLayer
(
layer
,
data
)
{
let
bg
=
pg
.
view
.
find
(
layer
,
'
bg
'
);
let
c1
=
pg
.
view
.
find
(
bg
,
'
c1
'
);
let
c2
=
pg
.
view
.
find
(
bg
,
'
c2
'
);
let
c3
=
pg
.
view
.
find
(
bg
,
'
c3
'
);
let
c4
=
pg
.
view
.
find
(
bg
,
'
c4
'
);
let
img
=
pg
.
view
.
find
(
layer
,
'
img
'
);
let
label
=
pg
.
view
.
find
(
layer
,
'
label
'
);
let
voice
=
pg
.
view
.
find
(
layer
,
'
voice
'
);
// 根据数据来渲染
img
.
active
=
true
;
pg
.
view
.
setNetImg
(
img
,
data
.
image
,
{
w
:
600
,
h
:
370
})
label
.
active
=
data
.
type
==
'
img_txt
'
||
data
.
type
==
'
img_txt_audio
'
pg
.
view
.
setString
(
label
,
data
.
text
);
voice
.
active
=
data
.
type
==
'
img_audio
'
||
data
.
type
==
'
img_txt_audio
'
pg
.
view
.
touchOn
(
voice
,
this
.
onTouchVoice
,
this
);
if
(
this
.
recordFlag
)
{
c1
.
active
=
false
;
c2
.
active
=
false
;
c3
.
active
=
false
;
c4
.
active
=
false
;
}
}
onTouchVoice
(
e
)
{
let
layer
=
e
.
target
.
parent
;
if
(
layer
===
this
.
CurrentLayer
)
{
pg
.
event
.
emit
(
'
img_voice_play_voice_start
'
)
pg
.
audio
.
playAudioByUrl
(
this
.
CurrentData
.
audio
,
()
=>
{
pg
.
event
.
emit
(
'
img_voice_play_voice_end
'
)
})
}
}
playLocalAudio
(
audioName
)
{
playLocalAudio
(
audioName
)
{
const
audio
=
cc
.
find
(
`Canvas/res/audio/
${
audioName
}
`
).
getComponent
(
cc
.
AudioSource
);
const
audio
=
cc
.
find
(
`Canvas/res/audio/
${
audioName
}
`
).
getComponent
(
cc
.
AudioSource
);
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
...
...
assets/hy01_danci/scene/pg.ts
View file @
2f1813c5
...
@@ -291,9 +291,9 @@ let pg = {
...
@@ -291,9 +291,9 @@ let pg = {
if
(
w
&&
h
&&
custom
)
{
if
(
w
&&
h
&&
custom
)
{
let
scaleX
=
w
/
nw
;
let
scaleX
=
w
/
nw
;
let
scaleY
=
h
/
nh
;
let
scaleY
=
h
/
nh
;
//
let scale = scaleX <= scaleY ? scaleX : scaleY;
let
scale
=
scaleX
<=
scaleY
?
scaleX
:
scaleY
;
node
.
width
=
nw
*
scale
X
;
node
.
width
=
nw
*
scale
;
node
.
height
=
nh
*
scale
Y
;
node
.
height
=
nh
*
scale
;
}
}
node
.
active
=
nodeActive
;
node
.
active
=
nodeActive
;
resolve
({
w
:
nw
,
h
:
nh
});
resolve
({
w
:
nw
,
h
:
nh
});
...
@@ -570,7 +570,9 @@ let pg = {
...
@@ -570,7 +570,9 @@ let pg = {
playAudioByUrl
(
audio_url
,
cb
=
null
,
loadCb
=
null
)
{
playAudioByUrl
(
audio_url
,
cb
=
null
,
loadCb
=
null
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
if
(
!
audio_url
)
return
resolve
(
null
);
if
(
!
audio_url
)
return
resolve
(
null
);
cc
.
assetManager
.
loadRemote
(
audio_url
,
(
err
,
audioClip
:
any
)
=>
{
cc
.
assetManager
.
loadRemote
(
audio_url
,
(
err
,
audioClip
:
any
)
=>
{
cc
.
audioEngine
.
stopAll
();
const
audioId
=
cc
.
audioEngine
.
play
(
audioClip
,
false
,
0.8
);
const
audioId
=
cc
.
audioEngine
.
play
(
audioClip
,
false
,
0.8
);
cc
.
audioEngine
.
setFinishCallback
(
audioId
,
()
=>
{
cc
.
audioEngine
.
setFinishCallback
(
audioId
,
()
=>
{
cb
&&
cb
();
cb
&&
cb
();
...
...
assets/hy01_danci/script/defaultData.ts
View file @
2f1813c5
export
const
defaultData
=
{
export
const
defaultData
=
"
pic_url
"
:
"
http://staging-teach.cdn.ireadabc.com/ed94332a503c31e0908bd4c6923a2665.png
"
,
{
"
pic_url_2
"
:
"
http://staging-teach.cdn.ireadabc.com/5fb60317ade0195d35ad8034d5370a7f.png
"
,
"
recordFlag
"
:
true
,
"
text
"
:
"
This is a test label.
"
,
"
title
"
:
"
test
"
,
"
audio_url
"
:
"
http://staging-teach.cdn.ireadabc.com/f47f1d7b5c160fe1c59500d180346240.mp3
"
"
questionText
"
:
""
,
}
"
questionTextAudio
"
:
""
,
\ No newline at end of file
"
questions
"
:
[
{
"
questionAudio
"
:
""
,
"
duration
"
:
120
,
"
options
"
:
[
{
"
type
"
:
"
img_audio
"
,
"
image
"
:
"
http://staging-teach.cdn.ireadabc.com/875862129c75a075b3d710f541258a00.png
"
,
"
audio
"
:
"
http://staging-teach.cdn.ireadabc.com/43839adb578c7e01456748b8a176a0c3_l.mp3
"
,
"
text
"
:
""
,
"
duration
"
:
10
,
"
content
"
:
"
egg
"
,
"
right
"
:
false
},
{
"
type
"
:
"
img_txt_audio
"
,
"
image
"
:
"
http://staging-teach.cdn.ireadabc.com/011cf423d6fd8760e810644ca6070e34.png
"
,
"
audio
"
:
"
http://staging-teach.cdn.ireadabc.com/43839adb578c7e01456748b8a176a0c3_l.mp3
"
,
"
text
"
:
"
hammer
"
,
"
duration
"
:
10
,
"
content
"
:
"
hammer
"
,
"
right
"
:
false
},
{
"
type
"
:
"
img_txt_audio
"
,
"
image
"
:
"
http://staging-teach.cdn.ireadabc.com/befdc1801d93fd95b3a8ee7c7a2d2d05.png
"
,
"
audio
"
:
"
http://staging-teach.cdn.ireadabc.com/43839adb578c7e01456748b8a176a0c3_l.mp3
"
,
"
text
"
:
"
clound
"
,
"
duration
"
:
10
,
"
content
"
:
"
clound
"
,
"
right
"
:
false
,
"
audioName
"
:
"
敲碎蛋的声音.mp3
"
}]
}],
"
bgAudio
"
:
""
,
"
bgAudioName
"
:
""
,
"
audioName
"
:
""
}
// {
// "recordFlag": true,
// "title": "test",
// "questionText": "",
// "questionTextAudio": "",
// "questions": [
// {
// "questionAudio": "", "duration": 120,
// "options": [
// { "type": "img", "image": "http://staging-teach.cdn.ireadabc.com/875862129c75a075b3d710f541258a00.png", "audio": "", "text": "", "duration": 10, "content": "egg", "right": false },
// { "type": "img_txt", "image": "http://staging-teach.cdn.ireadabc.com/011cf423d6fd8760e810644ca6070e34.png", "audio": "", "text": "hammer", "duration": 10, "content": "hammer", "right": false },
// { "type": "img_txt_audio", "image": "http://staging-teach.cdn.ireadabc.com/befdc1801d93fd95b3a8ee7c7a2d2d05.png", "audio": "http://staging-teach.cdn.ireadabc.com/43839adb578c7e01456748b8a176a0c3_l.mp3", "text": "clound", "duration": 10, "content": "clound", "right": false, "audioName": "敲碎蛋的声音.mp3" }]
// }], "bgAudio": "", "bgAudioName": "", "audioName": ""
// }
\ No newline at end of file
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