-
Notifications
You must be signed in to change notification settings - Fork 0
add animations to achievements #635
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
6f4452e
3a29775
98a3fff
293cb60
0d79f74
cea315c
8b5ed30
e6be911
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -185,8 +185,8 @@ private class popOneAndGo_TimerTask extends TimerTask { | |
|
|
||
| @Override | ||
| public void run() { | ||
| achievement_timer.schedule(new AchievementTimerTaskStart(myAchievement), 1); | ||
| achievement_timer.schedule(new AchievementTimerTaskEnd(isLast), Constants.Achievements.DISPLAY_TIME); | ||
| achievement_timer.schedule(new AchievementTimerTaskStart(myAchievement), 500); | ||
| achievement_timer.schedule(new AchievementTimerTaskEnd(isLast), Constants.Achievements.DISPLAY_TIME + 500); | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -208,10 +208,7 @@ public void run() { | |
| submitDataBinding.textAchievementDesc.setText(myAchievement.description); | ||
|
|
||
| //Animation animation = AnimationUtils.loadAnimation(SubmitData.this, R.anim.blink); | ||
|
|
||
| submitDataBinding.imageAchievement.setVisibility(View.VISIBLE); | ||
| submitDataBinding.textAchievementTitle.setVisibility(View.VISIBLE); | ||
| submitDataBinding.textAchievementDesc.setVisibility(View.VISIBLE); | ||
| animateAchievementStart(); | ||
| }); | ||
|
|
||
| // in_submitDataBinding.imageAchievement.startAnimation(animation); | ||
|
|
@@ -237,9 +234,7 @@ private class AchievementTimerTaskEnd extends TimerTask { | |
| @Override | ||
| public void run() { | ||
| SubmitData.this.runOnUiThread(() -> { | ||
| submitDataBinding.imageAchievement.setVisibility(View.INVISIBLE); | ||
| submitDataBinding.textAchievementTitle.setVisibility(View.INVISIBLE); | ||
| submitDataBinding.textAchievementDesc.setVisibility(View.INVISIBLE); | ||
| animateAchievementEnd(); | ||
| }); | ||
|
|
||
| if (isLast) closeAchievements(); | ||
|
|
@@ -278,6 +273,7 @@ private void initAchievements() { | |
| ArrayList<Achievements.PoppedAchievement> pop_list = Achievements.popAchievements(); | ||
|
|
||
| // Keep Achievements invisible | ||
| submitDataBinding.imageAchievementOpen.setVisibility(View.INVISIBLE); | ||
| submitDataBinding.imageAchievement.setVisibility(View.INVISIBLE); | ||
| submitDataBinding.textAchievementTitle.setVisibility(View.INVISIBLE); | ||
| submitDataBinding.textAchievementDesc.setVisibility(View.INVISIBLE); | ||
|
|
@@ -304,6 +300,64 @@ private void initAchievements() { | |
| } | ||
| } | ||
|
|
||
| public void animateAchievementStart() { | ||
| final float openingScaleValue = 1.2f; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should this be a constant in Constans.java ? perhaps that's overkill, but you should comment why it's 1.2f and not 1.1f or 1.6f, etc. Instead of all of my constants comments below, if you had a set of variables inside here with a comment block explaining what they are there for, that would be enough. (can be set to a hard-coded value then). I didn't look (yet) but if these are equally used in animateAchievementEnd(), then they should be Class Globals and defined up around line 34. Still commented to explain them. |
||
| // Show the opening logo overlay | ||
| submitDataBinding.imageAchievementOpen.setVisibility(View.VISIBLE); | ||
|
|
||
| //scale opening image at beginning | ||
| submitDataBinding.imageAchievementOpen.animate().scaleX(openingScaleValue).scaleY(openingScaleValue).setDuration(500) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's against coding standards to have hard-coded values like "500". Should probably be a constant - it's referenced below as well. |
||
| .withEndAction(new Runnable() { | ||
| @Override | ||
| public void run() { | ||
| submitDataBinding.imageAchievementOpen.animate().scaleX(1.0f).scaleY(1.0f).setDuration(500); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm okay with the scalex values of 1.0f but the 500 seems like a Constant (see above comment) |
||
| } | ||
| }); | ||
|
|
||
| // set pivot to a little bit in from the left | ||
| submitDataBinding.imageAchievement.setPivotX(20f); | ||
|
|
||
| // Set the achievement image visibility and shrink it to 0 immediately | ||
| submitDataBinding.imageAchievement.setScaleX(0.0f); | ||
| submitDataBinding.imageAchievement.setVisibility(View.VISIBLE); | ||
|
|
||
| // Scale it up to full size | ||
| submitDataBinding.imageAchievement.animate() | ||
| .scaleX(1.0f) | ||
| .setDuration(750) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 750 is a Constant. 1.0f is okay. |
||
| .withEndAction(new Runnable() { | ||
| @Override | ||
| public void run() { | ||
| // Reveal the text details after the scaling finishes | ||
| submitDataBinding.imageAchievement.setVisibility(View.VISIBLE); | ||
| submitDataBinding.textAchievementTitle.setVisibility(View.VISIBLE); | ||
| submitDataBinding.textAchievementDesc.setVisibility(View.VISIBLE); | ||
| } | ||
| }) | ||
| .start(); | ||
| } | ||
|
|
||
| // hiding achievements | ||
| public void animateAchievementEnd() { | ||
| final float openingScaleValue = 1.2f; | ||
| // hide all acheivement eliments while keeping opener visible | ||
| submitDataBinding.imageAchievementOpen.setVisibility(View.VISIBLE); | ||
| submitDataBinding.imageAchievementOpen.animate().scaleX(openingScaleValue).scaleY(openingScaleValue).setDuration(250); | ||
| submitDataBinding.textAchievementDesc.setVisibility(View.INVISIBLE); | ||
| submitDataBinding.textAchievementTitle.setVisibility(View.INVISIBLE); | ||
| submitDataBinding.imageAchievement.animate() | ||
| .scaleX(0.18f) | ||
| .setDuration(750) | ||
| .withEndAction(new Runnable() { | ||
| @Override | ||
| public void run() { | ||
| submitDataBinding.imageAchievement.setVisibility(View.INVISIBLE); | ||
| submitDataBinding.imageAchievementOpen.animate().scaleX(0.0f).scaleY(0.0f).setDuration(250).start(); | ||
| } | ||
| }); | ||
|
|
||
| } | ||
|
|
||
| // ============================================================================================= | ||
| // Function: initMatch | ||
| // Description: Initialize the Match field | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -172,6 +172,17 @@ | |
| app:layout_constraintBottom_toBottomOf="parent" | ||
| app:srcCompat="@drawable/achievement" /> | ||
|
|
||
| <ImageView | ||
| android:id="@+id/image_Achievement_Open" | ||
| android:layout_width="400dp" | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this really need to be 400dp wide? and this shifted -318dp? if it's the right width, you might be able to use: this way, if we move the image_Achievement, this goes with it. Give this a try and if it looks the same when it's actually popped, it'll be better. |
||
| android:layout_height="80dp" | ||
| android:layout_marginBottom="50dp" | ||
| android:layout_marginStart="-318dp" | ||
| app:layout_constraintEnd_toEndOf="parent" | ||
| app:layout_constraintStart_toStartOf="parent" | ||
| app:layout_constraintBottom_toBottomOf="parent" | ||
| app:srcCompat="@drawable/achievement_open" /> | ||
|
|
||
| <TextView | ||
| android:id="@+id/text_AchievementTitle" | ||
| android:gravity="center_vertical" | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can get rid of this comment. It was "saved" as a way to trigger a blink animation. Since you have a fn() to start the animation, we don't need this.