Jump to content

Physics overlap failing when adding a new group


mariogarranz
 Share

Recommended Posts

I have a number of groups in my game. These are all created at the create function of my game:

 

function create() {  game.stage.backgroundColor = '#7ACBE6';        // Activar registro de la actividad del ratón        game.input.recordPointerHistory = true;        game.input.recordRate = 20;        game.input.recordLimit = 10;if(!game.device.desktop){game.stage.scaleMode = Phaser.StageScaleMode.SHOW_ALL;game.stage.scale.setShowAll();game.stage.scale.refresh();}contador = game.time.now;        game.add.sprite(0,0,'background');        fallingFoodGroup = game.add.group();        game.add.sprite(0,0,'topBar');        game.add.sprite(0,404,'table');        dishesGroup = game.add.group();        plateFoodGroup = game.add.group();        var separacionPlatos = (game.world.width - 2 * PLATO_MARGEN - 3 * 75) / 2;dishesGroup.add(new Plato(game,PLATO_MARGEN, PLATO_ALTURA));        dishesGroup.add(new Plato(game,PLATO_MARGEN + 75 + separacionPlatos, PLATO_ALTURA));        dishesGroup.add(new Plato(game,PLATO_MARGEN + 2 * (75 + separacionPlatos), PLATO_ALTURA));        draggedFoodGroup = game.add.group();}

 

Then, at the update loop, I have this physics call which looks for overlaps between 2 of those groups.

game.physics.overlap(draggedFoodGroup,dishesGroup,alimentoPlatoHandler,null,this);

Everything was working fine, until I added another group.

Just adding this line at the end of the create funciton:

comandaGroup = game.add.group();

will cause the game to crash with the following error:

 

  1. Uncaught TypeError: Cannot read property 'exists' of undefined phaser.min.js:10
    1. d.Physics.Arcade.overlapGroupVsGroupphaser.min.js:10
    2. d.Physics.Arcade.overlapphaser.min.js:10
    3. d.StateManager.updatephaser.min.js:4
    4. d.Game.updatephaser.min.js:5
    5. d.RequestAnimationFrame.updateRAFphaser.min.js:8
    6. window.requestAnimationFrame._onLoopphaser.min.js:8

 

 

game.js:117 is the line that checks for overlaps between 2 groups mentioned earlier.

Either removing the new group creation, or the overlap check will make the game work just fine. But having both of them added at the same time will cause that error.

 

Note that I'm not even adding sprites to the new group. Just adding the group causes the crash.

Got absolutely no idea on what may be causing this. Is there a group limit? I don't think 5 groups is too much, is it?

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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