I kinda understand that you can use Scene2d for a Hud or stuff like that, I'm new to Java and so far I've done games that update in real time like let's say Flappy bird (simple games), so i wanted to try something different and now I'm kinda stuck, instead of having all the level be decided at the start of the game i want to instead have a forward and backwards button (Visual Novel) that lets me update the screen on each click, the problem is that i don't know how to do it in a clean way, is there a way to update the button on real time or any technique to have an entire "dialog level" scripted? (sorry if this sounds confusing i don't know how to phrase it properly, if you have played or seen a visual novel you would understand what I'm talking about)

  • \$\begingroup\$ If someone has some example code it would help a ton, there's only unity tutorials on how to do visualnovels \$\endgroup\$
    – Darkly
    Commented Jan 29, 2016 at 0:03

1 Answer 1


Scene2d would probably be good to use for a visual novel, it's not limited to UI, you could design a whole game with it if you wanted to. You could make a scene2d stage and then add back and forward buttons to it. You could have several buttons that you change label on and use for selecting what your characters says/does. If you find something scene2d can't do, you can just do it yourself or extend one of it's classes. Scene2d actions are really cool.

This playlist does a good job of explaining scene2d, both for UI and for other stuff, and comes with example code linked. https://www.youtube.com/watch?v=DPIeERAm2ao&index=11&list=PLS9MbmO_ssyCZ9Tjfay2tOQoaOVoG59Iy

If you want branching dialog you probably want to implement some way of loading that into your game. I would look into json, that way you could write all your dialog in files that you can load into your game and you won't need to hardcode that stuff in.


This is what I used to load my maps in my last project: (removed getters and setters to save space)

ObjectMapper mapper = new ObjectMapper();
Level[] loadedLevels = new Level[20];
private int id = 0;
private String image = ("image.png");
private String tileMap = ("mesh.png");
private String description = "default";

public void loadLevels() {
    try {
        String levelFile = "levels.json";
        loadedLevels = mapper.readValue(new File(levelFile), Level[].class);
    } catch (IOException e) {


This read a json with all my levels called levels.json

"id": 0,
"image": "res\\image0.png",
"tileMap": "level\\tilemap0.tmx",
"description": "GENESIS"
"id": 1,
"image": "levels\\lab.png",
"tileMap": "levels\\lab.tmx",
"description": "A lab"

I am sure there are some messy and wrong stuff here, but this is the gist of it. The method reads the json and loads every level into an array of levels. This way you can store all the text and stuff in json and read those. Makes editing a lot easier. There are a lot of different libraries you can use to serialize json into objects, with the one I used (jackson) it was as easy as making sure the the variables matched and it would create my objects.

Also, I would probably just start doing it, there isn't really any wrong way to do stuff. If you have your text and choices outside of the main code you can just rewrite the "engine" if you realize it needs to be improved as the projects grows in complexity.

Edit: Didn't see the android tag, I would assume that you can use json files in a android project, but I don't know anything about android specific stuff.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .