Visibility on SceneObject and Sprite
oranjoose

Sprites (and TextSprites) both have setVisible and isVisible methods, but SceneObjects only have the setVisible method. Granted, it just goes in and sets all the component sprites to visible or invisible, as a shorthand. 

But for the sake of consistency, would it not make sense to add an isVisible method to SceneObjects? Maybe the function could take an optional parameter to check if only one component sprite of the sceneobject is visible versus if all component sprites are visible, where the default would be to check if at least one component sprite is visible.

IMHO, it is generally expected that any object with a property setter would have a respective getter for the same property.

All 2 Comments
foxcode

Hi oranjoose

I actually had a similar situation recently, I think it's a good idea. You are right of course that it makes sense to have a getter when you can have a setter. Your idea for returning visible so long as a single sprite is visible makes sense to me. The only complication I can think of is if you have a scene object with sprites on different layers. The return value may be confusing if a whole layer is being hidden but the sprite is technically visible in the object or something similar occurs.

I consider my above example to be sufficiently rare though that we probably should have a getter for it. Will poke my boss about it in the morning :)

 

oranjoose

It looks like version 3.3 has given SceneObject's the isVisible function. I'm writing this here in case anyone in the future stumbles onto this thread, so that they know the more up-to-date information. Thanks for the update!

On a related note, and maybe I should make a separate thread for this, but currently when you set an object to be invisible in the properties panel of the editor, it makes it completely transparent in the editing pane. There are probably times where you would want an object to be completely transparent in the editor, but in my experience it is more often that someone would still want to be able to see the invisible object in the editor (of course, the object would be invisible at runtime), so that they can still select, resize, and scale it from the editing window. A common example is if a developer wanted to create a bunch of invisible checkpoint hit boxes in a level. Hunting them down in the Scene outliner would be tedious.

Post a reply
Add Attachment
Submit Reply
Login to Reply