Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

1 decade ago by dmen

In my game class I instantiate an entity that has a button in it. The button, is supposed to call a method in the main game class that instantiated it... How can I do this so I keep scope in the game class? Right now I do like so:

this.spDialog.show('l1intro', 'back', this.buttonBack, this);

and then in the spDialog the show method goes like:

show: function(whichDialog, b1, b1Func, b1Context){

and then I assign the callback and context:

this.callback = b1Func;
this.scope = b1Context;

and then I try to do:

this.callback.call(this.scope);

The function gets called, but inside the function, this is not the original scope...

1 decade ago by dmen

Sorry, the callback with call was actually working fine. It was a different problem...
Page 1 of 1
« first « previous next › last »