Сначала я определил такой класс:
function mapTile(nx,ny)
{
//members
this.x = nx;
this.y = ny;
//methods
this.prototype.visible = function(){return true;};
this.prototype.getID = function(){return y*tiles_per_line+x;};
this.prototype.getSrc = function(){return 'w-'+this.getID+'.png';}
};
Что вызывает исключение, когда я пытаюсь создать объект:
t=new mapTile(1,1)
TypeError: Cannot set property 'visible' of undefined
в Chromium и молча терпит неудачу в Firefox (с firebug)
Это работает нормально, хотя:
function mapTile(nx,ny)
{
//members
this.x = nx;
this.y = ny;
};
//methods
//this.prototype.xx=1;
mapTile.prototype.visible = function(){return true;};
Как правильно реализовать методы-прототипы внутри тела?