The IgnoresParentVisibility property controls whether an IVisible instance's visibility is impacted by its parent's visibility. If an IVisible doesn't have a parent, then the IgnoresParentVisibility property has no impact. IgnoresParentVisibility defaults to false, meaning that parent visibility impacts a child's visibility. Setting this value to true makes an IVisible's Visible property ultimately determine whether it appears on screen.
The following example creates four Sprites. Two of the Sprites are parents, two are children of their respective parent. spriteChildB has its IgnoresParentVisibility set to true, meaning it will still be visible desipite its parent being invisible. Since spriteParentA is invisible, spriteChildA will also be invisible.
The IVisible interface is an interface which defines that an object must have a Visible property. Setting Visible to true or false will make the object appear or disappear visually. Most visual FlatRedBall types implement the IVisible property including:
The following code shows how to toggle a Sprite's visibility when the mouse is clicked:
The Visible property on an IVisible controls whether an object will be drawn, but it also controls whether all of its children will be drawn. Therefore, if an object (such as a Glue Entity) implements IVisible, and if its Visible is set to false, then all attached objects will also be invisible. This behavior simplifies making UI objects (such as Pause menus) which many be made up of multiple levels of UI elements.
This behavior can be modified through the IgnoresParentVisibility property.
Did this article leave any questions unanswered? Post any question in our forums for a rapid response.