1 decade ago by benjtupas
I've been using the keyword get and set of JavaScript but I don't think that I'm implementing it correctly. I think there's a problem when implemented inside an ImpactJS class. Here's a snippet of the code:
I've done series of tests and the results are not as expected.
ig.module(
'core.data.slotgamedata'
).requires(
).defines(function(){
// Create a new singleton SlotGameData
SlotGameData = ig.Class.extend({
staticInstantiate: function() {
if( SlotGameData.instance == null ) {
return null;
}
else {
return SlotGameData.instance;
}
},
init : function() {
SlotGameData.instance = this
},
_maxWinnings: -1,
get maxWinnings() {
return this._maxWinnings;
},
setMaxWinnings : function( value ) {
this._maxWinnings = value;
}
});
SlotGameData.instance = null;
});
I've done series of tests and the results are not as expected.
console.log( this.sgd.maxWinnings ); // returns -1 console.log( this.sgd.setMaxWinnings( 999 ) ); // returns undefined and should 999 console.log( this.sgd.maxWinnings ); // returns -1 and should 999
