Skip to content
piitex edited this page Jun 16, 2024 · 7 revisions

Scenes

Scenes are frames in a visual novel game. They typically contain a background image and character dialogue. In RenJava there are several types of scenes such as;

  • AnimationScene - Contains a video instead of an image which plays in the background.
  • AutoPlayScene - Automatically displays and runs the next scene after a set duration.
  • ImageScene - Your standard visual novel scene. Background image and a textbox, both of which are optional.
  • InteractableScene - A little more complex of a scene, does not automatically end.
  • ChoiceScene - Contains choices for the player to select.
  • InputScene. Contains an input field.

RenScene and Story

In order to use and display the scenes you will have to create a story first. The init() function is then used to add scenes the story. I like to view stories as chapter and character events. Stories handle and map scenes to display and run them in the proper order. You will also have to map the story to the framework.

public class MyStory extends Story {
    
    public MyStory(String id) {
        super(id);
    }
    
    @Override
    public void init() {
        // Inside this function you need to add your scenes to the story.
        this.addScene(RenScene scene);
   
    }
}

To register and map the story to the framework, simply create an object instance of the class.

public class MyRenJavaClass extends RenJava {
    ...
    @Override
    public void createStory() {
        new MyStory("my-story");
    }
}

RenScene API

There are also generic scene functions which can be used to control how the scene plays.

    /**
     * Creates an event handler to execute when a scene starts.
     * @param sceneInterface Code to execute.
     * @return The modified RenScene.
     */
    public RenScene onStart(SceneStartInterface sceneInterface) {
        this.startInterface = sceneInterface;
        return this;
    }

    /**
     * Create an event handler to execute when a scene ends.
     * @param endInterface Code to execute.
     * @return The modified RenScene.
     */
    public RenScene onEnd(SceneEndInterface endInterface) {
        this.endInterface = endInterface;
        return this;
    }

    /**
     * Create an event handler to execute when a menu is built not rendered.
     * @param buildInterface Code to execute.
     * @return The modified RenScene.
     */
    public RenScene onBuild(SceneBuildInterface buildInterface) {
        this.buildInterface = buildInterface;
        return this;
    }

Here is some examples of how you can use these functions.

ImageScene scene = new ImageScene("1", nar, "After some struggle and rolling out of the bed. I make my way into the town.");
scene.onEnd(event -> {
    // Prevents the engine from advancing to the next scene.
    event.setAutoPlayNextScene(false);

    // Start next story.
    RenJava.getInstance().getPlayer().startStory("next-story");
});
scene.onStart(event -> {
    // Start music to set the mood for the scene. Sometimes it is best to set music for when the story starts.
    RenJava.getInstance().getTracks().play("happymusic.mp3", true);
});

Story API

There are a lot of ways to control and manage how stories work and function. You can control specific scenes in a story and event multiple. Stories can also have global controls, such as, setting music for the entire story.

NOT YET FINISHED.

ImageScene

Like said previously, the image scene is your standard VN scene. It contains an image and character dialogue. Note, both the image and dialogue can have null values.

image

Creating an ImageScene

Below is the current API documentation which explains some of the parameters needed to create an ImageScene. All RenScene's need to be in a story to be properly rendered and handled by the engine.

/**
* Creates an ImageScene object representing an image scene in the RenJava framework.
* An image scene is used to display an image and text associated with a character.
* Image scenes are typically used to present visuals and dialogue during gameplay or narrative progression.
*
* @param id        The ID used to identify the scene.
* @param character The character who is talking. Pass null if no character is talking in the scene.
* @param dialogue  The dialogue of the character. Pass null or an empty string if no one is talking.
* @param backgroundImage    The background image loader for the scene.
*/
public ImageScene(String id, @Nullable Character character, String dialogue, @Nullable ImageOverlay backgroundImage) {}