Jump to content

Phaser collide&overlap groupVSgroup not working


oxysoft
 Share

Recommended Posts

This does not work

this.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

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 be

this.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

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 be

this.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  :wacko:

 

I have edited the main post with the correct translated code

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...