Colon Posted December 7, 2018 Share Posted December 7, 2018 Hi, I am trying to organize my game, and try to collect some functions in an extra file so I dont need to rewrite them in every state. I am trying to convert this: world.js update: function() { this.game.physics.arcade.overlap(this.player, this.items, this.collect, null, this); } collect: function(player, collectable) { console.log('melon'); collectable.destroy(); }, to this: world.js update: function() { this.game.physics.arcade.overlap(this.player, this.items, collect(this.player, this.items), null, this); } functions.js function collect(player, collectable) { console.log('melon'); collectable.destroy(); } So what happens when I run my game with that is that the collect function is in an infinite loop, even if I dont overlap the item. Can you tell my why it is doing that and how I can fix that? Thanks, Colon Link to comment Share on other sites More sharing options...
samme Posted December 7, 2018 Share Posted December 7, 2018 this.game.physics.arcade.overlap(this.player, this.items, collect, null, this); Colon 1 Link to comment Share on other sites More sharing options...
Colon Posted December 7, 2018 Author Share Posted December 7, 2018 nice! Thanks so much. Link to comment Share on other sites More sharing options...
Recommended Posts