Commit 216ff7e4 authored by 李维's avatar 李维

dev commit

parent 6cce8f37
......@@ -149,6 +149,7 @@ export class PlayComponent implements OnInit, OnDestroy {
{x: 450}
]
m_currentQuestion = 0;
m_bgMusic = null
// ------------------------------------
......@@ -235,6 +236,10 @@ export class PlayComponent implements OnInit, OnDestroy {
startGame(){
this.loadQuestion()
this.g_cartoon.playAudio("bg_music", false ,null, true, (audio)=>{
this.m_bgMusic = audio
audio.volume = 0.05
})
this.g_cartoon.getCartoonElement(`question-index-board`).resetIndex()
this.g_cartoon.getCartoonElement("play-audio").in()
this.g_cartoon.getCartoonElement("skier").ready(()=>{
......@@ -249,7 +254,10 @@ export class PlayComponent implements OnInit, OnDestroy {
endGame(){
this.showEndPatal()
this.g_cartoon.playAudio("win")
this.muteBgMusic(true)
this.g_cartoon.playAudio("win", false, ()=>{
this.muteBgMusic(false)
})
this.m_setTimeoutIDs.push(setTimeout(() => {
this.stopEndPatal()
}, 3000))
......@@ -265,6 +273,14 @@ export class PlayComponent implements OnInit, OnDestroy {
})
}
muteBgMusic(status){
if(status){
this.m_bgMusic.volume = 0
}else{
this.m_bgMusic.volume = 0.05
}
}
initBackground(){
let element = this.g_cartoon.createCartoonElementImage("background-main", "background", this.g_canvasWidth, this.g_canvasHeight, this.g_canvasWidth/2, this.g_canvasHeight/2)
......@@ -489,8 +505,13 @@ export class PlayComponent implements OnInit, OnDestroy {
if(!this.g_formData.dataArray[this.m_currentQuestion].audio_url){
return
}
this.g_cartoon.stopAllAudio()
this.g_cartoon.playAudio(this.g_formData.dataArray[this.m_currentQuestion].audio_url, false, ()=>{
element.stop()
this.muteBgMusic(false)
this.g_cartoon.playAudio("bg_music", false ,null, true, (audio)=>{
this.m_bgMusic = audio
audio.volume = 0.05
})
})
element.playIntervalID = setInterval(()=>{
for(let i=0; i<3; i++){
......@@ -758,12 +779,7 @@ export class PlayComponent implements OnInit, OnDestroy {
element.firstClick = true
element.cruise = (callback?)=>{
header.ref.visible = true;
tweenChange(header.ref, {
x: header.initX,
y: header.initY,
scaleX: header.initScaleX,
scaleY: header.initScaleY
}, 0.8, ()=>{
if(element.firstClick){
element.cruiseSetTimeoutID = setTimeout(() => {
let dir = false;
......@@ -783,7 +799,20 @@ export class PlayComponent implements OnInit, OnDestroy {
}, 500)
this.m_setTimeoutIDs.push(element.cruiseSetTimeoutID)
}
this.m_setTimeoutIDs.push(setTimeout(() => {
tweenChange(header.ref, {
x: header.initX,
y: header.initY,
scaleX: header.initScaleX,
scaleY: header.initScaleY
}, 0.8, ()=>{
this.m_setTimeoutIDs.push(setTimeout(() => {
header.ref.visible = false
}, 4000))
})
}, 500))
}
element.stopCruise = ()=>{
......@@ -848,6 +877,7 @@ export class PlayComponent implements OnInit, OnDestroy {
let disX = element.ref.x - this.g_clickX
let disY = element.ref.y - this.g_clickY
this.g_cartoon.playAudio("skier", false, null, true)
this.muteBgMusic(true)
this.enableMoveAsstant(()=>{
element.ref.x = this.g_clickX + disX;
element.ref.y = this.g_clickY + disY;
......@@ -861,15 +891,14 @@ export class PlayComponent implements OnInit, OnDestroy {
element.enableDrag = false;
element.targetRunWay = this.calcRunWayIndex(element.ref.x, element.ref.y)
this.g_cartoon.stopAudio("skier")
this.muteBgMusic(false)
element.go(element.targetRunWay, ()=>{
if(this.gameControl(element.targetRunWay)){
this.g_cartoon.playAudio("sm-choice-correct")
element.goAhead(()=>{
this.nextQuestion(()=>{
this.loadQuestion()
element.ready(()=>{
// this.g_cartoon.getCartoonElement("play-audio").play()
})
element.ready()
})
})
}else{
......@@ -950,18 +979,10 @@ export class PlayComponent implements OnInit, OnDestroy {
this.endGame()
}else{
this.m_currentQuestion++
// this.g_cartoon.getCartoonElement("mask-layer").in(()=>{
// this.showMMilestoneBoardTotal(this.m_currentQuestion, ()=>{
// this.g_cartoon.getCartoonElement("mask-layer").out(()=>{
// callback && callback()
// })
// })
// })
for(let index=0; index<4; index++){
this.g_cartoon.getCartoonElement(`question-card-${index}`).ref.visible = false;
}
this.showEndPatal()
// this.g_cartoon.playAudio("win")
this.m_setTimeoutIDs.push(setTimeout(() => {
this.stopEndPatal()
callback && callback()
......
......@@ -70,6 +70,7 @@ const localAudios = {
'sm-choice-error': 'assets/default/audio/sm-choice-error.mp3',
'skier': 'assets/audio/skier.mp3',
'win': 'assets/audio/win.mp3',
"bg_music": "assets/audio/bg_music.mp3"
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment