Hi,
I’ve noticed that sounds are not reproduced if the effect is defined in an element inside a popup. The sound is properly played in the screen and also other effects in elements inside the popup are rendered.
I’ve implemented a simple test for this:
Main.java:
package mygame;
import com.jme3.app.SimpleApplication;
import com.jme3.niftygui.NiftyJmeDisplay;
import de.lessvoid.nifty.Nifty;
import de.lessvoid.nifty.elements.Element;
import de.lessvoid.nifty.screen.Screen;
import de.lessvoid.nifty.screen.ScreenController;
public class Main extends SimpleApplication implements ScreenController {
NiftyJmeDisplay niftyGui;
Element popup;
public static void main(String[] args) {
Main app = new Main();
app.start();
}
@Override
public void simpleInitApp() {
flyCam.setDragToRotate(true);
niftyGui = new NiftyJmeDisplay(getAssetManager(), getInputManager(), getAudioRenderer(), guiViewPort);
niftyGui.getNifty().fromXml("Interface/test.xml", "empty", this);
guiViewPort.addProcessor(niftyGui);
}
public void showTestPopup() {
popup=niftyGui.getNifty().findPopupByName("testPopup");
if(popup==null)
{
popup=niftyGui.getNifty().createPopupWithId("testPopup", "testPopup");
}
niftyGui.getNifty().showPopup(niftyGui.getNifty().getCurrentScreen(), "testPopup", null);
}
public void hideTestPopup() {
if(popup!=null)
{
niftyGui.getNifty().getCurrentScreen().closePopup(popup, null);
popup=null;
}
}
@Override
public void bind(Nifty nifty, Screen screen) {
}
@Override
public void onStartScreen() {
}
@Override
public void onEndScreen() {
}
}
test.xml:
<?xml version="1.0" encoding="UTF-8"?>
<nifty xmlns="http://nifty-gui.lessvoid.com/nifty-gui" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://raw.githubusercontent.com/void256/nifty-gui/1.4/nifty-core/src/main/resources/nifty.xsd https://raw.githubusercontent.com/void256/nifty-gui/1.4/nifty-core/src/main/resources/nifty.xsd">
<useStyles filename="nifty-default-styles.xml" />
<useControls filename="nifty-default-controls.xml" />
<registerSound id="menuSelect" filename="Sounds/MenuSelect.ogg" />
<registerSound id="menuBack" filename="Sounds/MenuBack.ogg" />
<screen id="empty" controller="mygame.Main">
<layer id="GLayer0" childLayout="center">
<panel style="nifty-panel-red" childLayout="center" padding="18px,28px,40px,16px" width="100%" height="100%" align="center" valign="center">
<interact onClick="showTestPopup()" />
<effect>
<onHover name="colorPulsate" startColor="#f00f" endColor="#0f0f" startDelay="0" />
<onClick name="playSound" sound="menuSelect" />
</effect>
</panel>
</layer>
</screen>
<popup id="testPopup" childLayout="center" backgroundColor="#000a">
<panel style="nifty-panel-red" childLayout="center" padding="18px,28px,40px,16px" width="440px" height="250px" align="center" valign="center">
<panel childLayout="vertical" align="center" valign="center">
<panel childLayout="vertical" height="70%" width="100%">
<text text="Popup text" style="base-font" align="center" valign="center" color="#000f" wrap="true"/>
</panel>
<panel childLayout="horizontal" align="center" height="30%" width="100%" backgroundColor="#fd0f" >
<interact onClick="hideTestPopup()" />
<effect>
<onHover name="colorPulsate" startColor="#f00f" endColor="#0f0f" startDelay="0" />
<onClick name="playSound" sound="menuSelect" />
</effect>
</panel>
</panel>
</panel>
</popup>
</nifty>
Maybe a nifty issue?
Thanks
EDIT: I forgot to mention I’m using jme 3.2.1 SDK which includes nifty-1.4.3