This project is read-only.

Hiding / showing objects

To hide an object use the following:

obj.hide();
To show an object use the following:

obj.show();
To query the hidden state of any object use the following:

var hidden = obj.hidden;
It is also possible to permanently remove an object from a scene. To do this use the following:

obj.destroy();
Destroying and re-adding an object can be resource-consuming compared to hiding and reshowing an object. Thus it is reasonable to use an object-pool with a couple of hidden objects if certain types of objects can appear and disappear in the scene from time-to-time. A good example for this would be rockets launched by a character: a rocket is typically a SheetObject because it can move around and a character can fire multiple rockets that later explode (disappear). In this case it is better to create a number of rockets, hide them, and when the character fires take one rocket, show it and reposition it to the start location, than to destroy it and add it to the scene every time.

Last edited Dec 11, 2012 at 2:56 AM by dobsonl, version 1

Comments

No comments yet.