Commit dd10053f authored by Chen Jiping's avatar Chen Jiping

完善

parent 8471fd16
...@@ -992,33 +992,35 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -992,33 +992,35 @@ export class PlayComponent implements OnInit, OnDestroy {
//取出气球显示 //取出气球显示
for(let i = 0; i < this.temp_max_ballon; ++ i){ for(let i = 0; i < this.temp_max_ballon; ++ i){
let answer = this.getShowAnswer(); this.getShowAnswer((answer)=>{
if(answer){
//取出坐标
answer.pic.x = this.ballon_mapx_arr[i];
this.ballon_temp_arr.push(answer);
//显示气球
this.ballonRose(answer);
}
});
}
}
else{
this.getShowAnswer((answer)=>{
if(answer){ if(answer){
//取出坐标 //设置坐标
answer.pic.x = this.ballon_mapx_arr[i]; answer.pic.x = mapX;
this.ballon_temp_arr.push(answer); this.ballon_temp_arr.push(answer);
//显示气球 //显示气球
this.ballonRose(answer); this.ballonRose(answer);
} }
} });
}
else{
let answer = this.getShowAnswer();
if(answer){
//设置坐标
answer.pic.x = mapX;
this.ballon_temp_arr.push(answer);
//显示气球
this.ballonRose(answer);
}
} }
...@@ -1046,26 +1048,29 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -1046,26 +1048,29 @@ export class PlayComponent implements OnInit, OnDestroy {
return check; return check;
} }
getShowAnswer(){ getShowAnswer(callback){
let answer;
while(true){ let answer = this.getRandomItemFromArr(this.curanswers);
answer = this.getRandomItemFromArr(this.curanswers); if(!answer){
if(!answer){ setTimeout(()=>{
break; this.getShowAnswer(callback);
} }, 10);
}
else{
let index = this.ballon_temp_arr.indexOf(answer); let index = this.ballon_temp_arr.indexOf(answer);
if(index == -1){ if(index == -1){
break; callback(answer);
}
else{
setTimeout(()=>{
this.getShowAnswer(callback);
}, 10);
} }
} }
return answer;
} }
getRandomItemFromArr(arr){ getRandomItemFromArr(arr){
......
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