Transparency/Opacity/Alpha: Settings for individual Elements?

Is there a way of adjusting the opacity of individual Nifty Elements?



Thanks in advance… and… ummmm… hallo again. Been a while since I have been able to do anything with JME.

You can set the opacity of a colour for anything with a colour (i.e text, plain background colour, etc).



So far as I’ve found you can’t set the opacity of an image/panel other than that…although you can apply the fade effect at a fixed fade strength and neverStopRendering=“true”

1 Like
@zarch said:
You can set the opacity of a colour for anything with a colour (i.e text, plain background colour, etc).

So far as I've found you can't set the opacity of an image/panel other than that...although you can apply the fade effect at a fixed fade strength and neverStopRendering="true"


I considered the EffectManager (at least I assume this would be how you do it) ... but was hoping the Opacity setting was accessible per element as it will always be a fixed opacity. Have you noticed any performance issues doing it this way?

Honestly I’ve never done it that way. :slight_smile:



I design my UI elements at the transparency I use them and effects are only used for transitions. Effects seem reasonably fast though.

1 Like

Opacity in Nifty can only be applied to colors, not images (unless you use effects). That part is done in jME3. So just put your nifty stuff in its custom node in which you add the appropriate bucket (transparent, translucent, etc) then finally attach that node to the guiNode.



This shouldn’t pose any problem.

1 Like
@madjack said:
Opacity in Nifty can only be applied to colors, not images (unless you use effects). That part is done in jME3. So just put your nifty stuff in its custom node in which you add the appropriate bucket (transparent, translucent, etc) then finally attach that node to the guiNode.

This shouldn't pose any problem.


Are you saying that I can attach the elements to individual nodes in the GUI and set the transparency to the node itself? I hope I am reading this right... that would be a huge help!
@t0neg0d said:
Are you saying that I can attach the elements to individual nodes in the GUI and set the transparency to the node itself? I hope I am reading this right... that would be a huge help!


No, I think he's saying that for images, don't use nifty but just add pictures to the guiNode... then you have total control over opacity.
1 Like

After rereading your OP I’m wondering if you want to modify said transparency dynamically. If so, I don’t see how that could be done except by using a discrete system, like Paul suggested, i.e.: putting those images (as in Image class) on the gui node or any other node attached to the gui node.



But, if it’s just a matter of having an image with transparency, the default setup works fine. That can be seen in my preview window that has a hole in it (where the star is rendered).



Just to make sure I wasn’t spewing nonsense I checked my code and there’s no need to use a custom node for the above.



It’s a bit convoluted though.



I use a ScreensManager that effectively links the game with each screen; info will go to the current screen. That manager is an app state and when I instantiate it I pass the guiViewport. It’s to that viewport that I add the NiftyDisplay processor.



By default the niftyDisplay (NiftyJmeDisplay) supports transparency and images with transparency are correctly rendered.



Hopefully I’m not mudding the question/answer. :wink: