Learning Android Development

Make Snooker-like Game with Android Physics-based Animation

Learn about Fling and Spring Dynamic Animation

Photo by Dan Burton on Unsplash

While playing around with Android Physics-based Animation API, I just created a simple App (just one Activity class— not good programming practice, but to state how simple it is) with about 200 lines of codes, and have the snooker like game.

Android Physics-Based Animation

Android Physics-Based Animation consists of these two animations, i.e. FlingAnimation and SpringAnimation, which is a subclass of DynamicAnimation.

It is not provided by default on Android. You’ll need to get the dependencies through build.gradle by adding

implementation "androidx.dynamicanimation:dynamicanimation:1.0.0"

Unlike normal animation, Fling and Spring animation behave according to the velocity provided to them. Hence the behavior is dynamic in correspond to its start velocity.

I use both of them and tied them together to make this simple snooker-like game. Check out below for a…

--

--