owen Posted January 6, 2015 Share Posted January 6, 2015 Hi Sorry if this seems ridiculously easy but I'm stuck. I am successfully drawing a rectangle in the canvas as per the official example:http://examples.phaser.io/_site/view_full.html?d=geometry&f=rectangle.js&t=rectangle But I need to delete it too and cannot see a way of doing that. How can I delete a rectangle that I have created? Ideally I want to properly destroy it, rather than set visible to false or size to zero. ThanksOwen Link to comment Share on other sites More sharing options...
owen Posted January 9, 2015 Author Share Posted January 9, 2015 Still no answer to this but thought I would post an update here. Just wanted to say that I have worked around the problem by setting width and height to 0, thus making the rectangle 'invisible' however it would be cleaner if there was a proper delete method for shapes. I am sure there is one but I cannot find it. ThanksOwen Link to comment Share on other sites More sharing options...
Ivanops Posted December 15, 2015 Share Posted December 15, 2015 Phaser rectangle must not be rendered its reference just set it to null it and that's it Link to comment Share on other sites More sharing options...
in mono Posted December 15, 2015 Share Posted December 15, 2015 What you're doing is a way to debug geometry, not to render an object for normal game use. It would be useful during development if you want for example to see how big a sprite with transparent pixels really is. If you want to draw a rectangle or another simple shape, better see this example. It lets you create a sprite and when you're finished with it, you can just call sprite.destroy()and you're done with it. Link to comment Share on other sites More sharing options...
Recommended Posts