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