Android Open Source - NotATop Welcome Surface View






From Project

Back to project page NotATop.

License

The source code is released under:

GNU General Public License

If you think the Android project NotATop 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.gg.view;
// ww  w  . ja v a 2s.c  om
import com.gg.util.Constant;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.view.SurfaceHolder;
import android.view.SurfaceView;

public class WelcomeSurfaceView extends SurfaceView 
implements SurfaceHolder.Callback  //????????????????
{
  MainActivity mainActivity;
  Paint paint;//????
  int currentAlpha=0;//??????????
  
  int screenWidth=Constant.SCREEN_WIDTH;//??????
  int screenHeight=Constant.SCREEN_HEIGHT;//??????
  int sleepSpan=50;//?????????ms
  
  Bitmap[] images=new Bitmap[2];//logo??????
  Bitmap currentImage;//???logo??????
  int currentX;
  int currentY;
  
  public WelcomeSurfaceView(MainActivity mainActivity) {
    super(mainActivity);
    this.mainActivity = mainActivity;
    this.getHolder().addCallback(this);//???????????????????????
    paint = new Paint();//????????
    paint.setAntiAlias(true);//??????
    
    //??????
    images[0]=BitmapFactory.decodeResource(mainActivity.getResources(), R.drawable.welcome_top); 
    images[1]=BitmapFactory.decodeResource(mainActivity.getResources(), R.drawable.welcome_gg);
  }
  public void onDraw(Canvas canvas){  
    //???????????????
    paint.setColor(Color.BLACK);//?????????
    paint.setAlpha(255);
    canvas.drawRect(0, 0, screenWidth, screenHeight, paint);
    
    //??????????
    if(currentImage==null)return;
    paint.setAlpha(currentAlpha);    
    //canvas.drawBitmap(currentImage, currentX, currentY, paint);  
    
    canvas.drawBitmap(currentImage, new Rect(0, 0,
        (int) currentImage.getWidth(), (int) currentImage
            .getHeight()), new Rect(0, 0,
        (int) Constant.SCREEN_WIDTH, (int) Constant.SCREEN_HEIGHT), paint);

  }

  public void surfaceChanged(SurfaceHolder arg0, int arg1, int arg2, int arg3) {
    
  }
  public void surfaceCreated(SurfaceHolder holder) {//???????????    
    new Thread()
    {
      public void run()
      {
        for(Bitmap bm:images)
        {
          currentImage=bm;
          //?????????
          currentX=screenWidth/2-bm.getWidth()/2;
          currentY=screenHeight/2-bm.getHeight()/2;
          
          for(int i=255;i>-100;i=i-15)
          {//??????????????????????????  
            currentAlpha=i;
            if(currentAlpha<0)
            {
              currentAlpha=0;
            }
            SurfaceHolder myholder=WelcomeSurfaceView.this.getHolder();
            Canvas canvas = myholder.lockCanvas();//???????
            try{
              synchronized(myholder){
                onDraw(canvas);//????
              }
            }
            catch(Exception e){
              e.printStackTrace();
            }
            finally{
              if(canvas != null){
                myholder.unlockCanvasAndPost(canvas);
              }
            }            
            try
            {
              if(i==255)
              {//?????????????????
                Thread.sleep(1000);
              }
              Thread.sleep(sleepSpan);
            }
            catch(Exception e)
            {
              e.printStackTrace();
            }
          }
        }
        //??????????????????????
        //activity.sendMessage(WhatMessage.GOTO_MAIN_MENU_VIEW);
        mainActivity.getHandler().sendEmptyMessage(SurfaceViewFactory.MAIN_MENU);
      }
    }.start();
  }

  public void surfaceDestroyed(SurfaceHolder arg0) {//???????????

  }
}




Java Source Code List

com.gg.game.ClassicGame.java
com.gg.game.ClassicGame.java
com.gg.game.GameFrame.java
com.gg.game.GameFrame.java
com.gg.game.TimeGame.java
com.gg.game.TimeGame.java
com.gg.module.DrawBackground.java
com.gg.module.DrawBackground.java
com.gg.module.DrawScore.java
com.gg.module.DrawScore.java
com.gg.module.DrawTrack.java
com.gg.module.DrawTrack.java
com.gg.module.SelectControl.java
com.gg.module.SelectControl.java
com.gg.module.SoundControl.java
com.gg.module.SoundControl.java
com.gg.module.VoiceControl.java
com.gg.module.VoiceControl.java
com.gg.top.BasicTop.java
com.gg.top.BasicTop.java
com.gg.top.DrawCircle.java
com.gg.top.DrawCircle.java
com.gg.top.DrawCone.java
com.gg.top.DrawCone.java
com.gg.top.DrawCylinder.java
com.gg.top.DrawCylinder.java
com.gg.top.DrawTop.java
com.gg.top.DrawTop.java
com.gg.util.Circle.java
com.gg.util.Circle.java
com.gg.util.Constant.java
com.gg.util.Constant.java
com.gg.util.DateUtil.java
com.gg.util.DateUtil.java
com.gg.util.Direction.java
com.gg.util.Direction.java
com.gg.util.Line.java
com.gg.util.Line.java
com.gg.util.Point.java
com.gg.util.Point.java
com.gg.util.TextureRect.java
com.gg.util.TextureRect.java
com.gg.util.TrackPoint.java
com.gg.util.TrackPoint.java
com.gg.util.Track.java
com.gg.util.Track.java
com.gg.util.Utils.java
com.gg.util.Utils.java
com.gg.view.ClassicGameSurfaceView.java
com.gg.view.ClassicGameSurfaceView.java
com.gg.view.EndSurfaceView.java
com.gg.view.EndSurfaceView.java
com.gg.view.FirstTimeSurfaceView.java
com.gg.view.FirstTimeSurfaceView.java
com.gg.view.GameModeSurfaceView.java
com.gg.view.GameModeSurfaceView.java
com.gg.view.HelpSurfaceView.java
com.gg.view.HelpSurfaceView.java
com.gg.view.MainActivity.java
com.gg.view.MainActivity.java
com.gg.view.MainMenuSurfaceView.java
com.gg.view.MainMenuSurfaceView.java
com.gg.view.ScoreSurfaceView.java
com.gg.view.ScoreSurfaceView.java
com.gg.view.SelectSurfaceView.java
com.gg.view.SelectSurfaceView.java
com.gg.view.SurfaceViewFactory.java
com.gg.view.SurfaceViewFactory.java
com.gg.view.TimeGameSurfaceView.java
com.gg.view.TimeGameSurfaceView.java
com.gg.view.WelcomeSurfaceView.java
com.gg.view.WelcomeSurfaceView.java