fruit的問(wèn)題,怎么這一節(jié)問(wèn)題這么少
var?fruitObject=function(){ this.alive=[];//boolean this.orange=new?Image(); this.blue=new?Image(); this.x=[]; this.y=[]; } fruitObject.prototype.num=30; fruitObject.prototype.init=function()?{ for(var?i=0;i<this.num;i++){ this.alive[i]=true; this.x[i]=0; this.y[i]=0; this.born(i); } this.orange.src="./src/fruit.png"; this.blue.src="./src/blue.png"; } fruitObject.prototype.draw=function(){ for(var?i=0;i<this.name;i++){ ctx2.drawImage(this.orange,this.x[i],this.y[i]); } } fruitObject.prototype.born=function(i){ var?aneid=Math.floor(Math.random()*ane.num); this.x[i]=ane.x[aneid]; this.y[i]=canHeight-ane.length[aneid]; ? } var?can1; var?can2; var?ctx1; var?ctx2; var?canWidth; var?canHeight; var?lastTime; var?deltaTime; var?ane; var?fruit; var?bgPic=new?Image(); document.body.onload=game; function?game() { init(); lastTime=Date.now(); deltaTime=0; gameloop(); } function?init(){ //獲得canves?context can1=document.getElementById("canvas1");//fishes,dust,ui ctx1=can1.getContext('2d'); can2=document.getElementById("canvas2"); ctx2=can2.getContext('2d'); bgPic.src="./src/background.jpg"; canWidth=can1.width; ????canHeight=can1.height; ????ane=new?aneObject(); ????ane.init(); ????fruit=new?fruitObject(); ????fruit.init(); } function?gameloop(){ requestAnimFrame(gameloop); var?now=Date.now(); deltaTime=now-lastTime; lastTime=now; drawbackground(); ane.draw(); fruit.draw(); } <!DOCTYPE?HTML> <html> <head> <meta?charset="utf-8"> <title>愛(ài)心魚(yú)</title> <style?type="text/css"> body{ padding-top:?10px; } .all_bg{ width:?800px; height:?600px; margin:?0px?auto; } .allCanves{ position:?relative;; width:?800px; height:?600px; margin:?0px; } #canves1{ position:?absolute; bottom:?0; left:?0; z-index:?1; } #canves2{ position:?absolute; bottom:?0; left:?0; z-index:?0; } </style> </head> <body> <div?class="all_bg"> <div?id="allCanves"> <canvas?id="canvas1"?width="800"?height="600"></canvas> <canvas?id="canvas2"?width="800"?height="600"></canvas> </div> </div> <script?type="text/javascript"?src="js/main.js"></script> <script?type="text/javascript"?src="js/commonFunctions.js"></script> <script?type="text/javascript"?src="js/background.js"></script> <script?type="text/javascript"?src="js/ane.js"></script> <script?type="text/javascript"?src="js/fruit.js"></script> </body> </html>
代碼沒(méi)有報(bào)錯(cuò)了 但是就是不顯示fruit怎么辦
2016-01-07