spritemanager.java~3~
来自「基于数字机顶盒J2me平台开发的互动游戏《金鼠财神》游戏」· JAVA~3~ 代码 · 共 76 行
JAVA~3~
76 行
package WealthGod148;
import javax.microedition.lcdui.*;
import javax.microedition.lcdui.game.*;
import java.io.*;
public class SpriteManager extends LayerManager implements Runnable{
protected Graphics g;
protected Sprites sp;
protected Sprites sp1;
protected Sprites sp2;
protected Image canyu,prize1,prize2;
protected Sprites sp_canyu1,sp_canyu2,sp_prize1,sp_prize2,sp_prize3,sp_prize4;
Thread t;
public SpriteManager(Graphics g) {
this.g = g;
sp = null;
sp1 = null;
sp2 = null;
try {
canyu = Image.createImage("/res/canyu.png");
prize1 = Image.createImage("/res/prize1.png");
prize2 = Image.createImage("/res/prize2.png");
}
catch (IOException ex) {
}
t = new Thread(this);
t.start();
}
public void run()
{
while(true)
{
for(int i=0;i<this.getSize();i++)
{
sp = (Sprites) this.getLayerAt(i);
sp.m_iDrawIndex++;
sp.nextFrame();
if(sp != null)
{
if(sp.Draw() == 1){
this.remove(sp);
sp = null;
}
else
{
if(sp.SPRITE_TYPE == 1)
sp1 = sp;
if(sp.SPRITE_TYPE == 2)
sp2 = sp;
if(sp1 != null && sp2 != null){
if (Math.abs(sp1.x - sp2.x) < 40 && Math.abs(sp1.y - sp2.y) < 40) {
// if(sp2.USERTYPE == 1)
// CreatePrizeSprite_SMS(sp2.x,sp2.y);
// if(sp2.USERTYPE == 0)
// CreatePrizeSprite_VIR(sp2.x,sp2.y);
this.remove(sp2);
// sp2 = null;
}
}
}
}
}
try {
Thread.sleep(20);
}
catch (InterruptedException ex) {}
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?