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
977070f6
Commit
977070f6
authored
Jul 01, 2023
by
Tt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
待增加上一题
parent
2c21417e
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
650 additions
and
395 deletions
+650
-395
hy01_danci.fire
assets/hy01_danci/scene/hy01_danci.fire
+512
-347
hy01_danci.ts
assets/hy01_danci/scene/hy01_danci.ts
+59
-10
pg_hy01_danci.ts
assets/hy01_danci/scene/pg_hy01_danci.ts
+41
-0
defaultData_hy01_danci.ts
assets/hy01_danci/script/defaultData_hy01_danci.ts
+38
-38
No files found.
assets/hy01_danci/scene/hy01_danci.fire
View file @
977070f6
This diff is collapsed.
Click to expand it.
assets/hy01_danci/scene/hy01_danci.ts
View file @
977070f6
import
{
asyncDelay
,
onHomeworkFinish
}
from
"
../script/util_hy01_danci
"
;
import
{
asyncDelay
,
onHomeworkFinish
}
from
"
../script/util_hy01_danci
"
;
import
{
MyCocosSceneComponent
}
from
"
../script/MyCocosSceneComponent_hy01_danci
"
;
import
{
MyCocosSceneComponent
}
from
"
../script/MyCocosSceneComponent_hy01_danci
"
;
import
pg
from
"
./pg_hy01_danci
"
;
import
pg
from
"
./pg_hy01_danci
"
;
import
ImgVoice
from
"
../common/script/ImgVoice_hy01_danci
"
;
const
{
ccclass
,
property
}
=
cc
.
_decorator
;
const
{
ccclass
,
property
}
=
cc
.
_decorator
;
...
@@ -43,6 +44,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -43,6 +44,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
private
list
:
Array
<
{
type
,
text
,
right
,
imgage
,
duration
,
content
,
audio
}
>
;
private
list
:
Array
<
{
type
,
text
,
right
,
imgage
,
duration
,
content
,
audio
}
>
;
private
recordFlag
:
boolean
;
//录音模式
private
recordFlag
:
boolean
;
//录音模式
private
score
:
number
;
private
score
:
number
;
private
scoreList
:
Array
<
number
>
;
private
tempScore
:
number
;
private
tempScore
:
number
;
initData
()
{
initData
()
{
// 所有全局变量 默认都是null
// 所有全局变量 默认都是null
...
@@ -52,6 +54,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -52,6 +54,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
this
.
tempScore
=
0
;
this
.
tempScore
=
0
;
this
.
recordFlag
=
data
.
recordFlag
;
this
.
recordFlag
=
data
.
recordFlag
;
this
.
list
=
data
.
questions
[
0
].
options
;
this
.
list
=
data
.
questions
[
0
].
options
;
this
.
scoreList
=
this
.
list
.
map
(()
=>
3
);
this
.
layers
=
[];
this
.
layers
=
[];
}
}
...
@@ -59,12 +62,38 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -59,12 +62,38 @@ export default class SceneComponent extends MyCocosSceneComponent {
private
layer_game
:
cc
.
Node
;
private
layer_game
:
cc
.
Node
;
private
layer_word
:
cc
.
Node
;
private
layer_word
:
cc
.
Node
;
private
layer_word_little
:
cc
.
Node
;
private
layer_word_little
:
cc
.
Node
;
private
layer_touch
:
cc
.
Node
;
private
layers
:
Array
<
cc
.
Node
>
;
private
layers
:
Array
<
cc
.
Node
>
;
initView
()
{
initView
()
{
this
.
layer_record
=
pg
.
view
.
find
(
this
,
'
layer_record
'
)
this
.
layer_record
=
pg
.
view
.
find
(
this
,
'
layer_record
'
)
this
.
layer_game
=
pg
.
view
.
find
(
this
,
'
layer_game
'
)
this
.
layer_game
=
pg
.
view
.
find
(
this
,
'
layer_game
'
)
this
.
layer_word
=
pg
.
view
.
find
(
this
,
'
layer_word
'
)
this
.
layer_word
=
pg
.
view
.
find
(
this
,
'
layer_word
'
)
this
.
layer_word_little
=
pg
.
view
.
find
(
this
,
'
layer_word_little
'
)
this
.
layer_word_little
=
pg
.
view
.
find
(
this
,
'
layer_word_little
'
)
this
.
layer_touch
=
pg
.
view
.
find
(
this
,
'
layer_touch
'
)
pg
.
view
.
touchStartOn
(
this
.
layer_touch
,
this
.
onTouchPanelGameDown
,
this
);
pg
.
view
.
touchEndOn
(
this
.
layer_touch
,
this
.
onTouchPanelGameUp
,
this
);
pg
.
view
.
touchMoveOn
(
this
.
layer_touch
,
this
.
onTouchPanelMove
,
this
);
pg
.
view
.
touchCancelOn
(
this
.
layer_touch
,
this
.
onTouchPanelGameUp
,
this
);
}
onTouchPanelMove
(
e
:
cc
.
Event
.
EventTouch
)
{
let
touchPoint
=
e
.
getLocation
();
let
startPoint
=
e
.
getStartLocation
();
let
move
=
touchPoint
.
clone
().
subtract
(
startPoint
);
console
.
log
(
move
.
toString
());
if
(
Math
.
abs
(
move
.
x
)
>
50
)
{
if
(
move
.
x
<
0
)
{
this
.
lastPage
();
}
else
if
(
move
.
x
>
0
)
{
this
.
nextPage
();
}
}
}
lastPage
()
{
this
.
lastLayer
();
}
nextPage
()
{
this
.
nextLayer
();
}
}
resetView
()
{
resetView
()
{
this
.
layer_game
.
removeAllChildren
();
this
.
layer_game
.
removeAllChildren
();
...
@@ -115,9 +144,11 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -115,9 +144,11 @@ export default class SceneComponent extends MyCocosSceneComponent {
})
})
}
else
{
}
else
{
if
(
this
.
CurrentData
.
type
.
indexOf
(
'
audio
'
)
>
-
1
)
{
if
(
this
.
CurrentData
.
type
.
indexOf
(
'
audio
'
)
>
-
1
)
{
pg
.
event
.
emit
(
'
img_voice_play_voice_start
'
)
let
img_voice
=
pg
.
view
.
find
(
this
.
CurrentLayer
,
'
voice/img_voice
'
);
let
com
=
img_voice
.
getComponent
(
ImgVoice
);
com
.
playVoiceStart
();
pg
.
audio
.
playAudioByUrl
(
this
.
CurrentData
.
audio
,
()
=>
{
pg
.
audio
.
playAudioByUrl
(
this
.
CurrentData
.
audio
,
()
=>
{
pg
.
event
.
emit
(
'
img_voice_play_voice_end
'
)
com
.
playVoiceEnd
();
pg
.
event
.
once
(
'
layer_coin_show_coin_end
'
,
()
=>
{
pg
.
event
.
once
(
'
layer_coin_show_coin_end
'
,
()
=>
{
this
.
nextLayer
();
this
.
nextLayer
();
})
// 动画回调\
})
// 动画回调\
...
@@ -127,13 +158,25 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -127,13 +158,25 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
}
}
}
}
}
addScore
(
num
)
{
if
(
num
>=
3
&&
this
.
scoreList
[
this
.
count
]
>=
3
)
{
this
.
score
+=
3
;
this
.
scoreList
[
this
.
count
]
-=
3
;
}
else
if
(
num
>=
2
&&
this
.
scoreList
[
this
.
count
]
>=
2
)
{
this
.
score
+=
2
;
this
.
scoreList
[
this
.
count
]
-=
2
;
}
else
if
(
num
>=
1
&&
this
.
scoreList
[
this
.
count
]
>=
1
)
{
this
.
score
+=
1
;
this
.
scoreList
[
this
.
count
]
-=
1
;
}
this
.
tempScore
=
0
;
}
onRecorScore
(
score
)
{
onRecorScore
(
score
)
{
if
(
score
<
10
)
{
if
(
score
<
10
)
{
pg
.
event
.
once
(
'
layer_right_show_tryagain_end
'
,
()
=>
{
pg
.
event
.
once
(
'
layer_right_show_tryagain_end
'
,
()
=>
{
this
.
tempScore
+=
1
;
this
.
tempScore
+=
1
;
if
(
this
.
tempScore
==
2
)
{
if
(
this
.
tempScore
==
2
)
{
this
.
score
+=
1
;
this
.
addScore
(
1
);
this
.
tempScore
=
0
;
pg
.
event
.
once
(
'
layer_coin_show_coin_end
'
,
()
=>
{
pg
.
event
.
once
(
'
layer_coin_show_coin_end
'
,
()
=>
{
this
.
nextLayer
();
this
.
nextLayer
();
})
// 动画回调
})
// 动画回调
...
@@ -150,8 +193,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -150,8 +193,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
pg
.
event
.
emit
(
'
layer_right_show_tryagain
'
)
pg
.
event
.
emit
(
'
layer_right_show_tryagain
'
)
}
else
if
(
score
<
60
)
{
}
else
if
(
score
<
60
)
{
pg
.
event
.
once
(
'
layer_right_show_good_end
'
,
()
=>
{
pg
.
event
.
once
(
'
layer_right_show_good_end
'
,
()
=>
{
this
.
score
+=
2
;
this
.
addScore
(
2
);
this
.
tempScore
=
0
;
pg
.
event
.
once
(
'
layer_coin_show_coin_end
'
,
()
=>
{
pg
.
event
.
once
(
'
layer_coin_show_coin_end
'
,
()
=>
{
this
.
nextLayer
();
this
.
nextLayer
();
})
// 动画回调
})
// 动画回调
...
@@ -160,8 +202,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -160,8 +202,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
pg
.
event
.
emit
(
'
layer_right_show_good
'
)
pg
.
event
.
emit
(
'
layer_right_show_good
'
)
}
else
{
}
else
{
pg
.
event
.
once
(
'
layer_right_show_excellent_end
'
,
()
=>
{
pg
.
event
.
once
(
'
layer_right_show_excellent_end
'
,
()
=>
{
this
.
score
+=
3
this
.
addScore
(
3
);
this
.
tempScore
=
0
;
pg
.
event
.
once
(
'
layer_coin_show_coin_end
'
,
()
=>
{
pg
.
event
.
once
(
'
layer_coin_show_coin_end
'
,
()
=>
{
this
.
nextLayer
();
this
.
nextLayer
();
})
// 动画回调
})
// 动画回调
...
@@ -169,6 +210,12 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -169,6 +210,12 @@ export default class SceneComponent extends MyCocosSceneComponent {
})
})
pg
.
event
.
emit
(
'
layer_right_show_excellent
'
)
pg
.
event
.
emit
(
'
layer_right_show_excellent
'
)
}
}
}
lastLayer
()
{
// 积分需要计算,未获取的内容
this
.
count
--
;
}
}
nextLayer
()
{
nextLayer
()
{
if
(
!
this
.
NextData
)
{
if
(
!
this
.
NextData
)
{
...
@@ -251,9 +298,11 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -251,9 +298,11 @@ export default class SceneComponent extends MyCocosSceneComponent {
onTouchVoice
(
e
)
{
onTouchVoice
(
e
)
{
let
layer
=
e
.
target
.
parent
;
let
layer
=
e
.
target
.
parent
;
if
(
layer
===
this
.
CurrentLayer
)
{
if
(
layer
===
this
.
CurrentLayer
)
{
pg
.
event
.
emit
(
'
img_voice_play_voice_start
'
)
let
img_voice
=
pg
.
view
.
find
(
this
.
CurrentLayer
,
'
voice/img_voice
'
);
let
com
=
img_voice
.
getComponent
(
ImgVoice
);
com
.
playVoiceStart
();
pg
.
audio
.
playAudioByUrl
(
this
.
CurrentData
.
audio
,
()
=>
{
pg
.
audio
.
playAudioByUrl
(
this
.
CurrentData
.
audio
,
()
=>
{
pg
.
event
.
emit
(
'
img_voice_play_voice_end
'
)
com
.
playVoiceEnd
();
})
})
}
}
}
}
...
...
assets/hy01_danci/scene/pg_hy01_danci.ts
View file @
977070f6
...
@@ -150,6 +150,47 @@ let pg = {
...
@@ -150,6 +150,47 @@ let pg = {
}
}
},
},
view
:
{
view
:
{
touchTypeOn
(
type
,
item
,
callback
,
target
)
{
if
(
!
item
)
return
pg
.
logger
.
w
(
"
添加按钮响应失败,传入了错误的item
"
);
if
(
!
callback
||
!
target
)
return
pg
.
logger
.
w
(
"
添加按钮响应失败,传入了空回调
"
);
let
node
=
item
.
node
?
item
.
node
:
item
;
node
.
on
(
type
,
callback
,
target
);
return
true
;
},
//移除监听
touchTypeOff
(
type
,
item
,
callback
,
target
)
{
if
(
!
item
)
return
pg
.
logger
.
w
(
"
移除按钮响应失败,传入了错误的item
"
);
if
(
!
callback
||
!
target
)
return
pg
.
logger
.
w
(
"
移除按钮响应失败,传入了空回调
"
);
let
node
=
item
.
node
?
item
.
node
:
item
;
if
(
!
node
||
!
node
.
parent
)
return
pg
.
logger
.
w
(
"
节点已移除
"
);
node
.
off
(
type
,
callback
,
target
);
return
true
;
},
touchStartOn
(
item
,
callback
,
target
)
{
return
this
.
touchTypeOn
(
cc
.
Node
.
EventType
.
TOUCH_START
,
item
,
callback
,
target
)
},
touchMoveOn
(
item
,
callback
,
target
)
{
return
this
.
touchTypeOn
(
cc
.
Node
.
EventType
.
TOUCH_MOVE
,
item
,
callback
,
target
)
},
touchEndOn
(
item
,
callback
,
target
)
{
return
this
.
touchTypeOn
(
cc
.
Node
.
EventType
.
TOUCH_END
,
item
,
callback
,
target
)
},
touchCancelOn
(
item
,
callback
,
target
)
{
return
this
.
touchTypeOn
(
cc
.
Node
.
EventType
.
TOUCH_CANCEL
,
item
,
callback
,
target
)
},
touchStartOff
(
item
,
callback
,
target
)
{
return
this
.
touchTypeOff
(
cc
.
Node
.
EventType
.
TOUCH_START
,
item
,
callback
,
target
)
},
touchMoveOff
(
item
,
callback
,
target
)
{
return
this
.
touchTypeOff
(
cc
.
Node
.
EventType
.
TOUCH_MOVE
,
item
,
callback
,
target
)
},
touchEndOff
(
item
,
callback
,
target
)
{
return
this
.
touchTypeOff
(
cc
.
Node
.
EventType
.
TOUCH_END
,
item
,
callback
,
target
)
},
touchCancelOff
(
item
,
callback
,
target
)
{
return
this
.
touchTypeOff
(
cc
.
Node
.
EventType
.
TOUCH_CANCEL
,
item
,
callback
,
target
)
},
//---------------------节点管理------------------------------
//---------------------节点管理------------------------------
//创建节点
//创建节点
createNode
()
{
createNode
()
{
...
...
assets/hy01_danci/script/defaultData_hy01_danci.ts
View file @
977070f6
export
const
defaultData
=
export
const
defaultData
=
{
"
recordFlag
"
:
true
,
"
title
"
:
""
,
"
questionText
"
:
""
,
"
questionTextAudio
"
:
""
,
"
questions
"
:
[
{
"
questionAudio
"
:
""
,
"
duration
"
:
120
,
"
options
"
:
[{
"
type
"
:
"
img
"
,
"
image
"
:
"
http://staging-teach.cdn.ireadabc.com/09670073e1cbb685cf03e29958133c99.png
"
,
"
audio
"
:
""
,
"
text
"
:
""
,
"
duration
"
:
100
,
"
content
"
:
"
ceshi
"
,
"
right
"
:
false
},
{
"
type
"
:
"
img_txt
"
,
"
image
"
:
"
http://staging-teach.cdn.ireadabc.com/b0b3c59954a6b8610182ef1fc5ba90c5.png
"
,
"
audio
"
:
""
,
"
text
"
:
"
test
"
,
"
duration
"
:
10
,
"
content
"
:
"
test
"
,
"
right
"
:
false
}]
}],
"
bgAudio
"
:
""
,
"
bgAudioName
"
:
""
,
"
audioName
"
:
""
,
"
npcTitle
"
:
"
123
"
,
"
npcAudio
"
:
"
http://staging-teach.cdn.ireadabc.com/f96fcb73dc6b3dcf2ce71fe2ba76e4c3_l.mp3
"
,
"
npcAudioName
"
:
"
选项正确.mp3
"
}
// {
// {
// "recordFlag": true,
// "recordFlag": true,
// "title": "test",
// "title": "",
// "audio_url": '',
// npcTitle: "I show info",
// npcAudio: "http://staging-teach.cdn.ireadabc.com/43839adb578c7e01456748b8a176a0c3_l.mp3",
// "questionText": "",
// "questionText": "",
// "questionTextAudio": "",
// "questionTextAudio": "",
// "questions": [
// "questions": [
// {
// {
// "questionAudio": "",
// "questionAudio": "", "duration": 120,
// "duration": 120,
// "options": [{
// "options": [
// "type": "img",
// {
// "image": "http://staging-teach.cdn.ireadabc.com/09670073e1cbb685cf03e29958133c99.png", "audio": "", "text": "",
// "type": "img_audio",
// "duration": 100, "content": "ceshi", "right": false
// "image": "http://staging-teach.cdn.ireadabc.com/875862129c75a075b3d710f541258a00.png",
// }, { "type": "img_txt", "image": "http://staging-teach.cdn.ireadabc.com/b0b3c59954a6b8610182ef1fc5ba90c5.png", "audio": "", "text": "test", "duration": 10, "content": "test", "right": false }]
// "audio": "http://staging-teach.cdn.ireadabc.com/43839adb578c7e01456748b8a176a0c3_l.mp3",
// }], "bgAudio": "", "bgAudioName": "", "audioName": "", "npcTitle": "123", "npcAudio": "http://staging-teach.cdn.ireadabc.com/f96fcb73dc6b3dcf2ce71fe2ba76e4c3_l.mp3", "npcAudioName": "选项正确.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
"
:
false
,
"
title
"
:
"
test
"
,
"
audio_url
"
:
''
,
npcTitle
:
"
I show info
"
,
npcAudio
:
"
http://staging-teach.cdn.ireadabc.com/43839adb578c7e01456748b8a176a0c3_l.mp3
"
,
"
questionText
"
:
""
,
"
questionTextAudio
"
:
""
,
"
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
"
:
""
}
...
...
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