📄 sprites.java~8~
字号:
package WealthGod104;
import javax.microedition.lcdui.*;
import javax.microedition.lcdui.game.*;
public class Sprites extends Sprite implements Runnable {
Graphics g;
protected SpriteManager sm;
protected Image pImage;
protected Sprite sp;
protected int iFrameCount; //精灵帧数
// protected int iFrameStart;
// protected int iFrameEnd;
protected int m_rect_top,m_rect_bottom,m_rect_left,m_rect_right;
protected int x,y,xc,yc,zc,xg,yg;
protected int m_z_way; //z轴当前变化方向
protected int ENUM_STYPE;//1为once,2loop,3BUMPSTOP
protected int SPRITE_TYPE = 0;//自己定义,默认为0
protected int USERTYPE;//VIR=0;SMS=1
protected String szShowID;
protected String szPrize;
protected int m_iDrawWeightBmp;
protected int m_iDrawWeightMem;
protected int m_iDrawHeightBmp;
protected int m_iDrawHeightMem;
protected Thread thread;
public Sprites(Image image,Graphics g,int iFrameCount,int m_rect_top,int m_rect_bottom,int m_rect_left,int m_rect_right,
int x,int y,int xc,int yc) {
super(image);
this.g = g;
this.pImage = image;
this.iFrameCount = iFrameCount;
this.m_rect_top = m_rect_top;
this.m_rect_bottom = m_rect_bottom;
this.m_rect_left = m_rect_left;
this.m_rect_right = m_rect_right;
this.x = x;this.y = y;this.xc=xc;this.yc=yc;this.xg=xg;this.yg=yg;
m_iDrawWeightBmp = image.getWidth();
m_iDrawHeightBmp = image.getHeight()/iFrameCount;
m_iDrawWeightMem = m_iDrawWeightBmp;
m_iDrawHeightMem = m_iDrawHeightBmp;
// sp = new Sprite(pImage,m_iDrawWeightBmp,m_iDrawHeightBmp);
thread.start();
}
public void run() {
while(true){
Draw(g);
}
}
public int Draw(Graphics g){
m_iDrawWeightMem += (zc*m_z_way);
m_iDrawHeightMem += (zc*m_z_way);
sp.setPosition(x,y);
// draw ID
if(szShowID.length()!=0){
g.setColor(255,255,255);
Font indicator = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_BOLD,Font.SIZE_LARGE);
g.setFont(indicator);
g.drawString(szShowID, x+15, y+15,Graphics.BASELINE | Graphics.HCENTER);
}
// draw Prize
if(szPrize.length()!=0){
g.setColor(255, 255, 255);
Font indicator = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_BOLD,
Font.SIZE_LARGE);
g.setFont(indicator);
g.drawString(szPrize, x, y, Graphics.BASELINE | Graphics.HCENTER);
}
if(sp.getFrame() == iFrameCount - 1)
{
if (ENUM_STYPE == 1)
return 1;
}
return ChangPos();
}
public int ChangPos(){
// x
if (xg == 0 && x + m_iDrawWeightBmp > m_rect_right+60)
{
if (ENUM_STYPE == 3)
return 1;
xg = 1;
}
if (xg == 1 && x < m_rect_left-50)
{
if (ENUM_STYPE == 3)
return 1;
xg = 0;
}
if (xg == 0)
x += xc;
else
x -= xc;
// y
if (yg == 0 && y + m_iDrawHeightBmp > m_rect_bottom - 101) // 141是word.bmp的高度
{
if (ENUM_STYPE == 3)
return 1;
yg = 1;
}
if (yg == 1 && y < m_rect_top - 50)
{
if (ENUM_STYPE == 3)
return 1;
yg = 0;
}
if (yg == 0)
y += yc;
else
y -= yc;
return 0;
}
public void appandme(SpriteManager layerManager){
this.sm = layerManager;
layerManager.append(sp);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -