babyObj.prototype.init = function () {
this.x = canWidth * 0.5;
this.y = canHeight * 0.5 ;
//this.babyEye.src = "src/babyEye0.png";
this.babyBody.src = "src/babyFade0.png";
this.angle = 0;
this.babyTailCount = 0;
this.babyTailTimer = 0;
for (var i = 0; i < 8; i++) {
this.babyTail[i] = new Image();
this.babyTail[i].src = "src/babyTail" + i + ".png";
}
this.babyEyeCount = 0;
this.babyEyeTimer = 0;
for (var i = 0; i < 2; i++) {
this.babyEye[i] = new Image();
this.babyEye[i].src = "src/babyEye" + i + ".png";
}
在baby对象中使用,就是私有属性,放到main中就是全局变量,就看你怎么使用了
说的好,同问