单个对应随机
							parent
							
								
									1fd6c25055
								
							
						
					
					
						commit
						883c6cfb10
					
				
							
								
								
									
										32
									
								
								js/custom.js
								
								
								
								
							
							
						
						
									
										32
									
								
								js/custom.js
								
								
								
								
							|  | @ -25,19 +25,28 @@ function allDancing(){ | |||
| 	},3000) | ||||
| } | ||||
| // 随机舞
 | ||||
| function randomDancing(){ | ||||
| function randomDancing(id){ | ||||
| 	actionTimer = setInterval(()=>{ | ||||
| 		var len = $('.dance-people').length; | ||||
| 		for (var i = 0; i < num; i++) { | ||||
| 		// var len = $('.dance-people').length;
 | ||||
| 		// for (var i = 0; i < num; i++) {
 | ||||
| 		// 	actionArr.forEach((item,index)=>{
 | ||||
| 		// 		// var chooseIdex = Math.floor(Math.random()*num);
 | ||||
| 		// 		var haveDan = $(`.data${i} .people-img`).is(`.${item}`);
 | ||||
| 		// 		if(haveDan){
 | ||||
| 		// 			$(`.data${i} .people-img`).removeClass(item);
 | ||||
| 		// 			$(`.data${i} .people-img`).addClass(actionArr[Math.floor(Math.random()*actionArr.length)]);
 | ||||
| 		// 		}
 | ||||
| 		// 	})
 | ||||
| 		// }
 | ||||
| 		actionArr.forEach((item,index)=>{ | ||||
| 			// var chooseIdex = Math.floor(Math.random()*num);
 | ||||
| 				var haveDan = $(`.data${i} .people-img`).is(`.${item}`); | ||||
| 			var haveDan = $(`.data${id} .people-img`).is(`.${item}`); | ||||
| 			if(haveDan){ | ||||
| 					$(`.data${i} .people-img`).removeClass(item); | ||||
| 					$(`.data${i} .people-img`).addClass(actionArr[Math.floor(Math.random()*actionArr.length)]); | ||||
| 				$(`.data${id} .people-img`).removeClass(item); | ||||
| 				$(`.data${id} .people-img`).addClass(actionArr[Math.floor(Math.random()*actionArr.length)]); | ||||
| 			} | ||||
| 		}) | ||||
| 		} | ||||
| 		console.log(id); | ||||
| 	},3000) | ||||
| } | ||||
| // 关闭说话
 | ||||
|  | @ -54,6 +63,7 @@ function sayIng(index){ | |||
| function peopleObj(name,say,action){ | ||||
| 	// 开始说话
 | ||||
| 	sayIng(peopleId); | ||||
| 	randomDancing(peopleId); | ||||
| 	let yspHtml = ''; | ||||
| 	let yspData = [ | ||||
| 		{ | ||||
|  | @ -87,20 +97,16 @@ $(function(){ | |||
| 	// 	console.log('开始集体舞');
 | ||||
| 	// 	allDancing();
 | ||||
| 	// },50000)
 | ||||
| 	setTimeout(()=>{ | ||||
| 		console.log('开启随机舞') | ||||
| 		randomDancing(); | ||||
| 	},4000)//需要2s的倍数
 | ||||
| 	timer = setInterval(()=>{ | ||||
| 		var nameIndex = Math.floor(Math.random()*nameArr.length); | ||||
| 		var sayIndex = Math.floor(Math.random()*sayArr.length); | ||||
| 		var actionIndex = Math.floor(Math.random()*actionArr.length); | ||||
| 		num++; | ||||
| 		if(num==300){ | ||||
| 		if(num==10){ | ||||
| 			clearInterval(timer); | ||||
| 		} else { | ||||
| 			peopleObj(nameArr[nameIndex],sayArr[sayIndex],actionArr[actionIndex]); | ||||
| 		} | ||||
| 	},1000) | ||||
| 	},000) | ||||
| 	 | ||||
| }) | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue