Learning By Doing Posted March 16, 2014 Share Posted March 16, 2014 Hello! I am having problems destroying a sprite, I get the following message:TypeError: this.body.destroy is not a function Can someone please help me? Link to comment Share on other sites More sharing options...
srikarg Posted March 16, 2014 Share Posted March 16, 2014 I don't think (YourSpriteName).body.destroy() exists. Try using (YourSpriteName).destroy(). Here's a reference: http://docs.phaser.io/Phaser.Sprite.html#destroy. Link to comment Share on other sites More sharing options...
Chupup Games Posted March 16, 2014 Share Posted March 16, 2014 Look this post: http://www.html5gamedevs.com/topic/4774-destroy-a-sprite/ Link to comment Share on other sites More sharing options...
Learning By Doing Posted March 16, 2014 Author Share Posted March 16, 2014 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 More sharing options...
Learning By Doing Posted March 16, 2014 Author Share Posted March 16, 2014 Look this post: http://www.html5gamedevs.com/topic/4774-destroy-a-sprite/ If I do: player.body = null;player.destroy(); I get the following message:TypeError: this._bindings is undefined Link to comment Share on other sites More sharing options...
rich Posted March 16, 2014 Share Posted March 16, 2014 Because you're doing it in a callback that is fired off the body object you're then nulling. Grab the dev branch, it's fixed in there. Will push live next week at some point. Link to comment Share on other sites More sharing options...
Learning By Doing Posted March 16, 2014 Author Share Posted March 16, 2014 Grab the dev branch, it's fixed in there. Will push live next week at some point. Stupid question maybe... But should I just get the phaser.min.js from the dev branch? Link to comment Share on other sites More sharing options...
rich Posted March 16, 2014 Share Posted March 16, 2014 No you have to build one from grunt. I'll upload a new min version tonight, check the commit log to see when I do it. Link to comment Share on other sites More sharing options...
Learning By Doing Posted March 16, 2014 Author Share Posted March 16, 2014 okay, thanks! Phaser is awesome! Link to comment Share on other sites More sharing options...
Recommended Posts