All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.ru.casperix.spine.animation.TranslateTimeline.kt Maven / Gradle / Ivy

The newest version!
package ru.casperix.spine.animation

class TranslateTimeline(
    override val boneIndex: Int,
    override val frames: List,
) : AbstractTimeline(frames), CurveTimeline1, BoneTimeline {
    private val xChannel = BoneTransformChannel(frames, false, 0, { it.x }, { it.x })
    private val yChannel = BoneTransformChannel(frames, false, 1, { it.y }, { it.y })

    override fun apply(context: AnimationContext) = context.getBoneContext(boneIndex)?.run {
        bone.local = bone.local.copy(
            x = xChannel.getCurrentValue(this),
            y = yChannel.getCurrentValue(this),
        )
    } ?: Unit
}

class TranslateXTimeline(
    override val boneIndex: Int,
    override val frames: List,
) : AbstractTimeline(frames), CurveTimeline1, BoneTimeline {
    private val xChannel = BoneTransformChannel(frames, false, 0, { it.x }, { it.x })

    override fun apply(context: AnimationContext) = context.getBoneContext(boneIndex)?.run {
        bone.local = bone.local.copy(
            x = xChannel.getCurrentValue(this),
        )
    } ?: Unit
}

class TranslateYTimeline(
    override val boneIndex: Int,
    override val frames: List,
) : AbstractTimeline(frames), CurveTimeline1, BoneTimeline {
    private val yChannel = BoneTransformChannel(frames, false, 1, { it.y }, { it.y })

    override fun apply(context: AnimationContext) = context.getBoneContext(boneIndex)?.run {
        bone.local = bone.local.copy(
            y = yChannel.getCurrentValue(this),
        )
    } ?: Unit
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy