課程
/前端開發(fā)
/HTML/CSS
/HTML5小游戲---愛心魚(上)
???不顯示出來 什么原因 跟老師一樣的代碼..
2017-03-20
源自:HTML5小游戲---愛心魚(上) 2-3
正在回答
//定義一個(gè)??麑?duì)象的類 var?aneObj?=?function() { }; //定義??膶?、高屬性 var?x?=?[]; var?y?=?[]; //定義??麄€(gè)數(shù) aneObj.prototype.num?=?50; //初始化確定每一個(gè)海葵的位置 aneObj.prototype.init?=?function() { ????for(var?i?=?0;?i?<?this.num;?i++)?{ ????????//寬 ????????x[i]?=?i?*?20?+?Math.random()?*?20;//Math.random()隨機(jī)[0,1] ????????//高 ????????y[i]?=?200?+?Math.random()?*?50; ????} ????console.log(x[i]); }; //繪制???aneObj.prototype.draw?=?function() { ????//指定api區(qū)間樣式生效 ????ctx2.save(); ????ctx2.globalAlpha?=?0.6; ????ctx2.lineWidth?=?'20'; ????ctx2.lineCap?=?'round'; ????ctx2.strokeStyle?=?'#3b154e'; ????for(var?i?=?0;?i?<?this.num;?i++)?{ ????????//beginPath,moveTo,lineTo,strokeStyle,stroke,lineWidth,lineCap,globalAlpha ????????ctx2.beginPath(); ????????ctx2.moveTo(x[i],canHeight); ????????ctx2.lineTo(x[i],canHeight?-?y[i]); ????????ctx2.stroke(); ????} ????ctx2.restore(); };
var?aneObj?=?function() { }; //定義海葵的寬、高屬性 var?x?=?[]; var?y?=?[];
嘗試著在外面定義變量,可能是最后畫線的時(shí)候值不能傳遞
什么原因啊
神一樣的男人3392911 提問者
已經(jīng)找出問題了,可以顯示???/p>
舉報(bào)
學(xué)做HTML5游戲,輕輕松松帶你上手,適合剛?cè)胧钟螒蜷_發(fā)的同學(xué)
5 回答??伙@示
1 回答為啥我的??伙@示?
1 回答??霾粊?/p>
1 回答海葵畫不出
3 回答??怀鰜?/p>
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號(hào)-11 京公網(wǎng)安備11010802030151號(hào)
購(gòu)課補(bǔ)貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動(dòng)學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號(hào)
2017-10-12
2017-10-12
嘗試著在外面定義變量,可能是最后畫線的時(shí)候值不能傳遞
2017-03-21
什么原因啊
2017-03-20
已經(jīng)找出問題了,可以顯示???/p>