Android Open Source - TheFirstMyth01 Special Effect






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.effect;
//from   ww w  .jav a2 s. c  o  m
import java.util.ArrayList;
import java.util.List;

import com.game.base.BaseInfo;
import com.game.base.PubSet;
import com.game.commen.BitmapUtil;
import com.game.commen.Direction;
import com.game.commen.EffectName;
import com.game.data.RoleData;
import com.game.data.RoleData_Main;

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.graphics.Typeface;

public class SpecialEffect {

  private String effectUrl = "";

  private int maxnum = 0;

  private boolean repeat;
  String lastpath = "";
  public int flag = 0;
  int flagpao = 0;

  public EffectName effectName ;
  public SpecialEffect(EffectName effectName ,String effectUrl, int maxnum,boolean repeat) {
    super();
    this.effectUrl = effectUrl;
    this.maxnum = maxnum;
    this.repeat=repeat;
    this.effectName=effectName;
  }

  public void myDraw_Effect(Context context, Canvas canvas, Paint paint,
      int x, int y) {

    
    // ??????????
    SetImgUrl(effectUrl, maxnum ,repeat);

    if (flag < maxnum) {
      Bitmap bmp = BitmapUtil.getBitmapFromAssets(context, lastpath);
      if (bmp != null) {

        // ??????
        int oneimgwidth = bmp.getWidth();
        int oneimgHeight = bmp.getHeight();

        Rect bmpRect = new Rect();
        int left = 0;
        int top = 0;
        int right = oneimgwidth;
        int bottom = oneimgHeight;
        bmpRect.set(left, top, right, bottom);

        // ????????????
        Rect dst = new Rect();
        // ????????
        dst.left = (int) x - oneimgwidth / 2;
        dst.top = (int) y - oneimgHeight / 2 - oneimgHeight / 4;
        dst.right = (int) x + oneimgwidth / 2;
        dst.bottom = (int) y + oneimgHeight / 2 - oneimgHeight / 4;

        canvas.drawBitmap(bmp, bmpRect, dst, paint);

        bmp.recycle();
        bmp = null;
        dst = null;
      }
    }
    
  }

  // ????????
  public void SetImgUrl(String ActionUrl, int MaxNum, boolean repeat) {
    if (flag < 10) {
      lastpath = ActionUrl + "0000" + flag + ".png";
    } else {
      lastpath = ActionUrl + "000" + flag + ".png";
    }
    flag++;
    if (repeat == true) {
      if (flag >= MaxNum) {
        flag = 0;
      }
    }
  }

}




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