67 lines
2.3 KiB
Java
67 lines
2.3 KiB
Java
package com.example.jmastermind;
|
|
|
|
import androidx.appcompat.app.AppCompatActivity;
|
|
import android.media.MediaPlayer;
|
|
import android.os.Bundle;
|
|
import android.view.animation.Animation;
|
|
import android.view.animation.AnimationSet;
|
|
import android.view.animation.LinearInterpolator;
|
|
import android.view.animation.TranslateAnimation;
|
|
import android.widget.LinearLayout;
|
|
import android.widget.TextView;
|
|
import com.example.jmastermind.Events.MenuEvent;
|
|
import com.example.jmastermind.Events.PrologueAnimation;
|
|
import com.example.jmastermind.Menu.Menu;
|
|
|
|
public class Prologue extends AppCompatActivity {
|
|
private MediaPlayer mp;
|
|
|
|
@Override
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
super.onCreate(savedInstanceState);
|
|
setContentView(R.layout.prologue);
|
|
|
|
this.mp = MediaPlayer.create(this, R.raw.prologuesong);
|
|
this.mp.setLooping(false);
|
|
this.mp.start();
|
|
|
|
LinearLayout prologue = (LinearLayout) findViewById(R.id.prologue);
|
|
prologue.setOnClickListener(new MenuEvent(this, Menu.class, this.mp));
|
|
|
|
TextView tx = (TextView) findViewById(R.id.prologuetext);
|
|
|
|
AnimationSet animationSet = new AnimationSet(true);
|
|
animationSet.setInterpolator(new LinearInterpolator());
|
|
|
|
TranslateAnimation animationUp = new TranslateAnimation(
|
|
Animation.RELATIVE_TO_SELF, 0f,
|
|
Animation.RELATIVE_TO_SELF, 0f,
|
|
Animation.RELATIVE_TO_SELF, 0f,
|
|
Animation.RELATIVE_TO_SELF, -1f
|
|
);
|
|
animationUp.setDuration(30000);
|
|
animationUp.setFillAfter(true);
|
|
animationSet.addAnimation(animationUp);
|
|
|
|
TranslateAnimation animationDown = new TranslateAnimation(
|
|
Animation.RELATIVE_TO_SELF, 0f,
|
|
Animation.RELATIVE_TO_SELF, 0f,
|
|
Animation.RELATIVE_TO_SELF, 1f,
|
|
Animation.RELATIVE_TO_SELF, 0f
|
|
);
|
|
animationDown.setDuration(30000);
|
|
animationDown.setFillAfter(true);
|
|
animationSet.addAnimation(animationDown);
|
|
|
|
PrologueAnimation pa = new PrologueAnimation(this, mp);
|
|
animationSet.setAnimationListener(pa);
|
|
|
|
tx.startAnimation(animationSet);
|
|
}
|
|
|
|
@Override
|
|
public void onBackPressed() {
|
|
this.mp.stop();
|
|
this.finishAffinity();
|
|
}
|
|
} |