Commit e82d9ac0 authored by 李维's avatar 李维

Update package

parent d73963a7
......@@ -9,7 +9,6 @@
# dependencies
/node_modules
/publish
# profiling files
chrome-profiler-events*.json
......
......@@ -114,21 +114,31 @@ export class Cartoon {
const audio = this.audio.get(key);
audio.volume = volume
}
stopAllAudio(){
this._playingNow.forEach(audio=>{
stopAllAudio(audioAll?){
if(!audioAll){
audioAll = this._playingNow
}
audioAll.forEach(audio_URL=>{
if(audio_URL){
const audio = this.audio.get(audio_URL);
try{
if(audio){
audio.onended && audio.onended()
audio.pause();
audio.pause && audio.pause();
audio.currentTime = 0;
}else{
if(audio.src && this.audioCallback[audio.src] && this.audioCallback[audio.src]["onended"]){
this.audioCallback[audio.src]["onended"]()
if(this.audioCallback[audio_URL] && this.audioCallback[audio_URL]["onended"]){
this.audioCallback[audio_URL]["onended"]()
}
}
}catch(err){
console.log(err)
}
}
else if(this._currentPlayAudio){
this._currentPlayAudio.pause();
this._currentPlayAudio.currentTime = 0;
}
})
this._playingNow = []
}
......
......@@ -170,7 +170,8 @@ export class PlayComponent implements OnInit, OnDestroy {
{x: 450}
]
}
m_canStopAudio = []
m_tipsSetinterval_1 = null;
// ------------------------------------
......@@ -217,9 +218,11 @@ export class PlayComponent implements OnInit, OnDestroy {
let array = []
contentObj.dataArray.forEach(item => {
array.push(item.audio_url)
this.m_canStopAudio.push(item.audio_url)
item.options.forEach(card=>{
if(card.audio_url){
array.push(card.audio_url)
this.m_canStopAudio.push(card.audio_url)
}
})
})
......@@ -254,11 +257,15 @@ export class PlayComponent implements OnInit, OnDestroy {
cleanGameVar(){
this.stopEndPatal()
this.m_currentQuestion = 0;
if(this.m_tipsSetinterval_1){
clearInterval(this.m_tipsSetinterval_1)
}
// this.g_cartoon.getCartoonElement(`play-audio`).firstClick = true;
}
startGame(){
this.loadQuestion()
this.playTips()
this.playTips(1)
this.g_cartoon.playAudio("skier", false ,null, true, (audio)=>{
this.m_bgMusic = audio
audio.volume = 0.5
......@@ -266,7 +273,6 @@ export class PlayComponent implements OnInit, OnDestroy {
this.g_cartoon.getCartoonElement(`question-index-board`).resetIndex()
this.g_cartoon.getCartoonElement("play-audio").in()
this.g_cartoon.getCartoonElement("skier").ready(()=>{
// this.g_cartoon.getCartoonElement("play-audio").play()
})
}
......@@ -404,10 +410,52 @@ export class PlayComponent implements OnInit, OnDestroy {
this.render(element.ref, 999)
}
playTips(){
playTips(type?){
let loopFunc
let header = this.g_cartoon.getCartoonElement(`header`)
let audio = this.g_cartoon.getCartoonElement(`play-audio`)
let skier = this.g_cartoon.getCartoonElement(`skier`)
if(!type){
type = 3
}
if(type == 1){
if(this.m_tipsSetinterval_1){
clearInterval(this.m_tipsSetinterval_1)
}
loopFunc = ()=>{
header.ref.visible = true;
header.ref.scaleX = header.ref.scaleX * 1.5
header.ref.scaleY = header.ref.scaleY * 1.5
header.ref.x = audio.ref.x + this.g_canvasWidth
header.ref.y = audio.ref.y + this.g_canvasHeight
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}, 2)
return loopFunc
}
this.m_tipsSetinterval_1 = setInterval(loopFunc(), 3000)
this.m_setIntervalIDs.push(this.m_tipsSetinterval_1)
return
}
if(type == 2){
header.ref.scaleX = header.initScaleX
header.ref.scaleY = header.initScaleY
header.ref.x = audio.ref.x+50*this.g_mapScale
header.ref.y = audio.ref.y+50*this.g_mapScale
header.ref.visible = true;
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()
})
return
}
if(type == 3){
setTimeout(()=>{
header.ref.visible = true;
header.ref.scaleX = header.ref.scaleX * 1.3
......@@ -429,6 +477,8 @@ export class PlayComponent implements OnInit, OnDestroy {
})
}, 1000);
}, 500)
return
}
}
initBaseLine(){
......@@ -550,12 +600,13 @@ export class PlayComponent implements OnInit, OnDestroy {
}
}, (w,h)=>{
return{
x: 1157*this.g_mapScale + (96/2)*this.g_mapScale,
x: this.g_canvasWidth - (190/2)*this.g_mapScale,
y: 80*this.g_mapScale + (96/2)*this.g_mapScale,
}
})
element.ref.setScaleXY(0)
element.firstClick = true;
let audio0 = new MySprite()
audio0.init(this.g_cartoon.images.get("play_audio_0"))
......@@ -586,7 +637,7 @@ export class PlayComponent implements OnInit, OnDestroy {
if(!this.g_formData.dataArray[this.m_currentQuestion].audio_url){
return
}
this.g_cartoon.stopAllAudio()
this.g_cartoon.stopAllAudio(this.m_canStopAudio)
this.g_cartoon.playAudio(this.g_formData.dataArray[this.m_currentQuestion].audio_url, false, ()=>{
element.stop();
this.muteBgMusic(false)
......@@ -614,8 +665,17 @@ export class PlayComponent implements OnInit, OnDestroy {
}
this.subscribeMapDownEvent(`play-audio`, ()=>{
clearInterval(this.m_tipsSetinterval_1)
if(element.firstClick){
element.firstClick = false;
this.playTips(2)
}else{
this.g_cartoon.getCartoonElement(`header`).ref.visible = false;
}
this.g_cartoon.getCartoonElement("skier").enbaleClick = true;
if(this.g_formData.dataArray[this.m_currentQuestion].audio_url){
this.g_cartoon.stopAllAudio()
this.g_cartoon.stopAllAudio(this.m_canStopAudio)
element.play()
}
tweenChange(element.ref, {scaleX: element.ref.initScaleX*0.9, scaleY: element.ref.initScaleY*0.9}, 0.1, ()=>{
......@@ -870,6 +930,7 @@ export class PlayComponent implements OnInit, OnDestroy {
element.ref.y = this.g_canvasHeight + 500*this.g_mapScale
element.ref.scaleX = element.initScaleX * 1.2
element.ref.scaleY = element.initScaleY * 1.2
element.enbaleClick = false;
let header = this.g_cartoon.createCartoonElementImageFunc(`header-inside`, "header", (w,h)=>{
return {
......@@ -940,17 +1001,11 @@ export class PlayComponent implements OnInit, OnDestroy {
element.firstReady = true;
element.ready =(callback?)=>{
this.g_cartoon.playAudio("skier", false, ()=>{
this.muteBgMusic(false)
})
tweenChange(element.ref, {x: element.initX, y: element.initY, scaleX: element.initScaleX, scaleY: element.initScaleY}, 0.2, ()=>{
this.g_enableMapDown = true
// if(element.firstReady){
// element.firstReady = false;
// element.cruise(()=>{
// callback && callback()
// })
// }else{
// callback && callback()
// }
})
}
......@@ -972,7 +1027,7 @@ export class PlayComponent implements OnInit, OnDestroy {
element.enableDrag = false;
this.subscribeMapDownEvent(element.id, ()=>{
if(!this.g_cartoon.getCartoonElementRef("mask-layer").visible && !element.enableDrag){
if(!this.g_cartoon.getCartoonElementRef("mask-layer").visible && !element.enableDrag && element.enbaleClick){
element.enableDrag = true
element.stopCruise()
let disX = element.ref.x - this.g_clickX
......@@ -984,6 +1039,10 @@ export class PlayComponent implements OnInit, OnDestroy {
element.ref.y = this.g_clickY + disY;
this.highlightRunWay(this.calcRunWayIndex(element.ref.x, element.ref.y))
})
}else{
if(!element.enbaleClick){
this.g_enableMapDown = true;
}
}
})
......@@ -991,7 +1050,6 @@ export class PlayComponent implements OnInit, OnDestroy {
if(element.enableDrag){
element.enableDrag = false;
element.targetRunWay = this.calcRunWayIndex(element.ref.x, element.ref.y)
// this.g_cartoon.playAudio("move")
this.muteBgMusic(false)
element.go(element.targetRunWay, ()=>{
if(this.gameControl(element.targetRunWay)){
......@@ -1001,7 +1059,8 @@ export class PlayComponent implements OnInit, OnDestroy {
element.goAhead(()=>{
this.nextQuestion(()=>{
this.loadQuestion()
element.ready()
element.ready();
this.g_cartoon.playAudio("move")
})
})
}else{
......@@ -1090,6 +1149,8 @@ export class PlayComponent implements OnInit, OnDestroy {
this.showEndPatal()
this.m_setTimeoutIDs.push(setTimeout(() => {
this.stopEndPatal()
this.playTips(1)
this.g_cartoon.getCartoonElement("skier").enbaleClick = false
callback && callback()
}, 3000))
......@@ -1098,7 +1159,6 @@ export class PlayComponent implements OnInit, OnDestroy {
}
controlCardAndHotZoo(num){
console.log(num)
let allQuestionCards = []
let hotZooArrows = []
for(let index=0; index<4; index++){
......
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