Currently, I am utilizing simple JavaScript objects that contain functions and members. One recurring issue I encounter is having to append the this
keyword every time I access a member or function.
Adding this
repeatedly can be tedious, so I am seeking ways to circumvent the need for it before each member variable or function call.
For instance:
var MyClass = cc.LayerColor.extend({
sprite:null,
stopGameLoop:false,
labelScore:null,
winSize:0,
visibleOrigin:0,
blocksList : [] ,
circle:null,
gameOverScreen:null,
circleblockY:0,
circleblockX:0,
blocksNum:0,
currentState:0,
zCount:0,
currentZorder:0,
iScore:0,
ctor:function () {
//////////////////////////////
// 1. super init first
this._super();
this.init( cc.color(255,255,255, 255) );
this.winSize = cc.winSize;
this.visibleOrigin = cc.director.getVisibleOrigin();
this.setGameOverScreen(this.blocksNum);
this.setLevel(this.circleblockY,this,circleblockX);
return true;
},
setLevel:function (a,b,c) {
},
setGameOverScreen:function (foo) {
},
});
Why am I constantly using this
?