i am new in android...i want to make a ferris wheel game and i need to move the ferris wheel chair in the wheel...i use:
TranslateAnimation transAnimation1 = new TranslateAnimation(0, 145, 0, 275);
transAnimation1.setDuration(6000);
ChairA1.startAnimation(transAnimation1);
TranslateAnimation transAnimation2 = new TranslateAnimation(0, 50, 0, 50);
transAnimation2.setDuration(6000);
ChairA2.startAnimation(transAnimation2);
TranslateAnimation transAnimation3 = new TranslateAnimation(0, 50, 0, 50);
transAnimation3.setDuration(6000);
ChairA3.startAnimation(transAnimation3);
TranslateAnimation transAnimation4 = new TranslateAnimation(0, 50, 0, 50);
transAnimation4.setDuration(6000);
ChairA4.startAnimation(transAnimation4);
TranslateAnimation transAnimation5 = new TranslateAnimation(0, 50, 0, 50);
transAnimation5.setDuration(6000);
ChairA5.startAnimation(transAnimation5);
TranslateAnimation transAnimation6 = new TranslateAnimation(0, 50, 0, 50);
transAnimation6.setDuration(6000);
ChairA6.startAnimation(transAnimation6);
TranslateAnimation transAnimation7 = new TranslateAnimation(0, 50, 0, 50);
transAnimation7.setDuration(6000);
ChairA7.startAnimation(transAnimation7);
TranslateAnimation transAnimation8 = new TranslateAnimation(0, 50, 0, 50);
transAnimation8.setDuration(6000);
ChairA8.startAnimation(transAnimation8);
i have 8 chairs in my ferris wheel but the problem is the wheel is circle and i cant make the ImageView(chair) in a curve destination...will someone help me...i really need a help on this
Here is the code. It's not well written, but it does the job. Don't ask me how I did the initial positioning of the chairs. I just used a RelativeLayout and guessed at the margins. To make this animation look nice and properly aligned on different phones, you will still have plenty of work to do.
Here is
MainActivity.java
And here is its layout
activity_main.xml
Some of the theory behind the code:
Imagine a ferris wheel turning 90 degrees one way. What does one chair on that ferris wheel usually do during that time? That chair moves with the ferris wheel along from the axis of the wheel, and at the very same time, that chair also rotates minus 90 degrees on its own axis.
In other words, we could have the chair start rotating on its own axis, and at the same time, if we could combine both the ferris wheel and the chair by enclosing it in a larger view, then we could rotate that larger view from the larger axis at the same rate in the opposite direction.
Hope this makes sense to you.