Skip to content

左右动画做得更平滑的建议 #1

@wojiaoliushe

Description

@wojiaoliushe

稍作修改,让左右动作变得更平滑

加入:
/**
* 左右动画时,一根棍的长度在gapCount次后渐渐变成下一根长度,越大动画越平滑。调大gapCount的同时,按倍数减小duration以保证播放速度不变
*/
var gapCount: Int = 1
private var gapIndex = 0
private var tempList: ArrayList = ArrayList()
——————————————————————————————

// val last = bodyWaveList.pollLast()
// bodyWaveList.addFirst(last)

修改为

                if (gapIndex == 0) {
                    tempList.clear()
                    tempList.addAll(bodyWaveList)
                }
                val list = ArrayList<Double>()
                tempList.forEachIndexed { index, i ->
                    val next = tempList[(index + tempList.size - 1) % tempList.size]
                    val value = i + ((next - i) / gapCount * (gapIndex + 1))
                    list.add(value)
                }
                bodyWaveList = list

                gapIndex++
                gapIndex %= gapCount

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions