Jump to content

Need to delete a rectangle that I created


owen
 Share

Recommended Posts

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.

 

Thanks

Owen

 

 

Link to comment
Share on other sites

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.

 

Thanks

Owen

Link to comment
Share on other sites

  • 11 months later...

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

 Share

  • Recently Browsing   0 members

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