Skip to content

Instantly share code, notes, and snippets.

@IvanShafran
Created January 3, 2022 16:44
Embed
What would you like to do?
class AnimatedGameObject(
private val bitmaps: List<Bitmap>,
private val duration: Long
) {
fun getBitmap(timeInMillis: Long): Bitmap {
val mod = timeInMillis % duration
val index = (mod / duration.toFloat()) * bitmaps.size
return bitmaps[index.toInt()]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment