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

📄 battlecommand.java

📁 《神州》RPG游戏引擎
💻 JAVA
字号:
import javax.microedition.lcdui.*;



public class BattleCommand {
	public static String COMMAND_ATTACK="攻击"; 
	public static String COMMAND_DEFENCE="防御";
	public static String COMMAND_SKILL="技能";
	public static String COMMAND_ITEM="道具";
	public static String COMMAND_AUTO="自动";
    public static String COMMAND_ESC="逃跑";
    
	public static String[] command;
	private Graphics g;
	private BattleCanvas canvas;	
	private int commandIndex;
	public int getCommandIndex() {
		return commandIndex;
	}
	private int x,y;
	
	public BattleCommand(BattleCanvas canvas)
	{
		this.canvas=canvas;
		this.g=canvas.g;
	}
	public void setCommand(String[] command)
	{
		BattleCommand.command=command;
	}
	public void setPosition(int x,int y)
	{
		this.x=x;
		this.y=y;
	}
    public int getHeight()
    {
        if(command==null || command.length<=0)
        {
            return 0;        
        }
        else
        {
            return command.length*Style.font.getHeight();
        }
    }
    public int getWidth()
    {
        int maxW=0;
        for(int i=0;command!=null && i<command.length;i++)
        {
            if(maxW<Style.font.stringWidth(command[i]))
            {
                maxW=Style.font.stringWidth(command[i]);
            }
        }
        return maxW;
    }
	
	public void nextCommand()
	{
        commandIndex++;
        if(commandIndex>command.length-1)
		{
            commandIndex=0;
		}
	}
	public void prevCommand()
	{
        commandIndex--;
        if(commandIndex<0)
        {
            commandIndex=command.length-1;
        }
	}
	public void paint()
	{    	
    	int w=0,h=0;
    	if(command!=null)
    	{
			for(int i=0;command!=null && i<command.length;i++)
	    	{
	    		if(w<Style.font.stringWidth(command[i]))
	    		{
	    			w=Style.font.stringWidth(command[i]);
	    		}
	    	}
			h=command.length*Style.font.getHeight();
    	}
    	w=w+6;
		g.setColor(Style.bgColor);
        g.fillRect(x,y,w,h);  //对话框背景色
        g.setColor(Style.boardColor);
    	g.drawRect(x,y,w,h); //外框
    	for(int i=0;i<command.length;i++)
    	{
    		if(i==commandIndex)
    		{
	    		//画高亮;
	    		g.setColor(Style.highLight);
	    		g.fillRect(x+1,y+commandIndex*Style.font.getHeight()+1,w-1,Style.font.getHeight()-1);
    		}
    		g.setColor(0x000000);
    		g.drawString(command[i],x+3,y+i*Style.font.getHeight(),Style.LT);
    	}
    	
    	
	}
}

⌨️ 快捷键说明

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