I used function() as class and I create some propeties using this. scope:
function field(newMaxX, newMaxY) {
this.maxX = newMaxX;
this.maxY = newMaxY;
}
But this caused this error:
Uncaught TypeError: Cannot set property 'maxX' of undefined
I have already write project with same using of function without error.
function snake(nX, nY, nScore, nDirection, maxX, maxY, cellSize) {
this.cells = [];
this.score = nScore;
...
}
Also JQuery points out at this problem:
jQuery.Deferred exception: Cannot set property 'maxX' of undefined TypeError: Cannot set property 'maxX' of undefined
I don't know how to fix that. Please help.
snakefunction with thenewkeyword somewhere or applying the context via.call,.apply, or.bindmethods? I think you need to edit and provide more information. (as an aside, if you're declaring a class, I'm talking aboutsnake, it's best practice to captialize the name, e.g.function Snake(){})