Hi All,
I am trying to setup a dynamic menu in nifty, so I creating the initial components in .xml, then setting up the dynamic parts in Java. The layout is working just fine, but I wanted to add an onHover effect, but it does not appear to work at all…
Here is an image of what I am making, just for you reference ( Debug coloring is enabled… ) This shows that I correctly get the panel from the .xml and setup the buttons correctly, only the pulsate effect is missing when I hover over the buttons…
In .xml I declare the popup window. The dynamic menu 10x10 buttons are later added to the “popupPanel” in java.
[xml]
<popup id=“popupExit” childLayout=“center” backgroundColor="#000a">
<!-- Fade the background to black -->
<effect>
<onStartScreen name=“fade” start="#0" end="#f" length=“300” />
<onEndScreen name=“fade” start="#f" end="#0" length=“300” />
</effect>
<interact onClick=“closePopup()” onSecondaryClick=“closePopup()” onTertiaryClick=“closePopup()” />
<panel id=“popupPanel” height=“662” width=“662” align=“center” valign=“bottom”
backgroundColor="#333b" childLayout=“absolute” visibleToMouse=“true”>
<text id=“popupText” x=“220” y="-15px" font=“aurulent-sans-16.fnt” color="#ffff" text=“MODULE SELECTION MENU” align=“center” valign=“center”/>
<!-- Fade the panel in and out -->
<effect>
<onStartScreen name=“move” mode=“in” direction=“bottom” length=“300” startDelay=“0” inherit=“true”/>
<onEndScreen name=“move” mode=“out” direction=“bottom” length=“300” startDelay=“0” inherit=“true”/>
<!–onHover name=“pulsate” scaleFactor=“0.008” startColor="#f600" endColor="#ffff" post=“true”/–>
<onStartScreen name=“fade” start="#0" end="#f" length=“300” />
<onEndScreen name=“fade” start="#f" end="#0" length=“300” />
</effect>
</panel>
</popup>
[/xml]
In Java I do the following to setup the 10 x 10 grid and add the pulsate effect:
[java]
private void setupPopup( Element popup ){
// Get the panel
Element back = popup.findElementByName(“popupPanel”);
assert( back == null ) : “Could not find ‘popupPanel’ from .xml file!”;
// Declare the onHover effect:
final HoverEffectBuilder builder = new HoverEffectBuilder(“pulsate”){{
this.effectValue(“scaleFactor”,“0.008”);
this.effectValue(“startColor”,"#f600");
this.effectValue(“endColor”,"#ffff");
this.post( true );
}};
// Add a 10 x 10 grid on buttons.
for( int x = 0; x < 10; x++ ){
for( int y = 0; y < 10; y++ ){
final String x_pos = ( x * 66 + 2 ) + “px”;
final String y_pos = ( y * 66 + 2 ) + “px”;
Element icon = new PanelBuilder(“icon[”+x+"|"+y+"]") {{
childLayoutCenter();
valignCenter();
backgroundColor("#88f8");
x( x_pos );
y( y_pos );
height(“64px”);
width(“64px”);
onHoverEffect( builder );
}}.build( nifty, screen, back );
back.add( icon );
}
}
}
[/java]
I do get one warning in my console:
WARNING: class [jme3test.niftygui.TestNiftyGui] could not be instanziated (java.lang.ClassNotFoundException: jme3test.niftygui.TestNiftyGui)
I guess nifty is trying to use TestNiftyGui as the default controller, would that be a problem?