📄 battlehand.java
字号:
import java.util.*;
import javax.microedition.lcdui.*;
public class BattleHand {
private Vector enemyVC;
private Image hand;
private int enemyIndex;
public BattleHand()
{
hand=Tools.getImage("/pic/hand.png");
}
public void setEnemyVC(Vector vc)
{
enemyVC=vc;
}
public void nextEnemy()
{
enemyIndex++;
if(enemyIndex>enemyVC.size()-1)
{
enemyIndex=0;
}
}
public void prevEnemy()
{
enemyIndex--;
if(enemyIndex<0)
{
enemyIndex=enemyVC.size()-1;
}
}
public void paint(Graphics g)
{
BattleSprite enemy=(BattleSprite)enemyVC.elementAt(enemyIndex);
int x=enemy.getOrgX();
int y=enemy.getOrgY();
g.drawImage(hand,x+enemy.getWidth()/2,y-20+yOffset,Style.CT);
aniHand();
}
int yOffset;
Timer timer;
boolean animing; //正在动的
private void aniHand()
{
if(!animing)
{
timer=new Timer();
TimerTask timerTask=new TimerTask()
{
public void run()
{
yOffset+=5;
if(yOffset>5)yOffset=0;
}
};
timer.schedule(timerTask,0,200);
animing=true;
}
}
public void stopAniHand()
{
if(timer!=null)
{
timer.cancel();
}
animing=false;
}
public int getEnemyIndex() {
return enemyIndex;
}
public void setEnemyIndex(int enemyIndex) {
this.enemyIndex = enemyIndex;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -