I am working on some effects tied to Lemur’s styling when I bumped into an npe when trying to access the effect info passed during effect.create()
public void simpleInitApp() {
GuiGlobals.initialize(this);
Styles styles = GuiGlobals.getInstance().getStyles();
Attributes attrs;
attrs = styles.getSelector("button", "test");
Effect testEffect = new AbstractEffect(){
@Override
public Animation create(Object t, EffectInfo ei) {
System.out.println("Effect Info: "+ei);
System.out.println("Here is the npe: "+ei.toString());
return new TweenAnimation(Tweens.delay(0));
}
};
Map<String, Effect> buttonEffects = new HashMap<>();
buttonEffects.put(Button.EFFECT_PRESS, testEffect);
attrs.set("effects", buttonEffects);
//test button
Button testButton = new Button("Test", "test");
testButton.setLocalTranslation(cam.getWidth()/2, cam.getHeight()/2, 0);
guiNode.attachChild(testButton);
}
This is the console
:run
Effect Info: null
Jan 01, 2020 1:05:24 AM com.jme3.app.LegacyApplication handleError
SEVERE: Uncaught exception thrown in Thread[jME3 Main,5,main]
java.lang.NullPointerException
at test.TestEffect$1.create(TestEffect.java:43)
at com.simsilica.lemur.effect.EffectControl.runEffect(EffectControl.java:134)
at com.simsilica.lemur.effect.EffectControl.runEffect(EffectControl.java:115)
at com.simsilica.lemur.Panel.runEffect(Panel.java:363)
at com.simsilica.lemur.Button.setPressed(Button.java:349)
at com.simsilica.lemur.Button$ButtonMouseHandler.mouseButtonEvent(Button.java:427)
at com.simsilica.lemur.event.MouseEventControl.mouseButtonEvent(MouseEventControl.java:122)
at com.simsilica.lemur.event.PickEventSession.buttonEvent(PickEventSession.java:693)
at com.simsilica.lemur.event.MouseAppState.dispatch(MouseAppState.java:98)
at com.simsilica.lemur.event.MouseAppState$MouseObserver.onMouseButtonEvent(MouseAppState.java:114)
at com.jme3.input.InputManager.processQueue(InputManager.java:841)
at com.jme3.input.InputManager.update(InputManager.java:917)
at com.jme3.app.LegacyApplication.update(LegacyApplication.java:724)
at com.jme3.app.SimpleApplication.update(SimpleApplication.java:246)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:151)
at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:197)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:232)
at java.lang.Thread.run(Thread.java:748)
Ultimately I was trying to use 1 effect object for multiple effect keys (ie effect_press & effect_release) similar to how the glass style handles button commands. I realize that probably isn’t the best practice for effects but this seemed like a bug regardless.