第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

正在回答

3 回答

怎么實(shí)現(xiàn)多個(gè)小球隨機(jī)跳動(dòng),不要有倒計(jì)時(shí)的效果。請(qǐng)看一下還差了什么。


0 回復(fù) 有任何疑惑可以回復(fù)我~
<!DOCTYPE?html>
<html?lang="en">
<head>
????<meta?charset="UTF-8">
????<title>Title</title>
</head>
<body>
<script>
?var?RADIUS=4;
?var?balls=[]
????window.onload=function()
????????{
????????????var?canvas?=?document.getElementById('canvas');
?canvas.width?=?1024;
?canvas.height?=?500;
?var?context?=?canvas.getContext("2d");
?setInterval(
????????????????function?()?{
????????????????????render(context);
?update();
?}
????????????????,
?50
?);
?}


????function?update(){

????????for(?var?i?=?0?;?i?<?balls.length?;?i?++?){

????????????balls[i].x?+=?balls[i].vx;
?balls[i].y?+=?balls[i].vy;
?balls[i].vy?+=?balls[i].g;

?if(?balls[i].y?>=?canvas.width-RADIUS?){
????????????????balls[i].y?=?canvas.height-RADIUS;
?balls[i].vy?=?-?balls[i].vy*0.75;
?}
????????}
????}
????function?render(cxt){
????????cxt.clearRect(0,0,cxt.canvas.width,cxt.canvas.height)
????????for(?var?i?=?0?;?i?<?balls.length?;?i?++?){
????????????cxt.fillStyle="#ff3";

?cxt.beginPath();
?cxt.arc(?balls[i].x?,?balls[i].y?,?RADIUS?,?0?,?2*Math.PI?,?true?);
?cxt.closePath();

?cxt.fill();
?}
????}
</script>
<canvas?id="canvas"?style="border:1px?solid?#aaa;display:block;margin:50px?auto;">
?<!--當(dāng)前瀏覽器不支持Canvas,請(qǐng)更換瀏覽器后再試-->
</canvas>

</body>
</html>


0 回復(fù) 有任何疑惑可以回復(fù)我~

把每個(gè)小球當(dāng)成一個(gè)對(duì)象放到數(shù)組里,遍歷數(shù)組實(shí)現(xiàn)每個(gè)小球的動(dòng)畫(huà)。

?//小球的基本運(yùn)動(dòng)????
?updataBalls?:?function(){????????
??????????var?_this?=?this;????????
??????????var?balls?=?_this.data.balls;????????
??????????for(var?i=0;?i<balls.length;?i++){???????????
?????????????balls[i].x?+=?balls[i].vx;????????????
?????????????balls[i].y?+=?balls[i].vy;???????????
?????????????balls[i].vy?+=?balls[i].g;????????????
?????????????if(balls[i].y?>=_WINDOW_HEIGHT?-?_RADIUS){?
?????????????????balls[i].y?=?WINDOW_HEIGHT?-RADIUS;????????????????
??????????????????balls[i].vy?=?-balls[i].vy*0.75;???????????
?????????????}???????
??????????}???
????????}


0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

小球跳動(dòng)的問(wèn)題

我要回答 關(guān)注問(wèn)題
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)