Jump to content

Help destroy sprite with phaser 2.0


Learning By Doing
 Share

Recommended Posts

I am

 

this is an example of my code:

var player;MyGame.Game.prototype = {    create: function () {        this.game.physics.startSystem(Phaser.Physics.ARCADE);        this.game.physics.setBoundsToWorld();        player = this.game.add.sprite(150, 150, 'player');        this.game.physics.enable(player, Phaser.Physics.ARCADE);        player.checkWorldBounds = true;        player.events.onOutOfBounds.add(this.restartGame, this);        player.outOfBoundsKill = true;        player.enableBody = true;        player.body.gravity.y = 1000;    },    update: function () {    },    restartGame: function () {        player.destroy();        this.game.state.start('MainMenu');    },        render: function () {        this.game.debug.text('Childrens: ' + this.game.world.children.length, 40, 820);    },};
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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