You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm starting out with Mini2Dx.
I'm creating this UI, where the player has to set some numbers, but I wanted to have a default value. So I set it. But it doesn't appear. It only appears in the TextBox if I insert another character (while the game is running).
This is what I'm trying:
// text box
textBox = new TextBox(20, 50, 50, 20);
textBox.setVisibility(Visibility.VISIBLE);
textBox.setValue("5");
Full example (this is the only file I changed from a generated game.
MyMini2DxGame.java
package com.mystudio.gamename;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.assets.AssetManager;
import com.badlogic.gdx.assets.loaders.FileHandleResolver;
import com.badlogic.gdx.assets.loaders.resolvers.ClasspathFileHandleResolver;
import com.badlogic.gdx.assets.loaders.resolvers.InternalFileHandleResolver;
import com.badlogic.gdx.graphics.Texture;
import org.mini2Dx.core.assets.FallbackFileHandleResolver;
import org.mini2Dx.core.game.BasicGame;
import org.mini2Dx.core.graphics.Graphics;
import org.mini2Dx.ui.UiContainer;
import org.mini2Dx.ui.UiThemeLoader;
import org.mini2Dx.ui.element.TextBox;
import org.mini2Dx.ui.element.Visibility;
import org.mini2Dx.ui.style.UiTheme;
public class MyMini2DxGame extends BasicGame {
public static final String GAME_IDENTIFIER = "com.mystudio.gamename";
private AssetManager assetManager;
private Texture texture;
private UiContainer uiContainer;
private TextBox textBox;
@Override
public void initialise() {
// UI
//Create fallback file resolver, so we can use the default mini2Dx-ui theme
FileHandleResolver fileHandleResolver = new FallbackFileHandleResolver(new ClasspathFileHandleResolver(),
new InternalFileHandleResolver());
//Create asset manager for loading resources
assetManager = new AssetManager(fileHandleResolver);
//Add mini2Dx-ui theme loader
assetManager.setLoader(UiTheme.class, new UiThemeLoader(fileHandleResolver));
//Load default theme
assetManager.load(UiTheme.DEFAULT_THEME_FILENAME, UiTheme.class);
uiContainer = new UiContainer(this, assetManager);
Gdx.input.setInputProcessor(uiContainer);
texture = new Texture("mini2Dx.png");
// text box
textBox = new TextBox(20, 50, 50, 20);
textBox.setVisibility(Visibility.VISIBLE);
textBox.setValue("5");
uiContainer.add(textBox);
}
@Override
public void update(float delta) {
// UI
if(!assetManager.update()) {
//Wait for asset manager to finish loading assets
return;
}
if(!UiContainer.isThemeApplied()) {
UiContainer.setTheme(assetManager.get(UiTheme.DEFAULT_THEME_FILENAME, UiTheme.class));
}
uiContainer.update(delta);
}
@Override
public void interpolate(float alpha) {
uiContainer.interpolate(alpha);
}
@Override
public void render(Graphics g) {
g.drawTexture(texture, 0f, 0f);
uiContainer.render(g);
}
}
Hello,
I'm starting out with Mini2Dx.
I'm creating this UI, where the player has to set some numbers, but I wanted to have a default value. So I set it. But it doesn't appear. It only appears in the TextBox if I insert another character (while the game is running).
This is what I'm trying:
Full example (this is the only file I changed from a generated game.
MyMini2DxGame.java
Full project:
mini2dxtest.zip
Thanks in advance for any help.
The text was updated successfully, but these errors were encountered: