Android Open Source - Space.Sprint Game View






From Project

Back to project page Space.Sprint.

License

The source code is released under:

GNU General Public License

If you think the Android project Space.Sprint 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.obisapps.spacerun;
// w w  w. j  a v  a2 s  .c o  m


import android.content.Context;
import android.graphics.Canvas;
import android.view.MotionEvent;
import android.view.SurfaceHolder;
import android.view.SurfaceView;

public class GameView extends SurfaceView implements SurfaceHolder.Callback {
  
  //private static final String TAG = GameView.class.getSimpleName();
    private RenderThread thread;
    private GameEngine gameEngine;
    

    public GameView(Context context) {
      super(context);
      
      getHolder().addCallback(this);
      
      gameEngine = new GameEngine(context);
      
      thread = new RenderThread(getHolder(), this);
      
      setFocusable(true);
      
    }

  @Override
  public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {

    
  }

    @Override 
    public void surfaceCreated(SurfaceHolder holder) {
      
      thread.setRunning(true);
      
      thread.start();
      
    
    }

    @Override 
    public void surfaceDestroyed(SurfaceHolder holder) {
       
      //Log.d(TAG, "Surface is being destroyed");
      
      boolean retry = true;
        //code to end 
        while (retry) {
            try {
                //code to kill Thread
                thread.join();
                retry = false;
            } catch (InterruptedException e) {
              
            }
        }
        

    }
             
    public void render(Canvas canvas) {
      gameEngine.draw(canvas);   
    }
    
  public void update(Canvas canvas, Long gameTime) {
      gameEngine.update(canvas, gameTime);  
  }

    public boolean onTouchEvent(MotionEvent event) {
      
      gameEngine.onTouchEvent(event);
      
      return true;
      
    }
    

       
}




Java Source Code List

com.obisapps.spacerun.GameActivity.java
com.obisapps.spacerun.GameEngine.java
com.obisapps.spacerun.GameView.java
com.obisapps.spacerun.HighScoreDBAdapter.java
com.obisapps.spacerun.HighScoreDatabaseHelper.java
com.obisapps.spacerun.LevelCharacter.java
com.obisapps.spacerun.PhysicsEngine.java
com.obisapps.spacerun.PickUpManager.java
com.obisapps.spacerun.PlayerCharacter.java
com.obisapps.spacerun.RenderThread.java
com.obisapps.spacerun.SoundManager.java
com.obisapps.spacerun.SpaceBackground.java
com.obisapps.spacerun.SpaceSprint.java