LibGDX | Android | LottieAnimation

Инструкция по добавлению LottieAnimation Loader-ов в LibGDX (только Android)

Photo by S Migaj on Unsplash
  1. Добавляем необходимые зависимость:
def coroutines_version = '1.5.2'
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version"
def lottie_version = '4.2.2'
implementation "com.airbnb.android:lottie:$lottie_version"
<com.airbnb.lottie.LottieAnimationView
android:id="@+id/lottie"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintDimensionRatio="1:1"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintWidth_percent=".9" />
object Loader {

private val coroutineAnimation = CoroutineScope(Dispatchers.Main)

fun show(@RawRes animationId: Int) {
coroutineAnimation.launch {
binding.lottie.apply {
isVisible = true
setAnimation(animationId)
repeatCount = LottieDrawable.INFINITE
playAnimation()
}
}
}

fun hide() {
coroutineAnimation.launch {
binding.lottie.apply {
isVisible = false
cancelAnimation()
}
}
}

}

--

--

LibGDX | Android | Developer | DragonBones | Enthusiast.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store