I often see Javascript code where this
is assigned to a variable to be used to refer to the current instance of the object.
var me = this;
me.someproperty_or_method
why are they coding like that? ? Here is a more complete code snippet,
var Preload = function(game){};
Preload.prototype = {
init: function() {
var me = this;
var style = {
font: "32px Arial",
fill: "ffffff",
align: "center"
};
this.text = this.add.text(me.game.world.centerX, me.game.world.centerY, "Loading: 0%", style);
this.text.anchor.x = 0.5;
}
preload: function(){
this.game.load.text('dictionary', 'assets/dictionary.txt');
},
create: function(){
this.game.state.start("Main");
}
}
I'm pretty sure this not a duplicate, the answers given on other posts are not definitive.