为什么我的黄果实在右上角?
为什么我的黄果实在右上角?
为什么我的黄果实在右上角?
2017-06-06
我的没有born(i)也是在左上角,但是加上之后,左上角都没有了
var fruitObj=function() { this.alive = [];//bool this.x = [];// this.y = [];// this.orange = new Image(); this.blue = new Image();//果实形态2 } fruitObj.prototype.num = 30; fruitObj.prototype.init=function() { for (var i = 0; i < this.num; i++) { this.alive[i]=false;//初始化果实为激活状态 this.x[i]=0; this.y[i]=0; //this.born(i); } this.orange.src="./img/fruit.png" this.blue.src="./img/blue.png" console.log("初始化执行"); } fruitObj.prototype.draw=function(){//画果实 for (var i = 0; i < this.num; i++) { ctx2.drawImage(this.orange, this.x[i] - this.orange.width * 0.5,this.y[i] - this.orange.height * 0.5); } console.log("画果实执行"); } fruitObj.prototype.born=function(i){ var aneID =Math.floor(Math.random()*ane.num); this.x[i]=ane.x[aneID]; this.y[i]=canHeight - ane.height[aneID]; console.log("果实出生执行"); }
求大神指点
举报