Sonolus Wiki

04. 舞台

在本章中,我们将实现舞台原型。

生命周期

舞台实体应始终保持活跃,一个简单地实现方法就是在 spawnTimedespawnTime 回调函数中返回一个巨大的值:

export class Stage extends Archetype {
    spawnTime() {
        return -999999
    }

    despawnTime() {
        return 999999
    }

    // ...
}
export class Stage extends Archetype {
    spawnTime() {
        return -999999
    }

    despawnTime() {
        return 999999
    }

    // ...
}

声明

我们需要声明皮肤精灵:

export const skin = defineSkin({
    sprites: {
        judgeLine: SkinSpriteName.JudgmentLine,
    },
})
export const skin = defineSkin({
    sprites: {
        judgeLine: SkinSpriteName.JudgmentLine,
    },
})

绘制

绘制舞台与游玩模式类似:

export class Stage extends Archetype {
    // ...

    updateParallel() {
        const layout = new Rect({
            l: judgeLine.l,
            r: judgeLine.r,
            t: 1 - note.radius / 4,
            b: 1 + note.radius / 4,
        })

        skin.sprites.judgeLine.draw(layout, 0, 1)
    }
}
export class Stage extends Archetype {
    // ...

    updateParallel() {
        const layout = new Rect({
            l: judgeLine.l,
            r: judgeLine.r,
            t: 1 - note.radius / 4,
            b: 1 + note.radius / 4,
        })

        skin.sprites.judgeLine.draw(layout, 0, 1)
    }
}