oxysoft Posted August 25, 2014 Share Posted August 25, 2014 This does not workthis.game.physics.arcade.collide(this.vehicles, this.citizens, function(e1, e2) { if (Math.max(e1.body.velocity.x, e1.body.velocity.y) > 15) e2.ranOver(e1)}, null, this)But this obviously does (not a group)this.game.physics.arcade.collide(this.truck, this.citizens, function(e1, e2) { if (Math.max(e1.body.velocity.x, e1.body.velocity.y) > 15) e2.ranOver(e1)}, null, this)The same results with overlap I'm using Phaser 2.0.7, though it shouldn't matter. Any reason why this is not working? Link to comment Share on other sites More sharing options...
bryanbibat Posted August 25, 2014 Share Posted August 25, 2014 I'm guessing it's because you didn't set the parameters in the callback i.e.this.game.physics.arcade.collide(this.vehicles, this.citizens, function() {should bethis.game.physics.arcade.collide(this.vehicles, this.citizens, function(e1, e2) {Your sprite vs group example may be working because you set the e1 and e2 variables within the parent scope. Link to comment Share on other sites More sharing options...
oxysoft Posted August 25, 2014 Author Share Posted August 25, 2014 I'm guessing it's because you didn't set the parameters in the callback i.e.this.game.physics.arcade.collide(this.vehicles, this.citizens, function() {should bethis.game.physics.arcade.collide(this.vehicles, this.citizens, function(e1, e2) {Your sprite vs group example may be working because you set the e1 and e2 variables within the parent scope. My bad, that's my fault; I write my code in coffeescript and translate it to js when I post here. I actually do have e1 and e2 defined I have edited the main post with the correct translated code Link to comment Share on other sites More sharing options...
oxysoft Posted August 25, 2014 Author Share Posted August 25, 2014 Nevermind this thread, it turns out that I was adding my vehicle into citizens for a test earlier today, I guess I forgot to change it back. Such a dumb mistake cost me like an hour, not very good for ludum dare Link to comment Share on other sites More sharing options...
Recommended Posts