課程
/前端開發
/HTML/CSS
/HTML5小游戲---愛心魚(上)
???不顯示出來 什么原因 跟老師一樣的代碼..
2017-03-20
源自:HTML5小游戲---愛心魚(上) 2-3
正在回答
//定義一個??麑ο蟮念?var?aneObj?=?function() { }; //定義海葵的寬、高屬性 var?x?=?[]; var?y?=?[]; //定義??麄€數 aneObj.prototype.num?=?50; //初始化確定每一個海葵的位置 aneObj.prototype.init?=?function() { ????for(var?i?=?0;?i?<?this.num;?i++)?{ ????????//寬 ????????x[i]?=?i?*?20?+?Math.random()?*?20;//Math.random()隨機[0,1] ????????//高 ????????y[i]?=?200?+?Math.random()?*?50; ????} ????console.log(x[i]); }; //繪制???aneObj.prototype.draw?=?function() { ????//指定api區間樣式生效 ????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?=?[];
嘗試著在外面定義變量,可能是最后畫線的時候值不能傳遞
什么原因啊
神一樣的男人3392911 提問者
已經找出問題了,可以顯示海葵
舉報
學做HTML5游戲,輕輕松松帶你上手,適合剛入手游戲開發的同學
5 回答海葵不顯示
1 回答為啥我的??伙@示?
3 回答??怀鰜?/p>
1 回答??嫴怀?/p>
1 回答海葵出不來
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網安備11010802030151號
購課補貼聯系客服咨詢優惠詳情
慕課網APP您的移動學習伙伴
掃描二維碼關注慕課網微信公眾號
2017-10-12
2017-10-12
嘗試著在外面定義變量,可能是最后畫線的時候值不能傳遞
2017-03-21
什么原因啊
2017-03-20
已經找出問題了,可以顯示海葵