Sign in to follow this  
programlocura

Collision problems

Recommended Posts

Hi!

 

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

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.