Android Open Source - TheFirstMyth01 Spirit






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;
//  www .  j  ava  2  s  .co  m
import java.util.ArrayList;
import java.util.List;

import com.game.data.RoleData;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;

public class Spirit {

  List<Rect> rectlist;

  private RoleData roloinfo;
  
  public Spirit(RoleData roloinfo) {
    super();
    this.roloinfo = roloinfo;
    rectlist = new ArrayList<Rect>();
  }

  public int playflag = 0;

  public void myDraw_Spirit(Canvas canvas, Paint paint,int x,int y) {

    //??????
        int oneimgwidth = roloinfo.getPlayerImg().getWidth() / roloinfo.getHorizontalcutnum();
        int oneimgHeight = roloinfo.getPlayerImg().getHeight() / roloinfo.getVerticalcutnum();
        
        rectlist = getRectList(roloinfo.getPlayerImg(), roloinfo.getHorizontalcutnum(), roloinfo.getVerticalcutnum());
        
        // ????????????
        Rect dst = new Rect();
        // ????????
        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 >= roloinfo.getPlaynum() == true) {
          playflag = 0;
        }
        
        // ?????
        Rect rect_yinzi = new Rect();
        rect_yinzi.left = 0;
        rect_yinzi.top = 0;
        rect_yinzi.right = roloinfo.getYinziImg().getWidth();
        rect_yinzi.bottom = roloinfo.getYinziImg().getHeight();
        
        // ????????????
        Rect rect_yinzi1 = new Rect();
        // ???????
        // ???????
        rect_yinzi1.left = (int) x -roloinfo.getYinziImg().getHeight();
        rect_yinzi1.top = (int) y + roloinfo.getYinziImg().getHeight()/2;
        rect_yinzi1.right = (int) x + roloinfo.getYinziImg().getHeight();
        rect_yinzi1.bottom = (int) y + (int)(roloinfo.getYinziImg().getHeight()*1.5);
        
        //??????????,????????
        canvas.drawBitmap(roloinfo.getYinziImg(), rect_yinzi , rect_yinzi1, paint);
        canvas.drawBitmap(roloinfo.getPlayerImg(), rectlist.get(playflag), dst, paint);
        
        
        playflag++;

        dst = null;
  }

  /*
   * ????????
   * 
   * 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