phaserjs / phaser

Phaser is a fun, free and fast 2D game framework for making HTML5 games for desktop and mobile web browsers, supporting Canvas and WebGL rendering.
https://phaser.io
MIT License
36.94k stars 7.08k forks source link

Phaser.Physics.Arcade.Body has no `destroy` method #573

Closed gabehollombe closed 10 years ago

gabehollombe commented 10 years ago

Lines 542-545 of src/gameobjects/Sprite.js call this.body.destroy(), but Phaser.Physics.Arcade.Body has no destroy function defined. How should we destroy Arcade bodies? I'm happy to write the PR myself with some guidance.

    if (this.body)
    {
        this.body.destroy();
    }

Simple reproduction via JSFiddle here: http://jsfiddle.net/fekhZ/1/

bojank commented 10 years ago

If you set Sprite.exists to false it will also set Sprite.visible to false and remove its body from the physics world (if it has one). If you set Sprite.exists to true it will also set Sprite.visible to true and add its body back into the physics world (if it has one).

this is in the v2 thats is under development

photonstorm commented 10 years ago

Please don't submit a PR as this is already fixed in the dev branch!

gabehollombe commented 10 years ago

Thanks for the heads up, @photonstorm. =-)