Android Open Source - BounceMe level Gen






From Project

Back to project page BounceMe.

License

The source code is released under:

MIT License

If you think the Android project BounceMe 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 com.example.bounceme;
/*  w  w w .  j  a  va 2 s . c o m*/
import android.app.Activity;
import android.content.Intent;
import android.graphics.Paint;
import android.graphics.Typeface;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.TextView;

public class levelGen extends Activity {
  PlaySurfaceView mySurfaceView;
  Button restart;

  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Intent i = getIntent();
    int levelNum = i.getIntExtra("level", 1);
    
    setContentView(R.layout.play_screen);
    
    FrameLayout surface = (FrameLayout) findViewById(R.id.frame);
    mySurfaceView = new PlaySurfaceView(this, levelNum);
    surface.addView(mySurfaceView);
    
    restart = (Button) findViewById(R.id.restartButton);
    final Button back = (Button) findViewById(R.id.menuButton);
    final Button pop = (Button) findViewById(R.id.popoutButton);
    pop.setText("^");
    pop.setOnClickListener(new View.OnClickListener() {
      
      @Override
      public void onClick(View arg0) {
        Log.d("OUTPUT", "clicked");
        if(pop.getText() == "^"){
          Log.d("OUTPUT", "IN2");
          pop.setText("-");
          back.setVisibility(0);
          restart.setVisibility(0);
        }else{
          pop.setText("^");
          back.setVisibility(4);
          restart.setVisibility(4);
        }
      }
    });
    
    
    
    restart = (Button) findViewById(R.id.restartButton);
    restart.setOnClickListener(new View.OnClickListener() {
      
      @Override
      public void onClick(View v) {
        mySurfaceView.reset();
        //((Button)findViewById(R.id.restartButton)).setXXX
        
      }
    });
    
    Typeface tf = Typeface.createFromAsset(getAssets(), "fonts/shades.ttf");
    ViewGroup parent = ((ViewGroup)getWindow().getDecorView());
    setTypeFace(tf, parent);
    
    Button menu = (Button) findViewById(R.id.menuButton);
    
    menu.setOnClickListener(new View.OnClickListener() {
      
      @Override
      public void onClick(View v) {
        finish();
        
      }
    });
  }

  public void restart(){
    levelGen.this.runOnUiThread(new Runnable(){
      public void run(){
        if(restart.getVisibility() == 4){
          //restart.setText("HEllO WORLD");
        }
      }
    });
  }
  
  @Override
  protected void onResume() {
    // TODO Auto-generated method stub
    super.onResume();
    mySurfaceView.onResumeMySurfaceView();
  }

  @Override
  protected void onPause() {
    // TODO Auto-generated method stub
    super.onPause();
    mySurfaceView.onPauseMySurfaceView();
  }
  
  public static void setTypeFace(Typeface custom, ViewGroup parent){
    for(int i = 0; i < parent.getChildCount(); i++){
      View v = parent.getChildAt(i);
      if(v instanceof ViewGroup){
        setTypeFace(custom, (ViewGroup) v);
      }else if(v instanceof TextView){
        TextView tv = (TextView) v;
        tv.setTypeface(custom);
        tv.setPaintFlags(tv.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG);
      }else if(v instanceof Button){
        Button b = (Button) v;
        b.setTypeface(custom);
        b.setPaintFlags(b.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG);        
      }
    }
  }
}




Java Source Code List

com.cse3345.f13.martin.Ball.java
com.cse3345.f13.martin.CreditActivity.java
com.cse3345.f13.martin.Goal.java
com.cse3345.f13.martin.LevelGen.java
com.cse3345.f13.martin.LevelPicker.java
com.cse3345.f13.martin.Level.java
com.cse3345.f13.martin.MenuActivity.java
com.cse3345.f13.martin.PlaySurfaceView.java
com.cse3345.f13.martin.SetActivity.java
com.cse3345.f13.martin.Sling.java
com.cse3345.f13.martin.TutActivity.java
com.cse3345.f13.martin.Wall.java
com.cse3345.f13.martin.WinActivity.java
com.example.bounceme.Ball.java
com.example.bounceme.CreditActivity.java
com.example.bounceme.Goal.java
com.example.bounceme.GridAdapter.java
com.example.bounceme.Level.java
com.example.bounceme.MenuActivity.java
com.example.bounceme.PlaySurfaceView.java
com.example.bounceme.SetActivity.java
com.example.bounceme.Sling.java
com.example.bounceme.WinActivity.java
com.example.bounceme.levelGen.java
com.example.bounceme.levelPicker.java