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

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

There is a newer version: 0.9.0
Show newest version
package ru.casperix.spine.animation

class TranslateTimeline(
    override val boneIndex: Int,
    override val frames: List,
) : AbstractTimeline(frames), CurveTimeline1, BoneTimeline {
    val xFrames = frames.map { createFrame(it.time, it.x, it.curve, 0) }
    val yFrames = frames.map { createFrame(it.time, it.y, it.curve, 1) }

    override fun apply(context: AnimationContext) = context.run {
        val bone = skeleton.bones[boneIndex]
        if (bone.isActive) {
            val x = FrameCalculator.getRelativeValue(xFrames, time, weight, blend, bone.local.x, bone.data.local.x, false)
            val y = FrameCalculator.getRelativeValue(yFrames, time, weight, blend, bone.local.y, bone.data.local.y, false)
            bone.local = bone.local.copy(x = x, y = y)
        }
    }


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy