最新回答 / 會飛的云89
gameloop()這個函數改下,可以試試看function gameloop(){ ????setTimeout(gameloop,100); ????drawStars();}
2017-05-08
老師,故意繞了一個圈子
var starObj = function (){ //創建函數對象為starObj
this.x=100+Math.random()*600;//x坐標值 也可以理解為屬性值,這了進行隨機變換
this.y=150+Math.random()*300;//y坐標值
}
starObj.prototype.draw=function(){//這里才是用畫布繪制星星的方法
ctx.drawImage(starPic,this.x,this.y);//ctx.drawImage();是畫布中的函數。
}
這樣就可以了
var starObj = function (){ //創建函數對象為starObj
this.x=100+Math.random()*600;//x坐標值 也可以理解為屬性值,這了進行隨機變換
this.y=150+Math.random()*300;//y坐標值
}
starObj.prototype.draw=function(){//這里才是用畫布繪制星星的方法
ctx.drawImage(starPic,this.x,this.y);//ctx.drawImage();是畫布中的函數。
}
這樣就可以了
2017-04-26