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

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

請(qǐng)問(wèn)為什么JS繪制的動(dòng)畫中會(huì)有重影呢。

請(qǐng)問(wèn)為什么JS繪制的動(dòng)畫中會(huì)有重影呢。

firmthinking 2016-02-17 00:02:08
//-----------------train.js---------------------------------- var?trainObj=function(){ ????this.x=[]; ????this.y=[]; ????this.alive=[];//bool ????this.ifrun=[]; ????this.ifturn=[]; ????this.open=new?Image(); ????this.close=new?Image(); } trainObj.prototype.num=1; trainObj.prototype.init=function(){ ????for(var?i=0;i<this.num;i++){ ????????this.x[i]=50; ????????this.y[i]=250; ????????this.alive[i]=false; ????????this.ifrun[i]=true; ????????this.ifturn[i]=false; ????????this.open.src="./src/trains.png"; ????????this.close.src="./src/trains.png"; ????} ????console.log("火車初始化完成"); } trainObj.prototype.draw=function(){ ????for(var?i=0;i<this.num;i++){ ????????if(this.ifrun[i]==true){ ????????????if(this.ifturn[i]==true){ ? ????????????}else{ ????????????????this.x[i]+=0.1*deltaTime; ????????????} ????????} ????????ctx1.drawImage(this.close,this.x[i],this.y[i]); ????} } //---------------------main.js----------------------------- var?can1; var?can2; var?ctx1; var?ctx2; var?lastTime; var?deltaTime; var?globW,globH; var?train; document.body.onload=game; function?game(){ ????init(); ????lastTime=Date.now(); ????deltaTime=0; ????gameloop(); } function?init(){ ????//獲得canvas?context ????can1=document.getElementById("canvas1");//繪制紅綠燈?UI??火車??文本框 ????ctx1=can1.getContext('2d'); ????can2=document.getElementById("canvas2");//繪制背景??軌道 ????ctx2=can2.getContext('2d'); ????globW=can1.width; ????globH=can1.height; ????train=new?trainObj(); ????train.init(); ????console.log("初始化完成"); } function?gameloop(){ ????window.requestAnimFrame(gameloop);//setInterval,setTimeout,fps ????var?now=Date.now(); ????deltaTime=now-lastTime; ????lastTime=now; ????console.log(deltaTime); ????background(); ????train.draw(); }上面是我的部分代碼后面是我的程序運(yùn)行的截圖找問(wèn)題找了很久了,但是一直沒(méi)有發(fā)現(xiàn),請(qǐng)大家?guī)蛶兔?,感激不盡!
查看完整描述

3 回答

?
firmthinking

TA貢獻(xiàn)3條經(jīng)驗(yàn) 獲得超0個(gè)贊

已經(jīng)自己解決啦 ?謝謝

查看完整回答
反對(duì) 回復(fù) 2016-02-18
?
firmthinking

TA貢獻(xiàn)3條經(jīng)驗(yàn) 獲得超0個(gè)贊

是不是每畫一幀就應(yīng)該將原有的圖像清除掉才行啊,而且我這樣一直畫也會(huì)導(dǎo)致內(nèi)存泄漏吧。就是不知道怎么實(shí)現(xiàn),請(qǐng)問(wèn)有前輩可以指點(diǎn)我一下嗎

查看完整回答
反對(duì) 回復(fù) 2016-02-17
?
firmthinking

TA貢獻(xiàn)3條經(jīng)驗(yàn) 獲得超0個(gè)贊

請(qǐng)問(wèn)有前輩指導(dǎo)一下么 ? 我在線等 ? 不然課題沒(méi)法往下做啦 ? 非常感謝

查看完整回答
反對(duì) 回復(fù) 2016-02-17
  • 3 回答
  • 1 關(guān)注
  • 2137 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號(hào)

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