Commit 0b6b99d2 authored by 李维's avatar 李维

dev commit

parent 216ff7e4
...@@ -227,6 +227,7 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -227,6 +227,7 @@ export class PlayComponent implements OnInit, OnDestroy {
this.initQuestionCards() this.initQuestionCards()
this.initSpeaker() this.initSpeaker()
this.initQuestionIndexBoard(); this.initQuestionIndexBoard();
this.initHeader()
} }
cleanGameVar(){ cleanGameVar(){
...@@ -236,9 +237,10 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -236,9 +237,10 @@ export class PlayComponent implements OnInit, OnDestroy {
startGame(){ startGame(){
this.loadQuestion() this.loadQuestion()
this.g_cartoon.playAudio("bg_music", false ,null, true, (audio)=>{ this.playTips()
this.g_cartoon.playAudio("skier", false ,null, true, (audio)=>{
this.m_bgMusic = audio this.m_bgMusic = audio
audio.volume = 0.05 audio.volume = 0.5
}) })
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()
...@@ -275,9 +277,12 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -275,9 +277,12 @@ export class PlayComponent implements OnInit, OnDestroy {
muteBgMusic(status){ muteBgMusic(status){
if(status){ if(status){
this.m_bgMusic.volume = 0 this.g_cartoon.stopAudio("skier")
}else{ }else{
this.m_bgMusic.volume = 0.05 this.g_cartoon.playAudio("skier", false ,null, true, (audio)=>{
this.m_bgMusic = audio
audio.volume = 0.5
})
} }
} }
...@@ -360,6 +365,51 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -360,6 +365,51 @@ export class PlayComponent implements OnInit, OnDestroy {
this.render(element.ref, 999) this.render(element.ref, 999)
} }
// 小手
initHeader(){
let element = this.g_cartoon.createCartoonElementImageFunc(`header`, "header", (w,h)=>{
return {
sx: 98*this.g_mapScale / w,
sy: 97*this.g_mapScale / h
}
}, (w,h)=>{
return{
x: this.g_canvasWidth/2,
y: this.g_canvasHeight/2
}
})
element.ref.visible = false;;
this.render(element.ref, 999)
}
playTips(){
let header = this.g_cartoon.getCartoonElement(`header`)
let audio = this.g_cartoon.getCartoonElement(`play-audio`)
let skier = this.g_cartoon.getCartoonElement(`skier`)
setTimeout(()=>{
header.ref.visible = true;
header.ref.scaleX = header.ref.scaleX * 1.3
header.ref.scaleY = header.ref.scaleY * 1.3
header.ref.x = audio.ref.x + this.g_canvasWidth
header.ref.y = audio.ref.y + this.g_canvasHeight
setTimeout(() => {
tweenChange(header.ref, {x: audio.ref.x+50*this.g_mapScale , y:audio.ref.y+50*this.g_mapScale, scaleX: header.initScaleX, scaleY: header.initScaleY}, 0.5, ()=>{
setTimeout(() => {
tweenChange(header.ref, {scaleX: header.ref.scaleX * 1.2, scaleY:header.ref.scaleY * 1.2}, 0.2)
setTimeout(() => {
tweenChange(header.ref, {scaleX: header.initScaleX, scaleY: header.initScaleY}, 0.2)
}, 300);
tweenChange(header.ref, {x: skier.ref.x+50*this.g_mapScale , y:skier.ref.y-50*this.g_mapScale}, 0.5, ()=>{
header.ref.visible = false;
this.g_cartoon.getCartoonElement("skier").cruise()
})
}, 1000);
})
}, 1000);
}, 500)
}
initBaseLine(){ initBaseLine(){
let element = this.g_cartoon.createCartoonElementImage("base-line", "base_line", this.g_canvasWidth, 5*this.g_mapScale, this.g_canvasWidth/2, this.g_canvasHeight*0.8) let element = this.g_cartoon.createCartoonElementImage("base-line", "base_line", this.g_canvasWidth, 5*this.g_mapScale, this.g_canvasWidth/2, this.g_canvasHeight*0.8)
element.ref.visible = false; element.ref.visible = false;
...@@ -507,11 +557,8 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -507,11 +557,8 @@ export class PlayComponent implements OnInit, OnDestroy {
} }
this.g_cartoon.stopAllAudio() 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.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++){
...@@ -756,31 +803,24 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -756,31 +803,24 @@ export class PlayComponent implements OnInit, OnDestroy {
element.ref.scaleX = element.initScaleX * 1.2 element.ref.scaleX = element.initScaleX * 1.2
element.ref.scaleY = element.initScaleY * 1.2 element.ref.scaleY = element.initScaleY * 1.2
let header = this.g_cartoon.createCartoonElementImageFunc(`header`, "header", (w,h)=>{ let header = this.g_cartoon.createCartoonElementImageFunc(`header-inside`, "header", (w,h)=>{
return { return {
sx: 98 / w, sx: 98 / w,
sy: 97 / h sy: 97 / h
} }
}, (w,h)=>{ }, (w,h)=>{
return{ return{
x: 0, x: 50,
y: 50 y: -50
} }
}) })
header.ref.x = header.ref.x+500
header.ref.y = header.ref.y+500
header.ref.scaleX = header.ref.scaleX * 1.5
header.ref.scaleY = header.ref.scaleY * 1.5
header.ref.visible = false; header.ref.visible = false;
element.ref.addChild(header.ref) element.ref.addChild(header.ref)
element.firstClick = true;
element.cruiseIntervalID = null;
element.cruiseSetTimeoutID = null
element.firstClick = true
element.cruise = (callback?)=>{ element.cruise = (callback?)=>{
header.ref.visible = true;
if(element.firstClick){ if(element.firstClick){
let time = 0;
header.ref.visible = true;
element.cruiseSetTimeoutID = setTimeout(() => { element.cruiseSetTimeoutID = setTimeout(() => {
let dir = false; let dir = false;
let step = 10 * this.g_mapScale let step = 10 * this.g_mapScale
...@@ -792,6 +832,11 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -792,6 +832,11 @@ export class PlayComponent implements OnInit, OnDestroy {
} }
if(element.ref.x>this.g_canvasWidth-300*this.g_mapScale || element.ref.x<300*this.g_mapScale){ if(element.ref.x>this.g_canvasWidth-300*this.g_mapScale || element.ref.x<300*this.g_mapScale){
dir = !dir dir = !dir
time++
}
if(time>=2 && ( element.ref.x<=(this.g_canvasWidth/2+20*this.g_mapScale) && element.ref.x>=(this.g_canvasWidth/2-20*this.g_mapScale) ) ){
element.stopCruise()
element.ref.x = element.ref.initX
} }
}, 30) }, 30)
this.m_setIntervalIDs.push(element.cruiseIntervalID) this.m_setIntervalIDs.push(element.cruiseIntervalID)
...@@ -799,24 +844,11 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -799,24 +844,11 @@ export class PlayComponent implements OnInit, OnDestroy {
}, 500) }, 500)
this.m_setTimeoutIDs.push(element.cruiseSetTimeoutID) 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 = ()=>{ element.stopCruise = ()=>{
header.ref.visible = false; header.ref.visible = false;
this.g_cartoon.getCartoonElement(`header`).ref.visible = false;
if(element.cruiseIntervalID){ if(element.cruiseIntervalID){
clearInterval(element.cruiseIntervalID) clearInterval(element.cruiseIntervalID)
} }
...@@ -842,14 +874,14 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -842,14 +874,14 @@ export class PlayComponent implements OnInit, OnDestroy {
element.ready =(callback?)=>{ element.ready =(callback?)=>{
tweenChange(element.ref, {x: element.initX, y: element.initY, scaleX: element.initScaleX, scaleY: element.initScaleY}, 0.2, ()=>{ tweenChange(element.ref, {x: element.initX, y: element.initY, scaleX: element.initScaleX, scaleY: element.initScaleY}, 0.2, ()=>{
this.g_enableMapDown = true this.g_enableMapDown = true
if(element.firstReady){ // if(element.firstReady){
element.firstReady = false; // element.firstReady = false;
element.cruise(()=>{ // element.cruise(()=>{
callback && callback() // callback && callback()
}) // })
}else{ // }else{
callback && callback() // callback && callback()
} // }
}) })
} }
...@@ -876,7 +908,7 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -876,7 +908,7 @@ export class PlayComponent implements OnInit, OnDestroy {
element.stopCruise() element.stopCruise()
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("move")
this.muteBgMusic(true) this.muteBgMusic(true)
this.enableMoveAsstant(()=>{ this.enableMoveAsstant(()=>{
element.ref.x = this.g_clickX + disX; element.ref.x = this.g_clickX + disX;
...@@ -890,11 +922,13 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -890,11 +922,13 @@ export class PlayComponent implements OnInit, OnDestroy {
if(element.enableDrag){ if(element.enableDrag){
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.playAudio("move")
this.muteBgMusic(false) 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", false, ()=>{
this.g_cartoon.playAudio("win")
})
element.goAhead(()=>{ element.goAhead(()=>{
this.nextQuestion(()=>{ this.nextQuestion(()=>{
this.loadQuestion() this.loadQuestion()
...@@ -902,7 +936,9 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -902,7 +936,9 @@ export class PlayComponent implements OnInit, OnDestroy {
}) })
}) })
}else{ }else{
this.g_cartoon.playAudio("sm-choice-error") this.g_cartoon.playAudio("sm-choice-error",false,()=>{
this.g_cartoon.playAudio("move")
})
this.g_cartoon.getCartoonElement(`question-card-${element.targetRunWay}`).shake(()=>{ this.g_cartoon.getCartoonElement(`question-card-${element.targetRunWay}`).shake(()=>{
element.ready() element.ready()
}) })
...@@ -993,53 +1029,6 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -993,53 +1029,6 @@ export class PlayComponent implements OnInit, OnDestroy {
} }
// 小手
initHeader(){
let element = this.g_cartoon.createCartoonElementImageFunc(`header`, "header", (w,h)=>{
return {
sx: 98*this.g_mapScale / w,
sy: 97*this.g_mapScale / h
}
}, (w,h)=>{
return{
x: this.g_canvasWidth/2,
y: this.g_canvasHeight/2
}
})
element.ref.visible = false;;
element.move = ()=>{
let y = this.g_cartoon.getCartoonElement("skier").ref.y + 50*this.g_mapScale
tweenChange(element.ref, {x: fakePoint[currentIndex], y:y}, 0.5)
currentIndex++;
if(currentIndex==9){
currentIndex = 0;
}
}
element.in = (callback?)=>{
element.ref.x = this.g_canvasWidth + 100*this.g_mapScale
element.ref.y = this.g_canvasHeight + 100*this.g_mapScale
let dis = {
x: this.g_cartoon.getCartoonElement("camera").ref.x + 55*this.g_mapScale,
y: this.g_cartoon.getCartoonElement("camera").ref.y + 55*this.g_mapScale
}
tweenChange(element.ref, dis, 0.5, ()=>{
callback && callback()
})
element.ref.visible = true;
}
element.out = ()=>{
element.ref.visible = false;
}
let currentIndex = 0;
let fakePoint = [ 735,1040,468,1288,196,1040,1288,735,196 ]
this.render(element.ref)
}
......
...@@ -70,8 +70,8 @@ const localAudios = { ...@@ -70,8 +70,8 @@ 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" "bg_music": "assets/audio/bg_music.mp3",
"move": "assets/audio/move.mp3"
}; };
export {localImages, localAudios}; export {localImages, localAudios};
src/assets/play/skier.png

49.2 KB | W: | H:

src/assets/play/skier.png

81 KB | W: | H:

src/assets/play/skier.png
src/assets/play/skier.png
src/assets/play/skier.png
src/assets/play/skier.png
  • 2-up
  • Swipe
  • Onion skin
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