Removed animations from countdown
Removed player-speed-textView
This commit is contained in:
@ -151,6 +151,9 @@ public class Game extends Rendering<GameScene> {
|
||||
scene.update(timer);
|
||||
collisionManager.update(physics, scene, timer);
|
||||
break;
|
||||
case COUNTDOWN:
|
||||
viewManager.updateCountdown(timer.getFrameTimeSeconds());
|
||||
break;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
onException(e);
|
||||
|
@ -1,81 +1,92 @@
|
||||
package de.frajul.endlessroll.views;
|
||||
|
||||
import android.graphics.Typeface;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.AnimationSet;
|
||||
import android.view.animation.AnimationUtils;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import de.frajul.endlessroll.R;
|
||||
import de.frajul.endlessroll.main.GameActivity;
|
||||
import de.frajul.endlessroll.main.GameLog;
|
||||
import de.frajul.endlessroll.main.game.Game;
|
||||
import de.frajul.endlessroll.sounds.SoundManager;
|
||||
import de.frajul.endlessroll.sounds.SoundStream;
|
||||
|
||||
/**
|
||||
* Created by Julian on 31.07.2016.
|
||||
*/
|
||||
public class Countdown implements Animation.AnimationListener {
|
||||
public class Countdown {
|
||||
|
||||
private Game game;
|
||||
private AnimationSet animations;
|
||||
private GameActivity gameActivity;
|
||||
private TextView textView;
|
||||
private SoundManager soundManager;
|
||||
private SoundStream soundStream;
|
||||
|
||||
private boolean firstHalfRepeated = true;
|
||||
private int repeatCount = 0;
|
||||
private AtomicBoolean running;
|
||||
private int currentSeconds = 0;
|
||||
private float time = 0;
|
||||
|
||||
public Countdown(Game game, SoundManager soundManager, Typeface typeface, TextView textView) {
|
||||
public Countdown(Game game, GameActivity gameActivity, TextView textView) {
|
||||
this.game = game;
|
||||
this.soundManager = soundManager;
|
||||
this.gameActivity = gameActivity;
|
||||
this.textView = textView;
|
||||
this.textView.setTypeface(typeface);
|
||||
animations = (AnimationSet) AnimationUtils
|
||||
.loadAnimation(game.getContext(), R.anim.countdown);
|
||||
for (Animation animation : animations.getAnimations())
|
||||
animation.setAnimationListener(this);
|
||||
this.textView.setTypeface(gameActivity.getTypeface());
|
||||
running = new AtomicBoolean(false);
|
||||
}
|
||||
|
||||
public void update(float delta) {
|
||||
if (running.get()) {
|
||||
time += delta;
|
||||
if (time >= 1000 && currentSeconds == 0)
|
||||
onNextSecondInUiThread(1);
|
||||
if (time >= 2000 && currentSeconds == 1)
|
||||
onNextSecondInUiThread(2);
|
||||
if (time >= 3000 && currentSeconds == 2) {
|
||||
gameActivity.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
textView.setVisibility(View.GONE);
|
||||
}
|
||||
});
|
||||
running.set(false);
|
||||
game.countdownFinished();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void start() {
|
||||
if (textView.getAnimation() == null || !textView.getAnimation().isInitialized()) {
|
||||
reset();
|
||||
textView.startAnimation(animations);
|
||||
soundStream = soundManager.playSound(soundManager.countdownSound);
|
||||
}
|
||||
reset();
|
||||
running.set(true);
|
||||
textView.setVisibility(View.VISIBLE);
|
||||
soundStream = gameActivity.getSoundManager()
|
||||
.playSound(gameActivity.getSoundManager().countdownSound);
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
textView.clearAnimation();
|
||||
textView.setVisibility(View.GONE);
|
||||
running.set(false);
|
||||
if (soundStream != null)
|
||||
soundManager.stopSound(soundStream);
|
||||
gameActivity.getSoundManager().stopSound(soundStream);
|
||||
}
|
||||
|
||||
private void reset() {
|
||||
repeatCount = 0;
|
||||
textView.setText("3");
|
||||
textView.setTextColor(game.getContext().getResources().getColor(R.color.countdown3));
|
||||
time = 0;
|
||||
onNextSecondInUiThread(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationStart(Animation animation) {
|
||||
private void onNextSecondInUiThread(final int second) {
|
||||
gameActivity.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
currentSeconds = second;
|
||||
textView.setText((3 - second) + "");
|
||||
int color = R.color.countdown1;
|
||||
if (second == 1)
|
||||
color = R.color.countdown2;
|
||||
else if (second == 2)
|
||||
color = R.color.countdown3;
|
||||
textView.setTextColor(game.getContext().getResources().getColor(color));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Animation animation) {
|
||||
game.countdownFinished();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationRepeat(Animation animation) {
|
||||
if (!firstHalfRepeated)
|
||||
repeatCount++;
|
||||
|
||||
firstHalfRepeated = !firstHalfRepeated;
|
||||
textView.setText((3 - repeatCount) + "");
|
||||
if (repeatCount == 1) {
|
||||
textView.setTextColor(game.getContext().getResources().getColor(R.color.countdown2));
|
||||
} else if (repeatCount == 2) {
|
||||
textView.setTextColor(game.getContext().getResources().getColor(R.color.countdown1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ public class ToolButton {
|
||||
if (progress == 100) {
|
||||
game.onToolButtonFinishedLoading(toolType);
|
||||
setColor(R.color.toolbuttonActiveReady);
|
||||
}else
|
||||
} else
|
||||
setColor(R.color.toolbuttonActiveNotReady);
|
||||
} else {
|
||||
if (progress == 100)
|
||||
|
@ -20,22 +20,8 @@ import de.frajul.endlessroll.user.ToolSlotSettings;
|
||||
/**
|
||||
* Created by Julian on 16.01.2016.
|
||||
*/
|
||||
public class ToolButtonBar implements View.OnClickListener, Animation.AnimationListener {
|
||||
public class ToolButtonBar implements View.OnClickListener{
|
||||
|
||||
@Override
|
||||
public void onAnimationStart(Animation animation) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Animation animation) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationRepeat(Animation animation) {
|
||||
|
||||
}
|
||||
|
||||
private Animation fadeIn, fadeOut;
|
||||
private Game game;
|
||||
private List<ToolButton> buttons = new ArrayList<>(4);
|
||||
private RelativeLayout button1;
|
||||
@ -47,9 +33,6 @@ public class ToolButtonBar implements View.OnClickListener, Animation.AnimationL
|
||||
public ToolButtonBar(Game game, ToolSlotSettings toolSlotSettings, LinearLayout layout1) {
|
||||
this.game = game;
|
||||
Context context = game.getContext();
|
||||
fadeIn = AnimationUtils.loadAnimation(game.getContext(), R.anim.fade_in);
|
||||
fadeIn.setAnimationListener(this);
|
||||
fadeOut = AnimationUtils.loadAnimation(game.getContext(), R.anim.fade_out);
|
||||
|
||||
button1 = (RelativeLayout) layout1.findViewById(R.id.toolbutton_1);
|
||||
button1.setOnClickListener(this);
|
||||
@ -65,20 +48,6 @@ public class ToolButtonBar implements View.OnClickListener, Animation.AnimationL
|
||||
buttons.add(new ToolButton(toolSlotSettings.get(3), game, context, button4));
|
||||
}
|
||||
|
||||
public void setTopPrimary() {
|
||||
button1.startAnimation(fadeIn);
|
||||
button2.startAnimation(fadeIn);
|
||||
button3.startAnimation(fadeIn);
|
||||
button4.startAnimation(fadeIn);
|
||||
}
|
||||
|
||||
public void setBottomPrimary() {
|
||||
button1.startAnimation(fadeOut);
|
||||
button2.startAnimation(fadeOut);
|
||||
button3.startAnimation(fadeOut);
|
||||
button4.startAnimation(fadeOut);
|
||||
}
|
||||
|
||||
public void changeToolButtonTypes(ToolSlotSettings toolSlotSettings) {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
buttons.get(i).changeToolSlot(toolSlotSettings.get(i));
|
||||
@ -86,7 +55,6 @@ public class ToolButtonBar implements View.OnClickListener, Animation.AnimationL
|
||||
}
|
||||
|
||||
public void reset(ToolSlotSettings toolSlotSettings) {
|
||||
GameLog.i("Reset toolbuttonBar");
|
||||
changeToolButtonTypes(toolSlotSettings);
|
||||
for (int i = 0; i < 4; i++) {
|
||||
if (toolSlotSettings.get(i).getToolType() != null) {
|
||||
|
@ -30,7 +30,6 @@ public class ViewManager implements View.OnClickListener {
|
||||
|
||||
private TextView fpsView;
|
||||
private TextView playerProgress;
|
||||
private TextView playerSpeed;
|
||||
private ImageView pauseButton;
|
||||
private GameOverMessage gameOverMessage;
|
||||
private GoalMessage goalMessage;
|
||||
@ -40,7 +39,7 @@ public class ViewManager implements View.OnClickListener {
|
||||
|
||||
private List<BombErrorMessage> bombErrorMessages = new ArrayList<>();
|
||||
|
||||
private String fpsFormat, playerProgressFormat, playerSpeedFormat;
|
||||
private String fpsFormat, playerProgressFormat;
|
||||
|
||||
public ViewManager(final Game game, final GameScreen gameScreen, final GameHandler gameViewHandler, final GameActivity gameActivity) {
|
||||
this.game = game;
|
||||
@ -60,8 +59,7 @@ public class ViewManager implements View.OnClickListener {
|
||||
layout.findViewById(R.id.game_game_over_message));
|
||||
goalMessage = new GoalMessage(game, gameScreen, gameActivity,
|
||||
layout.findViewById(R.id.game_goal_message));
|
||||
countdown = new Countdown(game, gameActivity.getSoundManager(),
|
||||
gameActivity.getTypeface(),
|
||||
countdown = new Countdown(game, gameActivity,
|
||||
(TextView) layout.findViewById(R.id.game_countdown));
|
||||
}
|
||||
});
|
||||
@ -69,14 +67,11 @@ public class ViewManager implements View.OnClickListener {
|
||||
pauseButton.setOnClickListener(this);
|
||||
playerProgress = (TextView) layout.findViewById(R.id.game_playerprogress);
|
||||
playerProgress.setTypeface(gameActivity.getTypeface());
|
||||
playerSpeed = (TextView) layout.findViewById(R.id.game_playerspeed);
|
||||
playerSpeed.setTypeface(gameActivity.getTypeface());
|
||||
fpsView = (TextView) layout.findViewById(R.id.game_fps);
|
||||
fpsView.setTypeface(gameActivity.getTypeface());
|
||||
|
||||
fpsFormat = game.getContext().getString(R.string.game_fps_format_d);
|
||||
playerProgressFormat = game.getContext().getString(R.string.game_playerprogress_format_f);
|
||||
playerSpeedFormat = game.getContext().getString(R.string.game_playerspeed_format_f);
|
||||
}
|
||||
|
||||
public void prepareToBeShown() {
|
||||
@ -88,6 +83,10 @@ public class ViewManager implements View.OnClickListener {
|
||||
goalMessage.prepareToBeShown();
|
||||
}
|
||||
|
||||
public void updateCountdown(float delta){
|
||||
countdown.update(delta);
|
||||
}
|
||||
|
||||
public void showBombErrorMessage(float xPos, float yPos) {
|
||||
for (BombErrorMessage bombErrorMessage : bombErrorMessages) {
|
||||
if (!bombErrorMessage.isAnimationRunning()) {
|
||||
@ -113,7 +112,6 @@ public class ViewManager implements View.OnClickListener {
|
||||
toolButtonBar.reset(user.getToolSlotSettings());
|
||||
toolButtonBar.update(0);
|
||||
playerProgress.setText(R.string.game_playerprogress_placeholder);
|
||||
playerSpeed.setText(R.string.game_playerspeed_placeholder);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -164,8 +162,6 @@ public class ViewManager implements View.OnClickListener {
|
||||
fpsView.setText(String.format(fpsFormat, timer.getFps()));
|
||||
if (gameRunning) {
|
||||
playerProgress.setText(String.format(playerProgressFormat, toMeters(playerX)));
|
||||
playerSpeed
|
||||
.setText(String.format(playerSpeedFormat, toMeters(playerXMov * 1000)));
|
||||
toolButtonBar.update(timer.getFrameTimeSeconds());
|
||||
}
|
||||
}
|
||||
|
@ -1,22 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<set xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<scale
|
||||
android:duration="700"
|
||||
android:fromXScale="2"
|
||||
android:fromYScale="2"
|
||||
android:interpolator="@android:anim/accelerate_interpolator"
|
||||
android:pivotX="50%"
|
||||
android:pivotY="50%"
|
||||
android:repeatCount="2"
|
||||
android:repeatMode="restart"
|
||||
android:toXScale="1"
|
||||
android:toYScale="1" />
|
||||
<alpha
|
||||
android:duration="360"
|
||||
android:interpolator="@android:anim/accelerate_interpolator"
|
||||
android:repeatCount="2"
|
||||
android:repeatMode="restart"
|
||||
android:fromAlpha="1"
|
||||
android:toAlpha="0"
|
||||
android:startOffset="340"/>
|
||||
</set>
|
@ -27,22 +27,12 @@
|
||||
android:id="@+id/game_playerprogress"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="4dp"
|
||||
android:layout_marginLeft="6dp"
|
||||
android:layout_marginTop="4dp"
|
||||
android:text="@string/game_playerprogress_placeholder"
|
||||
android:textColor="@color/secondary"
|
||||
android:textSize="22sp"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/game_playerspeed"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignLeft="@+id/game_playerprogress"
|
||||
android:layout_alignStart="@+id/game_playerprogress"
|
||||
android:layout_below="@+id/game_playerprogress"
|
||||
android:text="@string/game_playerspeed_placeholder"
|
||||
android:textColor="@color/secondary"
|
||||
android:textSize="22sp"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/game_fps"
|
||||
android:layout_width="wrap_content"
|
||||
@ -89,8 +79,7 @@
|
||||
android:layout_centerVertical="true"
|
||||
android:text="@string/game_countdown_placeholder"
|
||||
android:textColor="@color/countdown3"
|
||||
android:textSize="100sp"
|
||||
android:textStyle="bold"
|
||||
android:visibility="invisible"/>
|
||||
android:textSize="150sp"
|
||||
android:visibility="gone"/>
|
||||
|
||||
</RelativeLayout>
|
Reference in New Issue
Block a user