Android Open Source - Marble-Run Menu Activity






From Project

Back to project page Marble-Run.

License

The source code is released under:

Apache License

If you think the Android project Marble-Run listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package nttu.edu.activities;
//  w  w w.j a  v  a 2  s .  c o  m
import nttu.edu.R;
import nttu.edu.graphics.Art;
import nttu.edu.handler.ModPlayer;
import nttu.edu.sound.Sound;
import android.app.Activity;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.res.AssetManager;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.view.WindowManager.LayoutParams;
import android.widget.Button;

public class MenuActivity extends Activity implements View.OnClickListener {
  //public static MusicHandler music;
  public static ModPlayer player;
  
  @Override
  public void onCreate(Bundle b) {
    super.onCreate(b);
    this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    Window window = this.getWindow();
    window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    window.addFlags(LayoutParams.FLAG_KEEP_SCREEN_ON);
    this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE);
    this.setContentView(R.layout.menu);
    load();
    Button play = (Button) this.findViewById(R.id.playButton);
    Button score = (Button) this.findViewById(R.id.scoreButton);
    Button quit = (Button) this.findViewById(R.id.quitButton);
    Button settings = (Button) this.findViewById(R.id.settingsButton);
    play.setOnClickListener(this);
    score.setOnClickListener(this);
    quit.setOnClickListener(this);
    settings.setOnClickListener(this);
  }
  
  private void load() {
    AssetManager manager = this.getAssets();
    Art.sprites = Art.loadBitmap(manager, "art/sprites.png");
    Art.animatedHole = Art.loadBitmap(manager, "art/goal.png");
    Art.coin = Art.loadBitmap(manager, "art/coin.png");
    Art.gameOver = Art.loadBitmap(manager, "art/gameover.png");
    Art.gameOver = Bitmap.createScaledBitmap(Art.gameOver, 232, 32, false);
    Art.compass = Art.loadBitmap(manager, "art/compass.png");
    Art.hud = Art.loadBitmap(manager, "art/hud.png");
    Art.hudMenu = Art.loadBitmap(manager, "art/hudmenu.png");
    Sound.emergencyLoad(this, manager);
    PreferenceManager.setDefaultValues(getApplicationContext(), R.xml.preferences, false);
    if (SettingsActivity.sharedPreferences == null)
      SettingsActivity.sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    //music = new MusicHandler(this.getApplicationContext());
    player = new ModPlayer(this);
  }
  
  @Override
  protected void onPause() {
    //music.onPause();
    player.onPause();
    super.onPause();
  }
  
  @Override
  protected void onResume() {
    //music.onResume();
    player.onResume();
    super.onPause();
  }
  
  @Override
  public void finish() {
    //music.onFinish();
    player.onPause();
    super.finish();
  }
  
  public void onClick(View v) {
    Intent intent = null;
    switch (v.getId()) {
      case R.id.playButton:
        intent = new Intent(MenuActivity.this, LevelSelectionActivity.class);
        MenuActivity.this.startActivity(intent);
        break;
      case R.id.scoreButton:
        intent = new Intent(MenuActivity.this, ScoreActivity.class);
        MenuActivity.this.startActivity(intent);
        break;
      case R.id.quitButton:
        MenuActivity.this.finish();
        android.os.Process.killProcess(android.os.Process.myPid());
        break;
      case R.id.settingsButton:
        intent = new Intent(MenuActivity.this, SettingsActivity.class);
        MenuActivity.this.startActivity(intent);
        break;
    }
  }
}




Java Source Code List

nttu.edu.activities.LevelSelectionActivity.java
nttu.edu.activities.MenuActivity.java
nttu.edu.activities.NewLoadingActivity.java
nttu.edu.activities.PlayActivity.java
nttu.edu.activities.ScoreActivity.java
nttu.edu.activities.SettingsActivity.java
nttu.edu.alt.NewBall.java
nttu.edu.alt.NewCue.java
nttu.edu.alt.NewHole.java
nttu.edu.alt.Obstacle.java
nttu.edu.ball.Ball.java
nttu.edu.ball.Cue.java
nttu.edu.ball.Marble.java
nttu.edu.entity.Border.java
nttu.edu.entity.Bumper.java
nttu.edu.entity.Coin.java
nttu.edu.entity.Connector.java
nttu.edu.entity.CurvePipe.java
nttu.edu.entity.Entity.java
nttu.edu.entity.Funnel.java
nttu.edu.entity.Hole.java
nttu.edu.entity.Path.java
nttu.edu.entity.Pipe.java
nttu.edu.entity.Ramp.java
nttu.edu.entity.ShortFunnel.java
nttu.edu.entity.Tee.java
nttu.edu.entity.Terrain.java
nttu.edu.entity.Void.java
nttu.edu.graphics.Art.java
nttu.edu.graphics.RenderView.java
nttu.edu.handler.Accelero.java
nttu.edu.handler.ImageInfo.java
nttu.edu.handler.Info.java
nttu.edu.handler.Loading.java
nttu.edu.handler.ModPlayer.java
nttu.edu.handler.MusicHandler.java
nttu.edu.hud.BestScore.java
nttu.edu.hud.Compass.java
nttu.edu.hud.GoalCompass.java
nttu.edu.hud.HUDMenu.java
nttu.edu.hud.HUDScore.java
nttu.edu.hud.MarbleCompass.java
nttu.edu.hud.TimeBasedScore.java
nttu.edu.level.HUD.java
nttu.edu.level.Stage.java
nttu.edu.score.Format.java
nttu.edu.score.Score.java
nttu.edu.sound.Sound.java