Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
dg29_museum
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
dg29_museum
Commits
81f5dddc
Commit
81f5dddc
authored
Dec 22, 2023
by
Tt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
基础流程完成
parent
83628316
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
480 additions
and
191 deletions
+480
-191
dg18_tianci.fire
assets/dg18_tianci/scene/dg18_tianci.fire
+327
-132
dg18_tianci.ts
assets/dg18_tianci/scene/dg18_tianci.ts
+73
-8
dg18_tianci_xiaodi.ts
assets/dg18_tianci/scene/dg18_tianci_xiaodi.ts
+80
-51
No files found.
assets/dg18_tianci/scene/dg18_tianci.fire
View file @
81f5dddc
This diff is collapsed.
Click to expand it.
assets/dg18_tianci/scene/dg18_tianci.ts
View file @
81f5dddc
...
@@ -25,15 +25,16 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -25,15 +25,16 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
}
@
property
(
dg_xiaodi
)
xiaodi
:
dg_xiaodi
=
null
;
async
onLoadEnd
()
{
async
onLoadEnd
()
{
// TODO 加载完成后的逻辑写在这里, 下面的代码仅供参考
// TODO 加载完成后的逻辑写在这里, 下面的代码仅供参考
this
.
initData
();
this
.
initData
();
this
.
initView
();
this
.
initView
();
this
.
initEvent
();
this
.
initEvent
();
// pg.view.find(this, 'layout_xiaodi').getComponent(dg_xiaodi)
.playEnter(this.data.npcAudio).then(() => {
this
.
xiaodi
.
playEnter
(
this
.
data
.
npcAudio
).
then
(()
=>
{
//
this.initGame();
this
.
initGame
();
//
})
})
this
.
initGame
();
//
this.initGame();
}
}
_cantouch
=
null
;
_cantouch
=
null
;
...
@@ -63,6 +64,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -63,6 +64,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
@
property
(
cc
.
Node
)
label_tip_wait
:
cc
.
Node
=
null
;
@
property
(
cc
.
Node
)
label_tip_wait
:
cc
.
Node
=
null
;
@
property
(
cc
.
Node
)
label_tip_ing
:
cc
.
Node
=
null
;
@
property
(
cc
.
Node
)
label_tip_ing
:
cc
.
Node
=
null
;
@
property
(
cc
.
Node
)
rich_content
:
cc
.
Node
=
null
;
@
property
(
cc
.
Node
)
rich_content
:
cc
.
Node
=
null
;
@
property
(
cc
.
Node
)
btn_go
:
cc
.
Node
=
null
;
// 初始化页面
// 初始化页面
initView
()
{
initView
()
{
...
@@ -74,17 +76,16 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -74,17 +76,16 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
}
// 事件监听
// 事件监听
initEvent
()
{
initEvent
()
{
pg
.
view
.
touchOn
(
this
.
btn_go
,
this
.
onTouchNext
,
this
);
pg
.
view
.
touchOn
(
this
.
btn_restart
,
this
.
onTouchRestart
,
this
);
pg
.
view
.
touchOn
(
this
.
btn_vioce
,
this
.
onTouchRecord
,
this
);
pg
.
view
.
touchOn
(
this
.
btn_vioce
,
this
.
onTouchRecord
,
this
);
pg
.
view
.
touchOn
(
pg
.
view
.
find
(
this
.
btn_vioce
,
'
img_ing
'
),
this
.
onTouchRecordEnd
,
this
);
pg
.
view
.
touchOn
(
pg
.
view
.
find
(
this
.
btn_vioce
,
'
img_ing
'
),
this
.
onTouchRecordEnd
,
this
);
}
}
// 初始化游戏
// 初始化游戏
initGame
()
{
initGame
()
{
this
.
nextStage
();
this
.
nextStage
();
}
}
//1. 完成录音倒计时等部分代码。
//2. 完成录音结果匹配代码(dg17)
//3. 增加录音结果音频等
//4. 右下角角色的音频播放动作
//4. 右下角角色的音频播放动作
//5. 视频播放
//5. 视频播放
...
@@ -107,6 +108,20 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -107,6 +108,20 @@ export default class SceneComponent extends MyCocosSceneComponent {
this
.
btn_vioce
.
active
=
true
;
this
.
btn_vioce
.
active
=
true
;
pg
.
view
.
visible
(
pg
.
view
.
find
(
this
.
btn_vioce
,
'
img_ing
'
),
false
)
pg
.
view
.
visible
(
pg
.
view
.
find
(
this
.
btn_vioce
,
'
img_ing
'
),
false
)
this
.
label_tip_wait
.
active
=
true
;
this
.
label_tip_wait
.
active
=
true
;
// 展示下一题
this
.
btn_go
.
active
=
true
;
if
(
!
this
.
nextQuestion
)
{
pg
.
view
.
setString
(
pg
.
view
.
find
(
this
.
btn_go
,
'
text
'
),
'
看影像
'
)
}
else
{
pg
.
view
.
setString
(
pg
.
view
.
find
(
this
.
btn_go
,
'
text
'
),
'
下一题
'
)
}
this
.
_cantouch
=
false
;
this
.
xiaodi
.
playQuestionVoice
(
this
.
currentQuestion
.
startAudio
).
then
(()
=>
{
this
.
_cantouch
=
true
;
})
}
}
//按钮触发,使用的方法
//按钮触发,使用的方法
...
@@ -146,6 +161,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -146,6 +161,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
pg
.
view
.
visible
(
pg
.
view
.
find
(
this
.
btn_vioce
,
'
img_ing
'
),
false
)
pg
.
view
.
visible
(
pg
.
view
.
find
(
this
.
btn_vioce
,
'
img_ing
'
),
false
)
}
}
async
onTouchRecord
()
{
async
onTouchRecord
()
{
if
(
!
this
.
_cantouch
)
return
;
if
(
this
.
recording
)
return
;
if
(
this
.
recording
)
return
;
if
(
this
.
recordAudio
)
return
;
if
(
this
.
recordAudio
)
return
;
this
.
recording
=
true
;
this
.
recording
=
true
;
...
@@ -201,7 +217,55 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -201,7 +217,55 @@ export default class SceneComponent extends MyCocosSceneComponent {
this
.
rich_content
.
active
=
true
;
this
.
rich_content
.
active
=
true
;
const
richText
=
this
.
rich_content
.
getComponent
(
cc
.
RichText
);
const
richText
=
this
.
rich_content
.
getComponent
(
cc
.
RichText
);
richText
.
string
=
str
;
richText
.
string
=
str
;
// 处理正确错误
this
.
scheduleOnce
(()
=>
{
if
(
isRight
)
{
this
.
xiaodi
.
playQuestionVoice
(
this
.
currentQuestion
.
rightAudio
).
then
(()
=>
{
this
.
_cantouch
=
true
;
this
.
showNextBtn
();
})
}
else
{
this
.
xiaodi
.
playQuestionVoice
(
this
.
currentQuestion
.
errorAudio
).
then
(()
=>
{
this
.
_cantouch
=
true
;
})
}
},
0.5
)
}
showNextBtn
()
{
}
}
showVideo
()
{
return
new
Promise
(
reslove
=>
{
reslove
(
''
)
})
}
onTouchRestart
()
{
// 处理展示视频内容
this
.
showVideo
().
then
(()
=>
{
// 底部显示为重新查看
this
.
btn_restart
.
active
=
true
;
// 播放小迪结束的动作与gameOver相关内容
this
.
gameOver
();
})
}
onTouchNext
()
{
if
(
this
.
recording
)
return
;
if
(
!
this
.
nextQuestion
)
{
// 处理展示视频内容
this
.
showVideo
().
then
(()
=>
{
// 底部显示为重新查看
this
.
btn_restart
.
active
=
true
;
// 播放小迪结束的动作与gameOver相关内容
this
.
gameOver
();
})
}
else
{
this
.
xiaodi
.
playQuestionVoiceEnd
();
this
.
nextStage
();
}
}
showData
(
data
)
{
showData
(
data
)
{
let
list
=
data
.
result
.
sentences
[
0
].
details
;
let
list
=
data
.
result
.
sentences
[
0
].
details
;
// 列表处理
// 列表处理
...
@@ -253,6 +317,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
...
@@ -253,6 +317,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
pg
.
view
.
find
(
this
,
'
layout_xiaodi
'
).
getComponent
(
dg_xiaodi
).
playOverEnd
()
pg
.
view
.
find
(
this
,
'
layout_xiaodi
'
).
getComponent
(
dg_xiaodi
).
playOverEnd
()
}
}
private
gameOver
()
{
private
gameOver
()
{
// 按钮显示未下一题的显示内容
this
.
showXiaodi
();
this
.
showXiaodi
();
}
}
onTouchExit
()
{
onTouchExit
()
{
...
...
assets/dg18_tianci/scene/dg18_tianci_xiaodi.ts
View file @
81f5dddc
...
@@ -7,50 +7,29 @@ export default class dg_xiaodi extends cc.Component {
...
@@ -7,50 +7,29 @@ export default class dg_xiaodi extends cc.Component {
@
property
(
cc
.
Node
)
@
property
(
cc
.
Node
)
aniRole
:
cc
.
Node
=
null
;
aniRole
:
cc
.
Node
=
null
;
@
property
moveX
:
number
=
500
;
private
defaultX
:
number
;
onLoad
()
{
onLoad
()
{
this
.
defaultX
=
this
.
aniRole
.
x
;
}
}
private
audioIdEnter
:
any
;
private
audioIdEnter
:
any
;
playEnter
(
audioUrl
)
{
playEnter
(
audioUrl
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
this
.
node
.
active
=
true
;
this
.
node
.
active
=
true
;
let
startX
=
this
.
defaultX
+
this
.
moveX
;
let
startX
=
1500
this
.
aniRole
.
x
=
startX
;
this
.
aniRole
.
x
=
startX
;
cc
.
tween
(
this
.
aniRole
)
cc
.
tween
(
this
.
aniRole
)
.
call
(()
=>
{
.
call
(()
=>
{
pg
.
view
.
playDBAnimation
(
this
.
aniRole
,
'
run
'
);
pg
.
view
.
playDBAnimation
(
this
.
aniRole
,
'
run
'
);
if
(
this
.
moveX
<
0
)
{
this
.
aniRole
.
scaleX
=
-
this
.
aniRole
.
scaleX
;
}
})
})
.
to
(
0.5
,
{
x
:
0
})
.
to
(
0.5
,
{
x
:
80
0
})
.
call
(()
=>
{
.
call
(()
=>
{
if
(
this
.
moveX
<
0
)
{
this
.
aniRole
.
scaleX
=
-
this
.
aniRole
.
scaleX
;
}
pg
.
view
.
playDBAnimation
(
this
.
aniRole
,
'
talk
'
);
pg
.
view
.
playDBAnimation
(
this
.
aniRole
,
'
talk
'
);
pg
.
audio
.
playAudioByUrl
(
audioUrl
,
()
=>
{
pg
.
audio
.
playAudioByUrl
(
audioUrl
,
()
=>
{
this
.
audioIdEnter
=
null
;
this
.
audioIdEnter
=
null
;
this
.
scheduleOnce
(()
=>
{
cc
.
tween
(
this
.
aniRole
)
this
.
playEnterEnd
()
.
call
(()
=>
{
resolve
(
''
);
pg
.
view
.
playDBAnimation
(
this
.
aniRole
,
'
run
'
);
},
0.5
)
if
(
this
.
moveX
<
0
)
{
this
.
aniRole
.
scaleX
=
-
this
.
aniRole
.
scaleX
;
}
})
.
to
(
0.5
,
{
x
:
-
1800
})
.
call
(()
=>
{
this
.
scheduleOnce
(()
=>
{
this
.
playEnterEnd
()
resolve
(
''
);
},
0.5
)
})
.
start
();
},
audioId
=>
{
},
audioId
=>
{
this
.
audioIdEnter
=
audioId
;
this
.
audioIdEnter
=
audioId
;
})
})
...
@@ -59,38 +38,88 @@ export default class dg_xiaodi extends cc.Component {
...
@@ -59,38 +38,88 @@ export default class dg_xiaodi extends cc.Component {
});
});
}
}
playEnterEnd
()
{
playEnterEnd
()
{
this
.
node
.
active
=
false
;
// this.node.active = false;
pg
.
view
.
playDBAnimation
(
this
.
aniRole
,
'
normal
'
);
if
(
this
.
audioIdEnter
)
{
if
(
this
.
audioIdEnter
)
{
cc
.
audioEngine
.
stopEffect
(
this
.
audioIdEnter
)
cc
.
audioEngine
.
stopEffect
(
this
.
audioIdEnter
)
}
}
}
}
// private audioIdStart: any;
// playQuestionStart(audioUrl) {
// return new Promise((resolve, reject) => {
// pg.view.playDBAnimation(this.aniRole, 'talk');
// pg.audio.playAudioByUrl(audioUrl, () => {
// this.audioIdStart = null;
// this.scheduleOnce(() => {
// this.playQuestionStartEnd()
// resolve('');
// }, 0.5)
// }, audioId => {
// this.audioIdStart = audioId;
// })
// })
// }
// playQuestionStartEnd() {
// pg.view.playDBAnimation(this.aniRole, 'normal');
// if (this.audioIdStart) {
// cc.audioEngine.stopEffect(this.audioIdStart)
// }
// }
private
audioIdVoice
:
any
;
playQuestionVoice
(
audioUrl
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
pg
.
view
.
playDBAnimation
(
this
.
aniRole
,
'
talk
'
);
pg
.
audio
.
playAudioByUrl
(
audioUrl
,
()
=>
{
this
.
audioIdVoice
=
null
;
this
.
scheduleOnce
(()
=>
{
this
.
playQuestionVoiceEnd
()
resolve
(
''
);
},
0.5
)
},
audioId
=>
{
this
.
audioIdVoice
=
audioId
;
})
})
}
playQuestionVoiceEnd
()
{
pg
.
view
.
playDBAnimation
(
this
.
aniRole
,
'
normal
'
);
if
(
this
.
audioIdVoice
)
{
cc
.
audioEngine
.
stopEffect
(
this
.
audioIdVoice
)
}
}
private
audioIdOver
:
any
;
private
audioIdOver
:
any
;
playOver
(
audioUrl
)
{
playOver
(
audioUrl
)
{
this
.
node
.
active
=
true
;
this
.
node
.
active
=
true
;
let
startX
=
this
.
defaultX
+
this
.
moveX
;
//
let startX = this.defaultX + this.moveX;
this
.
aniRole
.
x
=
startX
;
//
this.aniRole.x = startX;
cc
.
tween
(
this
.
aniRole
)
//
cc.tween(this.aniRole)
.
call
(()
=>
{
//
.call(() => {
pg
.
view
.
playDBAnimation
(
this
.
aniRole
,
'
run
'
);
//
pg.view.playDBAnimation(this.aniRole, 'run');
if
(
this
.
moveX
<
0
)
{
//
if (this.moveX < 0) {
this
.
aniRole
.
scaleX
=
-
this
.
aniRole
.
scaleX
;
//
this.aniRole.scaleX = -this.aniRole.scaleX;
}
//
}
})
//
})
.
to
(
0.3
,
{
x
:
this
.
defaultX
})
//
.to(0.3, { x: this.defaultX })
.
call
(()
=>
{
//
.call(() => {
if
(
this
.
moveX
<
0
)
{
//
if (this.moveX < 0) {
this
.
aniRole
.
scaleX
=
-
this
.
aniRole
.
scaleX
;
//
this.aniRole.scaleX = -this.aniRole.scaleX;
}
//
}
pg
.
view
.
playDBAnimation
(
this
.
aniRole
,
'
talk
'
);
//
pg.view.playDBAnimation(this.aniRole, 'talk');
pg
.
audio
.
playAudioByUrl
(
audioUrl
,
()
=>
{
//
pg.audio.playAudioByUrl(audioUrl, () => {
this
.
audioIdOver
=
null
;
//
this.audioIdOver = null;
pg
.
view
.
playDBAnimation
(
this
.
aniRole
,
'
normal
'
);
//
pg.view.playDBAnimation(this.aniRole, 'normal');
},
audioId
=>
{
//
}, audioId => {
this
.
audioIdOver
=
audioId
;
//
this.audioIdOver = audioId;
})
//
})
})
//
})
.
start
();
//
.start();
}
}
playOverEnd
()
{
playOverEnd
()
{
this
.
node
.
active
=
false
;
this
.
node
.
active
=
false
;
...
...
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