Skip to content

This Application Can earn a bunch of coins for you. it is easy, just click on the big middle button to get your coins

Notifications You must be signed in to change notification settings

amirghm/Coin-Earner-Animation-Sample

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Coin-Earner

This Application Can earn a bunch of coins for you. it is easy, just click on the big middle button to get your coins

Motion Layout:

First I try to implement animation with MotionLayout because I heard if you want to handle animations use MotionLayout. I never worked with that but try to figure it out. After a while, I could create a smooth animation for a view into the layout. everything seems good but one problem exists. I just could use this animation for a predefined view into the XML while I need to create from 1 to 50 coins randomly. so I start searching to find how can I set the animation to a dynamically created view in Kotlin and find almost nothing. So I decided to find another way to handle this.

Animator Set:

Before I just heard we have animator set into the android which you can play multiple animations together or sequentially, I try searching to understand how can I play smooth complex animation and find AnimatorSet class which you can combine multiple primitive animations together. I was excited to find that so I start to Implement multiple simple animations (I just get some data from my made motion layout). After a while, the result disappointed me. The animation slowly played and you can really guess the ugly transform animation when one of them ends and another one played. It was horrible. I try to handle this issue by finding a good interpolator to fix this issue. I search and search and test many interpolators and even many libraries but the results were so bad, and the performance because multiple animations played together is not good (especially we want to have this animation for max 50 or even more coins). I really need something which can play animation on a path in one Animation.

Object animator via the path:

I try searching to find is there any way that I play some animation on a predefined or non-predefined path and find a good method, with ObjectAnimator (which I know before and mark as the best and easier animating solution) we can play some animation in a path. I was excited about finding that and try to create a good path via previous information in the R.I.P MotionLayout. I create a good one and the result is very good. I could see I have a complex animation with one animation play! I was happy about this and I even try this method on animating scale and alpha. this was a good solution.

Loop using handler:

So I need a loop to play multiple coin animation earn. so I should create a dynamic view and then start animation for it, but I need to make some chaos in playing to looks nice, so simply I create a handler and call animation with a small random delay time. of course, I can use the "Coroutines" or "RXJava" for handling this, but at the first, I prefer to do it as simply as possible.

Random Animation problem:

After I creating multiple animation playing I encountered some new issues even on random emission time. I see all the coins moving like a beautiful snake to the CoinBox. well, it is not good, I try thinking about how can I made the coins animation more natural and pleasant. I found a good way, I try to randomize path points for every animation as the results are so good and with a small delay in playing animation it becomes much better. but one another issue exists, the animation sequence, I mean moving animation is not good and so arid.

Handle interpolation:

After all, I need to find a good interpolation for animation. so start reading the android documentation to find a good one with no success, I really need something special for this animation. I have some experience in animations in after effects and 3ds max and game industry, so create my own interpolation via a tool and try to find how can I set it to my android animation. hopefully, I found a way and do that and I made the animation smooth and fast. but I want something more...

Handle Sound lag issue:

For every animation like this we need to hear some coin sound when coin earning happened(I know it is not part of the sample, but I want to try it myself). At first, I simply play a sound as soon as one animation ends, but guess what? The performance extremely decreased and scared me. so I'm thinking with myself about how to resolve this issue. I found a good idea to handle this and try it. I start editing the coin sound I've found. I repeat multiple random coin sound in one file and mark the last coin sound time. when the first animation end, I start playing the big sound from a random beginning (to start a new sound sequence), and when the last animation played I seek the sound to the last coin sound and handle the smooth sound experience. Yes, I just handle multiple sounds playing with just one sound playing and it increases the performance compared to the previous state.

About

This Application Can earn a bunch of coins for you. it is easy, just click on the big middle button to get your coins

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages