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

dev commit

parent 6cce8f37
...@@ -149,6 +149,7 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -149,6 +149,7 @@ export class PlayComponent implements OnInit, OnDestroy {
{x: 450} {x: 450}
] ]
m_currentQuestion = 0; m_currentQuestion = 0;
m_bgMusic = null
// ------------------------------------ // ------------------------------------
...@@ -235,6 +236,10 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -235,6 +236,10 @@ export class PlayComponent implements OnInit, OnDestroy {
startGame(){ startGame(){
this.loadQuestion() 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(`question-index-board`).resetIndex()
this.g_cartoon.getCartoonElement("play-audio").in() this.g_cartoon.getCartoonElement("play-audio").in()
this.g_cartoon.getCartoonElement("skier").ready(()=>{ this.g_cartoon.getCartoonElement("skier").ready(()=>{
...@@ -249,7 +254,10 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -249,7 +254,10 @@ export class PlayComponent implements OnInit, OnDestroy {
endGame(){ endGame(){
this.showEndPatal() 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.m_setTimeoutIDs.push(setTimeout(() => {
this.stopEndPatal() this.stopEndPatal()
}, 3000)) }, 3000))
...@@ -265,6 +273,14 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -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(){ initBackground(){
let element = this.g_cartoon.createCartoonElementImage("background-main", "background", this.g_canvasWidth, this.g_canvasHeight, this.g_canvasWidth/2, this.g_canvasHeight/2) 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 { ...@@ -489,8 +505,13 @@ export class PlayComponent implements OnInit, OnDestroy {
if(!this.g_formData.dataArray[this.m_currentQuestion].audio_url){ if(!this.g_formData.dataArray[this.m_currentQuestion].audio_url){
return return
} }
this.g_cartoon.stopAllAudio()
this.g_cartoon.playAudio(this.g_formData.dataArray[this.m_currentQuestion].audio_url, false, ()=>{ 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(()=>{ element.playIntervalID = setInterval(()=>{
for(let i=0; i<3; i++){ for(let i=0; i<3; i++){
...@@ -758,32 +779,40 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -758,32 +779,40 @@ export class PlayComponent implements OnInit, OnDestroy {
element.firstClick = true element.firstClick = true
element.cruise = (callback?)=>{ element.cruise = (callback?)=>{
header.ref.visible = true; header.ref.visible = true;
tweenChange(header.ref, {
x: header.initX, if(element.firstClick){
y: header.initY, element.cruiseSetTimeoutID = setTimeout(() => {
scaleX: header.initScaleX, let dir = false;
scaleY: header.initScaleY let step = 10 * this.g_mapScale
}, 0.8, ()=>{ element.cruiseIntervalID = setInterval(()=>{
if(element.firstClick){ if(dir){
element.cruiseSetTimeoutID = setTimeout(() => { element.ref.x += step
let dir = false; }else{
let step = 10 * this.g_mapScale element.ref.x -= step
element.cruiseIntervalID = setInterval(()=>{ }
if(dir){ if(element.ref.x>this.g_canvasWidth-300*this.g_mapScale || element.ref.x<300*this.g_mapScale){
element.ref.x += step dir = !dir
}else{ }
element.ref.x -= step }, 30)
} this.m_setIntervalIDs.push(element.cruiseIntervalID)
if(element.ref.x>this.g_canvasWidth-300*this.g_mapScale || element.ref.x<300*this.g_mapScale){ callback && callback()
dir = !dir }, 500)
} this.m_setTimeoutIDs.push(element.cruiseSetTimeoutID)
}, 30) }
this.m_setIntervalIDs.push(element.cruiseIntervalID)
callback && callback() this.m_setTimeoutIDs.push(setTimeout(() => {
}, 500) tweenChange(header.ref, {
this.m_setTimeoutIDs.push(element.cruiseSetTimeoutID) 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 = ()=>{ element.stopCruise = ()=>{
...@@ -848,6 +877,7 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -848,6 +877,7 @@ export class PlayComponent implements OnInit, OnDestroy {
let disX = element.ref.x - this.g_clickX let disX = element.ref.x - this.g_clickX
let disY = element.ref.y - this.g_clickY let disY = element.ref.y - this.g_clickY
this.g_cartoon.playAudio("skier", false, null, true) this.g_cartoon.playAudio("skier", false, null, true)
this.muteBgMusic(true)
this.enableMoveAsstant(()=>{ this.enableMoveAsstant(()=>{
element.ref.x = this.g_clickX + disX; element.ref.x = this.g_clickX + disX;
element.ref.y = this.g_clickY + disY; element.ref.y = this.g_clickY + disY;
...@@ -861,15 +891,14 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -861,15 +891,14 @@ export class PlayComponent implements OnInit, OnDestroy {
element.enableDrag = false; element.enableDrag = false;
element.targetRunWay = this.calcRunWayIndex(element.ref.x, element.ref.y) element.targetRunWay = this.calcRunWayIndex(element.ref.x, element.ref.y)
this.g_cartoon.stopAudio("skier") this.g_cartoon.stopAudio("skier")
this.muteBgMusic(false)
element.go(element.targetRunWay, ()=>{ element.go(element.targetRunWay, ()=>{
if(this.gameControl(element.targetRunWay)){ if(this.gameControl(element.targetRunWay)){
this.g_cartoon.playAudio("sm-choice-correct") this.g_cartoon.playAudio("sm-choice-correct")
element.goAhead(()=>{ element.goAhead(()=>{
this.nextQuestion(()=>{ this.nextQuestion(()=>{
this.loadQuestion() this.loadQuestion()
element.ready(()=>{ element.ready()
// this.g_cartoon.getCartoonElement("play-audio").play()
})
}) })
}) })
}else{ }else{
...@@ -950,18 +979,10 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -950,18 +979,10 @@ export class PlayComponent implements OnInit, OnDestroy {
this.endGame() this.endGame()
}else{ }else{
this.m_currentQuestion++ 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++){ for(let index=0; index<4; index++){
this.g_cartoon.getCartoonElement(`question-card-${index}`).ref.visible = false; this.g_cartoon.getCartoonElement(`question-card-${index}`).ref.visible = false;
} }
this.showEndPatal() this.showEndPatal()
// this.g_cartoon.playAudio("win")
this.m_setTimeoutIDs.push(setTimeout(() => { this.m_setTimeoutIDs.push(setTimeout(() => {
this.stopEndPatal() this.stopEndPatal()
callback && callback() callback && callback()
......
...@@ -70,6 +70,7 @@ const localAudios = { ...@@ -70,6 +70,7 @@ const localAudios = {
'sm-choice-error': 'assets/default/audio/sm-choice-error.mp3', 'sm-choice-error': 'assets/default/audio/sm-choice-error.mp3',
'skier': 'assets/audio/skier.mp3', 'skier': 'assets/audio/skier.mp3',
'win': 'assets/audio/win.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