Sonolus Wiki

03. Initialization

In this chapter, we will implement Initialization.

Initialization

Because watch mode is simply play mode but without inputs, we can simply copy play mode Initialization code over, which includes setting up skin and particle transformation, calculating and sharing immutable data of judge line and note, score, life, UI, and global preprocess.

One noteworthy difference is the extra progress UI, which allows players to control the playback of watch mode:

export class Initialization extends Archetype {
    preprocess() {
        // ...

        ui.progress.set({
            anchor: screen.rect.lb.add(new Vec(0.05, 0.05)),
            pivot: { x: 0, y: 0 },
            size: { x: screen.rect.w - 0.1, y: 0.15 * ui.configuration.progress.scale },
            rotation: 0,
            alpha: ui.configuration.progress.alpha,
            horizontalAlign: HorizontalAlign.Center,
            background: true,
        })

        // ...
    }
}
export class Initialization extends Archetype {
    preprocess() {
        // ...

        ui.progress.set({
            anchor: screen.rect.lb.add(new Vec(0.05, 0.05)),
            pivot: { x: 0, y: 0 },
            size: { x: screen.rect.w - 0.1, y: 0.15 * ui.configuration.progress.scale },
            rotation: 0,
            alpha: ui.configuration.progress.alpha,
            horizontalAlign: HorizontalAlign.Center,
            background: true,
        })

        // ...
    }
}