📄 drawboard.java
字号:
import javax.microedition.lcdui.*;
//Download by http://www.codefans.net
public class DrawBoard extends mmae.ui.Base
{
public static final int UP = 0;
public static final int DOWN = 1;
public static final int LEFT = 2;
public static final int RIGHT = 3;
private int offSetV,offSetH;
private Image img;
private int way,oldWay;
private boolean is360D;
private int imgWidth,imgHeight;
private int speed=1;
private boolean auto = true;
public DrawBoard(Image image)
{
img = image;
imgWidth = img.getWidth();
imgHeight = img.getHeight();
offSetH = offSetV = 0;
is360D = true;
way = oldWay = LEFT;
}
public boolean isAuto()
{
return auto;
}
public void setAuto(boolean Auto)
{
auto = Auto;
}
public void set360(boolean Is360)
{
is360D = Is360;
}
public boolean is360()
{
return is360D;
}
public void setSpeed(int i)
{
speed = i;
}
public int getSpeed()
{
return speed;
}
public void setWay(int Way)
{
if (way==2 || way==3) oldWay=way;
way = Way;
}
public int getWay()
{
return way;
}
public void move()
{
switch(way)
{
case UP://UP
if( offSetH<0 )
offSetH+=speed;
else
if(oldWay==2 || oldWay==3)
setWay(oldWay);
break;
case DOWN://DOWN
if( offSetH>height-imgHeight )
offSetH-=speed;
else
if(oldWay==2 || oldWay==3)
setWay(oldWay);
break;
case LEFT://LEFT
if(is360D)
{
offSetV-=speed;
if( offSetV<(width-imgWidth) ) offSetV=width;
}
else
if( offSetV<0 ) offSetV+=speed;
break;
case RIGHT://RIGHT
if(is360D)
{
offSetV+=speed;
if( offSetV>imgWidth) offSetV=0;
}
else
if( offSetV>width-imgWidth ) offSetV-=speed;
break;
}
}
public void draw(Graphics g)
{
int i1 = g.getClipX();
int j1 = g.getClipY();
int k1 = g.getClipWidth();
int l1 = g.getClipHeight();
g.setClip(left,top,width,height);
for(int i=0;i<=width/imgWidth+1;i++)
g.drawImage(img,offSetV-i*imgWidth+left,offSetH+top,g.TOP|g.LEFT);
g.setClip(i1,j1,k1,l1);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -