Hello, im trying use a BasicGameStateNode with BasicGameState childs
The problem is that add a full-screen size quad to rootNode, and later instance and attach a child gamestate, that he implement some other minors quads as buttons. and only can see the first full-screen size quad only, i cant see the buttons quad, then i try comment the buildBackround() method and surprise! i can see now all buttons, then i think that this buttons are drawing back the big background quad.
Why is this? what im doing bad?
This is my BasicGameStateNode
(Implement only a background, and later attach and active the children)
public class MenuState extends BasicGameStateNode <BasicGameState> {
public MenuState() {
super("menuState");
this.getRootNode().setRenderQueueMode(Renderer.QUEUE_ORTHO);
this.buildBackground();
MainMenuState mainMenuState = new MainMenuState();
this.attachChild(mainMenuState);
this.activateChildNamed("mainMenuState");
this.getRootNode().updateRenderState();
}
private void buildBackground() {
Texture t = TextureManager.loadTexture(
MainMenuState.class.getClassLoader()
.getResource("res/woodBckg.png"),
Texture.MinificationFilter.Trilinear,
Texture.MagnificationFilter.Bilinear);
Quad bckgQuad = new Quad("bckgQuad", 1024, 600);
TextureState ts = DisplaySystem.getDisplaySystem().getRenderer().createTextureState();
ts.setTexture(t);
bckgQuad.setRenderState(ts);
bckgQuad.setLocalTranslation(512, 300, 0);
this.getRootNode().attachChild(bckgQuad);
}
}
Children BasicGameState that implement minors quad buttons
public class MainMenuState extends BasicGameState {
private BlendState blendState;
private Button[] buttons;
private int focusedButton;
private TextureState font;
public MainMenuState() {
super("mainMenuState");
this.getRootNode().setRenderQueueMode(Renderer.QUEUE_ORTHO);
this.buildLogo();
this.buildButtons();
this.buildText();
this.getRootNode().updateRenderState();
}
private void buildLogo() {
Texture t = TextureManager.loadTexture(
MainMenuState.class.getClassLoader()
.getResource("res/gameLogo.png"),
Texture.MinificationFilter.Trilinear,
Texture.MagnificationFilter.Bilinear);
Quad logoQuad = new Quad("logoQuad", 512, 256);
TextureState ts = DisplaySystem.getDisplaySystem().getRenderer().createTextureState();
ts.setTexture(t);
logoQuad.setLocalTranslation(250, 450, 0);
logoQuad.setRenderState(ts);
this.getRootNode().attachChild(logoQuad);
}
private void buildButtons() {
// Create buttons
this.buttons = new Button[3];
this.buttons[0] = new Button("creditsButton", 256, 256,
"res/credits0.png", "res/credits1.png");
this.buttons[1] = new Button("quitButton", 256, 256,
"res/quit0.png", "res/quit1.png");
this.buttons[2] = new Button("newButton", 256, 256,
"res/new0.png", "res/new1.png");
// Set translations, attach and set focus
this.buttons[0].setLocalTranslation(300, 170, 0);
this.buttons[1].setLocalTranslation(600, 420, 0);
this.buttons[2].setLocalTranslation(860, 250, 0);
for (int i = 0; i < this.buttons.length; i++) {
this.buttons[i].setRenderState(this.blendState);
this.getRootNode().attachChild(this.buttons[i]);
}
this.buttons[2].setFocus(true);
this.focusedButton = 2;
}
}