Jump to content

Collision problems


Recommended Posts



I'm currently working on a game and i came across with a problem. Today i was merging new changes into the project and the collisions stop working... 

The changes were:

  • Add audio/music
  • Delete some comments
  • Change minor things

I'm managing the collisions this way:

this.physics.collide( this.player, this.zombies, this.collisionHandler, null, this);

The collision handler:

/** * Manage the collision between the player and the enemies * @param obj1 PhaserSprite  * @param obj2 PhaserGroup  * @returns void */collisionHandler : function( obj1, obj2 ) {	/*	console.clear();	console.log("%c-- Colision Between Player And Zombie --", "color: red; font-size: 18px");	console.debug(obj1);	console.debug(obj2);	*/	if( obj2.type === 'zombie' ) 	{		// Games end		this.gameEnded = true;		// Stoping zombies		for( var i = 0; i < this.zombiesCount; i++ ) {			var currZombie = this.zombiesManager[i].spr;			if( currZombie ) 			{				currZombie.body.velocity.x = 0;				currZombie.body.velocity.y = 0;			}		}		// Calling Game over		this.onGameover();	}},

I don't even know how to start debugging this error. The dev console doesn't show the collision or errors.

Is there any reported bug where the collisions suddenly stop working?


Overlap isn't working either :( I can't figure out why the collisions are deactivated...

this.zombies.forEach(function(collectible){	if(this.game.physics.overlap(this.player,collectible))	{		this.collisionHandler(this.player, collectible);	}}); 

Thanks in advance.

Edited by programlocura
Link to comment
Share on other sites


  • Recently Browsing   0 members

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