Missing screen binding for custome effect

hello,

I try to implement a custom effect, it works nice,
but is there a way to provide the current screen to the effect???
so far I have to use a global static variable

public class CustomEffect implements EffectImpl 
{
    private static Screen screen;  
  
    public static void Init(Screen _screen) 
    {
        screen=_screen;
    }
  
    public void activate(final Nifty nifty, final Element element, final EffectProperties parameter)
    {
        String state = parameter.getProperty("state");
        if(state!=null)
        {
          Element background=element.findElementByName("#background");
          NiftyImage image = nifty.getRenderEngine().createImage(screen,fileName, false); << needs screen
          final ImageRenderer imageRenderer = background.getRenderer(ImageRenderer.class);
          imageRenderer.setImage(image);
        }
    }

    public void execute(final Element element,final float normalizedTime,final Falloff falloff,final NiftyRenderEngine r)
    {
    }

    public void deactivate() 
    {
    }
}

thanks

Why make it static? Just use a constructor?

well, the effect is defined in the xml, I cant put java there … !!!

<effect>
            <onStartHover name="customEffect" state="on" length="100" startDelay="0" inherit="true" neverStopRendering="false" />
            <onEndHover   name="customEffect" state="off" length="100" startDelay="0"  inherit="true" neverStopRendering="false" />
         </effect>

You can make: screen = nifty.getCurrentScreen(); on the activate method.

arf sh… How could I miss that one???, I thought FindScreenController(String) was the only access
my bad, thanks :slight_smile: