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

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...
 Share

  • Recently Browsing   0 members

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