Skip to content
piitex edited this page Jun 15, 2024 · 15 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 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("6", 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.
    RenJava.getInstance().getTracks().play("happymusic.mp3", true);
});

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) {}

Clone this wiki locally