随机位移

master
chen 2021-11-24 11:35:11 +08:00
parent 19624b2ed7
commit 8072863a87
2 changed files with 28 additions and 32 deletions

View File

@ -80,50 +80,46 @@ function peopleAction(id,aevent){
}
// 随机位移
function moveEv(id){
// upMove(id);
downMove(id);
// var typeMove = Math.floor(Math.random()*4);
// switch (typeMove){
// case 0:
// upMove(id);
// break;
// case 1:
// downMove(id);
// break;
// case 2:
// leftMove(id);
// break;
// case 3:
// rightMove(id);
// break;
// }
upMove(id);
// downMove(id);
var typeMove = Math.floor(Math.random()*4);
switch (typeMove){
case 0:
upMove(id);
break;
case 1:
downMove(id);
break;
case 2:
leftMove(id);
break;
case 3:
rightMove(id);
break;
}
}
// 上
function upMove(id){
var odivu = document.getElementById(`${id}`);
var upTimer = setInterval(()=>{
if(odivu.style.top <='1%' || odivu.style.top<30){
// console.log('关闭了上走');
if(parseInt(odivu.style.top) <=10){
clearInterval(upTimer);
downMove(id);
} else {
// console.log('上走进来了');
$(`#${id}`).animate({top:'0%'},20000);
// odivu.style.top = odivu.offsetTop-speed+'px';
$(`#${id}`).animate({top:`${Math.floor(Math.random()*76)}%`,left:`${Math.floor(Math.random()*76)}%`},Math.floor(Math.random()*40000+10000));
}
},100)
},10)
}
// 下
function downMove(id){
var odivd = document.getElementById(`${id}`);
downTimer = setInterval(()=>{
if(odivd.style.top >='76%'){
var downTimer = setInterval(()=>{
if(parseInt(odivd.style.top) >=86){
clearInterval(downTimer);
upMove(id);
} else {
$(`#${id}`).animate({top:'80%'},10000);
// odivd.style.top = odivd.offsetTop+speed+'px';
$(`#${id}`).animate({top:`${Math.floor(Math.random()*90)}%`,left:`${Math.floor(Math.random()*90)}%`},Math.floor(Math.random()*40000+10000));
}
},10)
}
@ -131,11 +127,11 @@ function downMove(id){
function leftMove(id){
var odivl = document.getElementById(`${id}`);
leftTimer = setInterval(()=>{
if(odivl.offsetLeft == 0){
if(odivl.offsetLeft < 10){
clearInterval(leftTimer);
rightMove(id);
} else {
odivl.style.left = odivl.offsetLeft-speed+'px';
$(`#${id}`).animate({top:`${Math.floor(Math.random()*90)}%`,left:`${Math.floor(Math.random()*90)}%`},Math.floor(Math.random()*40000+10000));
}
},10)
}
@ -143,11 +139,11 @@ function leftMove(id){
function rightMove(id){
var odivr = document.getElementById(`${id}`);
rightTimer = setInterval(()=>{
if(odivr.offsetLeft > 1600){
if(odivr.offsetLeft >= 86){
clearInterval(rightTimer);
leftMove(id);
} else {
odivr.style.left = odivr.offsetLeft+speed+'px';
$(`#${id}`).animate({top:`${Math.floor(Math.random()*90)}%`,left:`${Math.floor(Math.random()*90)}%`},Math.floor(Math.random()*40000+10000));
}
},10)
}

View File

@ -222,7 +222,7 @@ function receiveMessage(event)
//关闭领舞说话
setTimeout(()=>{
$('.speak-pink').fadeOut();
},3000)
},1000)
}
// 领舞说切歌
if(leader.text=="切歌"){