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

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

如何讓背景圖隨 cancas 的移動(dòng)而移動(dòng)

如何讓背景圖隨 cancas 的移動(dòng)而移動(dòng)

剛毅87 2016-07-16 16:37:49
<!DOCTYPE?html> <html> <head> <meta?charset="UTF-8"> <title></title> <style?type="text/css"> *{ margin:?0; padding:?0; } </style> </head> <body> <canvas?id="myCanvas"?height=""?width=""> 此瀏覽器不支持canvas,請(qǐng)更換瀏覽器 </canvas> <script?type="text/javascript"> var?canvas?=?document.getElementById('myCanvas'); var?context?=?canvas.getContext('2d'); canvas.width?=?document.documentElement.clientWidth; canvas.height?=?document.documentElement.clientHeight; var?imgs?=?new?Image(); imgs.src?=?'img/background.png'; var?bgY?=?0; function?bgmove(){ context.clearRect(0,0,canvas.width,canvas.height); bgY++; var?pattarn?=?context.createPattern(imgs,'repeat'); console.log(bgY); context.fillRect(0,bgY,canvas.width,canvas.height/2); context.fillStyle?=?pattarn; context.fill(); } setInterval(bgmove,30) </script> </body> </html>想讓背景圖隨 cancas 的移動(dòng)而移動(dòng),該如何改進(jìn),求大神指導(dǎo).
查看完整描述

2 回答

已采納
?
業(yè)余奶茶品鑒師

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

參考一下這個(gè)吧

<!DOCTYPE?html>??
<html>??
????<head>??
????????<meta?charset="utf-8">??
????????<title>圖片運(yùn)動(dòng)實(shí)例</title>??
????????<style?type="text/css">??
????????????body?{??
????????????????background:?#DDDDDD;??
????????????}??
????????????#canvas?{??
????????????????border:?thin?solid?black;??
????????????}??
????????????input?{??
????????????????margin-left:?15px;??
????????????}??
????????</style>??
????</head>??
????<body>??
????????<canvas?id="canvas"?width="1000"?height="440">??
????????????您的瀏覽器不支持canvas,請(qǐng)更新到最新的瀏覽器??
????????</canvas>??
????????<input?type="button"?name="animateButton"?id="animateButton"?value="運(yùn)動(dòng)"?/>??
????????<hr?/>??
????????<div>??
????????????<table?border="1"?cellspacing=""?cellpadding="">??
????????????????<tr>??
????????????????????<td>FPS</td>??
????????????????????<td><span?id="FPS"></span></td>??
????????????????</tr>??
????????????????<tr>??
????????????????????<td>SKY_VELOCITY/fps</td>??
????????????????????<td><span?id="SKY_VELOCITY"></span></td>??
????????????????</tr>??
????????????????<tr>??
????????????????????<td>GRASS_VELOCITY/fps</td>??
????????????????????<td><span?id="GRASS_VELOCITY"></span></td>??
????????????????</tr>??
????????????????<tr>??
????????????????????<td>TREE_VELOCITY/fps</td>??
????????????????????<td><span?id="TREE_VELOCITY"></span></td>??
????????????????</tr>??
????????????????<tr>??
????????????????????<td>FAST_TREE_VELOCITY/fps</td>??
????????????????????<td><span?id="FAST_TREE_VELOCITY"></span></td>??
????????????????</tr>??
??????????????????
????????????</table>??
????????</div>??
????</body>??
????<script?type="text/javascript">??
??????
????????var?canvas?=?document.getElementById("canvas"),??
????????????context?=?canvas.getContext("2d"),??
????????????animateButton?=?document.getElementById("animateButton"),??
??????????????
????????????//創(chuàng)建多個(gè)圖像對(duì)象??
????????????sky?=?new?Image(),??
????????????tree?=?new?Image(),??
????????????nearTree?=?new?Image(),??
????????????grass?=?new?Image(),??
????????????grass2?=?new?Image(),??
????????????redRect?=?new?Image,??
??????????????
??????????????
????????????paused?=?true,??
????????????lastTime?=?0,???
????????????fps?=?0,????//當(dāng)前的幀速率


查看完整回答
1 反對(duì) 回復(fù) 2016-07-17
?
剛毅87

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

求大神!

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

添加回答

舉報(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)