Jump to content

ArcadePhysics Overlap


hyperion
 Share

Recommended Posts

Hi, 

 

First of all;

I'm using Phaser 2.0.0, I have two sprite groups, "newspaper" and "home" and I'm moving the home group with clockwise movement of mouse.

I do "game.physics.arcade.enable(sprite);" thing for all sprites in these groups.

 

When i'm trying detect overlap with this code, 

this.physics.arcade.overlap(this.newspaper, this.homes, (newspaper, home) => {                            if (newspaper.name == 'newspaper' && home.name == 'newspaper') {                                newspaper.name = '';                                home.name = '';                                this.money += 1;                            }                        });

It doesn't work :(

 

When i'm trying Phaser 1.1.6, it works but i can't use Phaser 1.1.6..

 

How i can solve this problem ASAP?

 

Thx for answers

Link to comment
Share on other sites

Try adding a 

this.newspaper.forEachAlive(function(newspaper){    game.debug.body(newspaper);});this.homes.forEachAlive(function(home){    game.debug.body(home);});

to your update function to see if the bodies are actually colliding and not reporting it.

 

Also, are you enabling physics on the group itself? What I did to make it work was, instead of enabling physics on each sprite individually, I just called:

game.physics.arcade.enable(this.newspaper);game.physics.arcade.enable(this.homes);

Right after populating all the sprites to the group. 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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