Android Open Source - TheFirstMyth02 Bitmap Touch Checker






From Project

Back to project page TheFirstMyth02.

License

The source code is released under:

MIT License

If you think the Android project TheFirstMyth02 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.game.commen;
//from w  w  w. java  2 s. co m
import com.game.base.PubSet;
import com.game.commen.IrregularButton.TouchChecker;
import com.game.fengshen.GameMainActivity;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.util.Log;
import android.widget.Toast;

public class BitmapTouchChecker implements TouchChecker  
{  
    private Bitmap bitmap;  
    private Context context;
    public BitmapTouchChecker(Context context,Bitmap bitmap)  
    {  
        this.bitmap = bitmap;  
        this.context=context;
    }  
 // ?????????
   public static int F_x = 0;
   public static int F_y = 0;
 // ????
   public void Draw(Canvas canvas, Paint paint, int spirit_x,
       int spirit_y) {
   // ?????
     int mapwidth = bitmap.getWidth();
       int mapheight = bitmap.getHeight();

       // ?????
     int screenWidth = PubSet.screenWidth;
     int screenHeight = PubSet.screenHeight;
       
     Rect map_rect = new Rect();
    map_rect.left = F_x;
    map_rect.top = F_y;
    map_rect.right = F_x + screenWidth;
    map_rect.bottom = F_y + screenHeight;

    // ???????????
    Rect screen_rect = new Rect();
    screen_rect.left = 0;
    screen_rect.top = 0;
    screen_rect.right = screenWidth;
    screen_rect.bottom = screenHeight;
    
     canvas.drawBitmap(bitmap, map_rect, screen_rect, paint);

   }
    
    @Override  
    public boolean isInTouchArea(int x, int y, int width, int height)  
    {  
        if (bitmap != null)  
        {  
            int pixel = bitmap.getPixel(x, y);  
              
            if (((pixel >> 24) & 0xff) > 0)  
            {  
              tip("?????????");  
                return true;  
            }  
        }     
          
        tip("???????????");  
        return false;  
    }  
  
    public void tip(String str)
  {
    Toast.makeText(context,str, Toast.LENGTH_SHORT).show();
  }
}




Java Source Code List

.Test.java
com.game.base.BaseInfo.java
com.game.base.GameBackGround.java
com.game.base.GameChapterBaseSet_Shentan.java
com.game.base.GameMap.java
com.game.base.PubSet.java
com.game.commen.AStarMap.java
com.game.commen.AStarNode.java
com.game.commen.AStar.java
com.game.commen.ActionToDo.java
com.game.commen.BitmapTouchChecker.java
com.game.commen.BitmapUtil.java
com.game.commen.Direction.java
com.game.commen.EffectName.java
com.game.commen.GameXmlcommen.java
com.game.commen.GetImgCommen.java
com.game.commen.IrregularButton.java
com.game.commen.MapName.java
com.game.commen.Paintforziti.java
com.game.commen.ToDo.java
com.game.data.BaseInfo.java
com.game.data.RoleData_Main.java
com.game.data.RoleData.java
com.game.data.StroyTipData.java
com.game.effect.SpecialEffect.java
com.game.fengshen.GameActivity.java
com.game.fengshen.GameMainActivity.java
com.game.fengshen.GameView.java
com.game.fengshen.MoveTest.java
com.game.renwu.Objs.java
com.game.renwu.SpiritMain.java
com.game.renwu.Spirit_Main.java
com.game.renwu.Spirit_NPC.java
com.game.renwu.Spirit.java
com.game.renwu.Spiritgirl.java
com.game.stroy.MainStroy.java
com.game.tip.PublicTips.java