yltang Posted December 11, 2015 Share Posted December 11, 2015 How do I pass arguments to a callback function? For example:var main = { ... create: function () { this.cursor = game.input.keyboard.createCursorKeys(); }, update: function() { game.physics.arcade.collide(this.player, this.platforms, null, this.ignoreCollision); }, ignoreCollision: function(player, platform) { if (this.cursors.down.isDown) { return false; } return true; },}'this.cursors' is undefined. I guess I have to pass 'this' to 'ignoreCollision'. How do I do that? Link to comment Share on other sites More sharing options...
Skeptron Posted December 11, 2015 Share Posted December 11, 2015 Doc : http://phaser.io/docs/2.4.4/Phaser.Physics.Arcade.html#collide callbackContext ("this" or whatever your context is) is the last argument. yltang 1 Link to comment Share on other sites More sharing options...
yltang Posted December 11, 2015 Author Share Posted December 11, 2015 Got it. Thanks a lot. Link to comment Share on other sites More sharing options...
Recommended Posts