yltang Posted September 1, 2015 Share Posted September 1, 2015 I am a newbie for Phaser and am following the Phaser documentation "collect stars". There is one statement: game.physics.arcade.overlap(obj1, obj2, overlapCallback, processCallback, callbackContext); I wonder what "callbackContext" means and how to provide a proper value for it? The tutorial uses "this" (again, what does this mean?), however, giving it "null" is also OK. Can anybody shed some light on it? Thanks Link to comment Share on other sites More sharing options...
rich Posted September 1, 2015 Share Posted September 1, 2015 It's the execution context in which your callbacks will be invoked (it's a JavaScript thing, not a Phaser thing, just in case you want to read-up more on it) VitaZheltyakov, yltang, netcell and 1 other 4 Link to comment Share on other sites More sharing options...
yltang Posted September 3, 2015 Author Share Posted September 3, 2015 Thanks, but do we always give it the value "this"? If that's the case, wouldn't it be redundant? As I mentioned, I tried to use "null" and everthing worked just fine. Why? Link to comment Share on other sites More sharing options...
rich Posted September 3, 2015 Share Posted September 3, 2015 If your game is using a single state running out of the global scope, then 'null' will work fine. As soon as you move on to using more complex set-ups (i.e. properly split game states) it'll no longer work. There are lots of cases where 'this' doesn't work as the context. You just won't encounter them in the examples because we boil it down to the most simplest form it can be. yltang 1 Link to comment Share on other sites More sharing options...
yltang Posted September 4, 2015 Author Share Posted September 4, 2015 Got it. Thanks a lot. Link to comment Share on other sites More sharing options...
Recommended Posts