Sonolus Wiki

10. 倍速

在本章中,我们将设置并实现倍速变化。

倍速变化

倍速变化原型的实现与前面章节的 BPM 变化原型非常类似。

export const skin = defineSkin({
    sprites: {
        // ...
        timeScaleChangeLine: SkinSpriteName.GridYellow,
    },
})
export const skin = defineSkin({
    sprites: {
        // ...
        timeScaleChangeLine: SkinSpriteName.GridYellow,
    },
})
export const archetypes = defineArchetypes({
    // ...
    [EngineArchetypeName.TimeScaleChange]: TimeScaleChange,
})
export const archetypes = defineArchetypes({
    // ...
    [EngineArchetypeName.TimeScaleChange]: TimeScaleChange,
})
export class TimeScaleChange extends Archetype {
    import = this.defineImport({
        beat: { name: EngineArchetypeDataName.Beat, type: Number },
        timeScale: { name: EngineArchetypeDataName.TimeScale, type: Number },
    })

    render() {
        line(skin.sprites.timeScaleChangeLine, this.import.beat, 0.5)

        print(
            this.import.timeScale,
            bpmChanges.at(this.import.beat).time,
            PrintFormat.TimeScale,
            'auto',
            PrintColor.Yellow,
            'left',
        )
    }
}
export class TimeScaleChange extends Archetype {
    import = this.defineImport({
        beat: { name: EngineArchetypeDataName.Beat, type: Number },
        timeScale: { name: EngineArchetypeDataName.TimeScale, type: Number },
    })

    render() {
        line(skin.sprites.timeScaleChangeLine, this.import.beat, 0.5)

        print(
            this.import.timeScale,
            bpmChanges.at(this.import.beat).time,
            PrintFormat.TimeScale,
            'auto',
            PrintColor.Yellow,
            'left',
        )
    }
}