I’m trying to make a custom effect for Nifty Gui:
public class ContractEffect implements EffectImpl {
private float size;
@Override
public void activate(Nifty nifty, Element element, EffectProperties parameter) {
size = element.getWidth();
}
@Override
public void execute(Element element, float effectTime, Falloff falloff, NiftyRenderEngine r) {
element.setWidth((int)(size - (size * effectTime)));
}
@Override
public void deactivate() {
}
}
And use it with:
<registerEffect name="contractEffect" class="mygame.ContractEffect" />
The element have this:
<effect>
<onActive name="fade" start="#f" end="#8"/>
<onHover name="fade" start="#8" end="#f"/>
<onClick name="contractEffect" length="750"/>
</effect>
I want it to start when I click an element and end it when the “length” time is ended but all my onClick
effects are stopped when I stop pressing the element. I tried to comment the other two effects (they work as I want) but it have the same issue.