Jump to content

Killing a grouped laser is also killing my enemy?


Recommended Posts

Hey guys, 


On collision between an enemy and a laser (within a group) I kill the laser but the enemy is also being killed. Bug or something I'm doing wrong?


Laser.prototype.update = function() {game.physics.collide(this._laserGroup, layer, laserLayerCollideHandler, null, this);game.physics.collide(this._laserGroup, jumperBot._sprite, laserJumperBotCollideHandler, null ,this);} // end updatefunction laserLayerCollideHandler(laser, layer) {laserExplode(laser, layer, this);}function laserJumperBotCollideHandler(laser, jumperBot) {laserExplode(laser, jumperBot, this);}function laserExplode(laser, target, context) {if ( laser.body.touching.right ) {context._laserEmitter.x = laser.x + (laser.body.width );context._laserEmitter.y = laser.y;context._laserEmitter.maxParticleSpeed.x = -550;context._laserEmitter.start(true, 200, null, 5);} else if ( laser.body.touching.left ) {context._laserEmitter.x = laser.x;context._laserEmitter.y = laser.y;context._laserEmitter.maxParticleSpeed.x = 550;context._laserEmitter.start(true, 200, null, 5);}laser.kill();}

My repo:



Thanks guys, you're the best!


Link to comment
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.

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.


  • Recently Browsing   0 members

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