Hello!
Im developing now a 2D Gui (MENU)
is a main menu, then i have 2 textures for each button, one normal and other focused


Then i need set the normal texture, and when one button is focused (my stuff) enable the flash texture (focused)
Then, i ask about what is the better way for make it in jME:
two TextureState maybe? how disable one and enable other? i look the TextureState javadoc for this, but really dont see any.
now im my current code only have implemented the texture of the idle.
final TextureState ts = display.getRenderer().createTextureState();
ts.setTexture(t);
quad.setRenderState(ts);
You can't disable textures, you should probably just switch the texture that is set on the TextureState when needed.
Thanks!
for the community: this is my Button class with focus feature.
Thanks again
public class Button extends Quad {
final private Texture idleTexture;
final private Texture focusTexture;
private boolean focus;
public Button(String name, int width, int height,
String idleTextureFn, String focusTextureFn) {
super(name, width, height);
DisplaySystem display = DisplaySystem.getDisplaySystem();
// TODO this.setRenderQueueMode(Renderer.QUEUE_ORTHO);
// Load TextureStates and Textures
this.idleTexture = TextureManager.loadTexture(
Button.class.getClassLoader().getResource(idleTextureFn),
Texture.MinificationFilter.BilinearNearestMipMap,
Texture.MagnificationFilter.Bilinear);
this.focusTexture = TextureManager.loadTexture(
Button.class.getClassLoader().getResource(focusTextureFn),
Texture.MinificationFilter.BilinearNearestMipMap,
Texture.MagnificationFilter.Bilinear);
TextureState ts = display.getRenderer().createTextureState();
this.setRenderState(ts);
this.setFocus(false);
}
public void setFocus(boolean value) {
if (value) {
TextureState ts = (TextureState) this.getRenderState(RenderState.RS_TEXTURE);
ts.setTexture(this.focusTexture);
}
else if (!value) {
TextureState ts = (TextureState) this.getRenderState(RenderState.RS_TEXTURE);
ts.setTexture(this.idleTexture);
}
this.focus = value;
}
}