Android Open Source - TheFirstMyth01 Spiritgirl






From Project

Back to project page TheFirstMyth01.

License

The source code is released under:

MIT License

If you think the Android project TheFirstMyth01 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.renwu;
/*from ww w.  j  a  va  2s  .  co  m*/
import java.util.ArrayList;
import java.util.List;

import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;

public class Spiritgirl {

  private Bitmap SpiritImg;
  List<Rect> rectlist ;
  public Spiritgirl() {
    super();
    
    rectlist = new ArrayList<Rect>();
  }
  
  public int playflag = 0;
  
  public void myDraw_renwu(Canvas canvas, Paint paint ,float x, float y) {

    rectlist = getRectList(SpiritImg,9,8);//9???????
    int oneimgwidth = SpiritImg.getWidth()/9;
    int oneimgHeight = SpiritImg.getHeight()/8;
    Rect dst = new Rect();// ???????????
    // ????? dst ??? ??????????
    dst.left =(int) x-(oneimgwidth/2); 
    dst.top =(int) y-(oneimgHeight/2); 
    dst.right = (int)x+oneimgwidth/2; 
    dst.bottom =(int) y+oneimgHeight/2; 
    
    if(playflag>=3==true)
    {
      playflag=0;  
    }
    
    canvas.drawBitmap(SpiritImg, rectlist.get(playflag), dst, paint);
    playflag++;
    
    
    
//    Rect src1 = new Rect();// ??
////    src1 = getRectList(src1);
//    
//    Rect src = new Rect();// ??
//    Rect dst = new Rect();// ???????????
//    // src ?????????????
//    src.left = 0; // 0,0
//    src.top = 0;
//    src.right = renwu1.getWidth()/8 ;// mBitDestTop.getWidth();,????????????
//    src.bottom = renwu1.getHeight();// mBitDestTop.getHeight()/2;// ????????????????
//    
//    int oneimgwidth = renwu1.getWidth()/8;
//    int oneimgHeight = renwu1.getHeight()/1;
//    
//    // ????? dst ??? ??????????
//    dst.left =(int) x-(oneimgwidth/2); 
//    dst.top =(int) y-(oneimgHeight/2); 
//    dst.right = (int)x+oneimgwidth/2; 
//    dst.bottom =(int) y+oneimgHeight/2; 
//    canvas.drawBitmap(renwu1, src, dst, paint);
    
    dst = null;

  }

  /*???????? 
  *
  *  lastleft lasttop ?????????
  *  horizontalcutnum ???????
  *  verticalcutnum ???????
  */
  public List<Rect> getRectList(Bitmap bmp,int horizontalcutnum,int verticalcutnum) {
    List<Rect> rectlist = new ArrayList<Rect>();
    //????????????
    int oneimgwidth = bmp.getWidth()/horizontalcutnum;
    int oneimgHeight = bmp.getHeight()/verticalcutnum;
    
    for (int i = 0; i < verticalcutnum; i++) {
      for (int j = 0; j < horizontalcutnum; j++) {
        Rect bmpRect = new Rect();
        int left = oneimgwidth*j;
        int top = oneimgHeight*i;
        int right = oneimgwidth*(j+1);
        int bottom = oneimgHeight*(i+1);
        bmpRect.set(left, top, right, bottom);
        rectlist.add(bmpRect);
      }
    }
    
    
    return rectlist;
  }

}




Java Source Code List

com.example.gametest1.GameActivity.java
com.example.gametest1.GameMainActivity.java
com.example.gametest1.GameView.java
com.example.gametest1.MoveTest.java
com.game.base.BaseInfo.java
com.game.base.GameBackGround.java
com.game.base.GameMap.java
com.game.base.PubSet.java
com.game.commen.ActionToDo.java
com.game.commen.BitmapUtil.java
com.game.commen.Direction.java
com.game.commen.EffectName.java
com.game.commen.GetImgCommen.java
com.game.commen.MapName.java
com.game.commen.ToDo.java
com.game.data.BaseInfo.java
com.game.data.RoleData_Main.java
com.game.data.RoleData.java
com.game.effect.SpecialEffect1.java
com.game.effect.SpecialEffect.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