Jump to content

Phaser Kill freezing game


Indenialgamer
 Share

Recommended Posts

Hi I have an issue in my game.js

 

these are snippets from the entire code where bullets and enemies overlap, but when they overlap the game crashes?: 

create : function(){

this.enemies = game.add.group();
        this.enemies.enableBody = true;

       for (var i = 0; i < 1; i++)
        {
         var s = this.enemies.create(game.world.randomX, game.world.randomY, 'enemy1');
        s.name = 'enemy1' + s;
        s.body.collideWorldBounds = true;
        s.body.bounce.setTo(0.1, 0.1);
            s.animations.add('walk', [0, 1,]);
        s.play('walk', 6, true);
        s.body.velocity.setTo(5 + Math.random() * 40, 5 + Math.random() * 40);
    }
    {
        var f = this.enemies.create(game.world.randomX, game.world.randomY, 'enemy2');
            f.name= 'enemy2' + f;
            f.body.collideWorldBounds = true;
        f.body.bounce.setTo(0.1, 0.1);
            f.animations.add('walk', [0, 1,]);
        f.play('walk', 6, true);
        f.body.velocity.setTo(5 + Math.random() * 40, 5 + Math.random() * 40);
    }

}

update: function() {
  
        game.physics.arcade.overlap(this.bullet, this.enemies, this.enemyKill, null, this);

 

enemyKill: function(){
  
  this.enemies.kill();
  this.score += 10;
  this.scoreText.text = 'score: ' + score;
  
},

 

 

Thanks

:D 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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