⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 speffect.java

📁 恶魔城-晓月圆舞曲 JAVA手機遊戲
💻 JAVA
字号:
import javax.microedition.lcdui.*;

public class SpEffect {
	byte effect;//基本特效模式
	byte font;//特效字体种类
	byte bruise;//攻击特效种类
	static final byte BRUISE$BLOOD = 0;
	static final byte FONT$BLOOD = 1;
	private static final byte DELETE = 3;
	
	static final byte INCREASE = 0;//加血,蓝色
	static final byte REDUCE = 1;//减血,红色
	
	static final byte BRUISE_1 = 0;
	static final byte BRUISE_2 = 1;
	
	private byte frame;
	private byte aniSpeed;
	private short x,y;//地图坐标
	private short sx,sy;//屏幕坐标
	private boolean del;
	private short loseBlood;
	private byte spCount;
	private short spLastY;
	private byte ilk;
	public SpEffect(byte effect,byte ilk)
	{
		this((short)(CastleCanvas.soma.roleX+CastleCanvas.soma.imgW/2),
				(short)CastleCanvas.soma.roleY,effect,ilk);
	}
	public SpEffect(short x,short y,byte effect,byte ilk)
	{
		this.x = x;
		this.y = y;
		this.effect = effect;
		switch(effect)
		{
		case BRUISE$BLOOD:
			bruise = ilk;
			break;
		case FONT$BLOOD:
			font = ilk;
			break;
		}
	}
	public boolean getDelete()
	{
		return del;
	}
	public void setLoseBlooad(short blood)
	{
		loseBlood = blood;
	}
	public void paint(Graphics g)
	{
		tickcCoord();
		switch(effect)
		{
		case BRUISE$BLOOD:
			draw_bruise(g);
			break;
		case FONT$BLOOD:
			draw_font(g);
			break;
		case DELETE:
			del = true;
			break;
		}
	}
	private void draw_font(Graphics g)
	{
		tickSp();
		switch(font)
		{
		case INCREASE:
			draw_num(g,(byte)43);
			break;
		case REDUCE:
			draw_num(g,(byte)35);
			break;
		}
	}
	public void tickcCoord()//修正坐标
	{
		sx = (short)(x-CastleCanvas.map.getPosX());
		sy = (short)(y-CastleCanvas.map.getPosY());
	}
	public void setEffect(byte ilk) //设置字体的特效种类
	{
		this.ilk = ilk;
	}
	public void tickSp()
	{
		//0 攻击
		//1 受伤效果
		//2 加血效果
		//3 无特效
		switch(ilk)
		{
		case 0:
			spCount++;
			y -= 2;
			if(spCount>11)//一定是单数,否则直接ELSE 出错
			{
				if(spCount%2==0)
				{
					spLastY = y;
					y = -100;
				}
				else
				{
					y = (short)(spLastY-1);
				}
				if(spCount>14)
				{
					effect = DELETE;
					spCount = 0;
				}
			}	
			break;
		case 1:
			x = (short)(CastleCanvas.soma.roleX+CastleCanvas.soma.imgW/2);
			y = (short)(CastleCanvas.soma.roleY);
			spCount++;
			if(spCount<=11)
			{
				if(spCount%2==0)
				{
					y -= 2;
				}
				else
				{
					y += 1;
				}
			}
			else if(spCount>11)
			{
				y--;
				if(spCount>=14)
				{
					effect = DELETE;
					spCount = 0;
				}
			}
			break;
		case 2:
			break;
		case 3:
			break;
		}
	}
	private void draw_num(Graphics g,byte pos)
	{
		short lb = 0;
		byte count = 0;
		byte curr = pos;
		lb = loseBlood;
		do
		{
			byte n = (byte)(lb%10);
			g.setClip(sx-count*6,sy,8,8);
			g.drawImage(CastleCanvas.itemEnum,sx-(139+n*8)-count*6,sy-curr,CastleCanvas.imgLT);
			count++;
		}
		while((lb/=10)!=0);
//		red = 35;
//		blue = 43;
	}

	private void draw_bruise(Graphics g)
	{
		switch(bruise)
		{
		case BRUISE_1:
			short[][] plasm = new short[][]{
				{91,50,107,68},
				{108,50,131,68}	
		};
			animation(plasm,g,Enemy.enemy);
			break;
		case BRUISE_2:
			break;
		}
	}
	private void animation(short action[][],Graphics g,Image img)
	{
		byte maxS = 2;
		byte maxF = (byte)action.length;
		short offx = action[frame][0];
		short offy = action[frame][1];
		short imgW = (short)(action[frame][2]-offx);
		short imgH = (short)(action[frame][3]-offy);
		aniSpeed++;
		aniSpeed %= maxS;
		g.setClip(sx,sy,imgW,imgH);
		g.drawImage(img,sx-offx,sy-offy,CastleCanvas.imgLT);
		if(aniSpeed == 0)
		{
			frame++;
			frame %= maxF;
			if(frame==0)
				effect = DELETE;
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -