//Bullets.png /*********************************************************子弹类*/ class BulletsSprite implements Runnable{ private Sprite bullet; private boolean end=true; private int Xbullets=3,Ybullets; public BulletsSprite() { try{ bullet=new Sprite(Image.createImage("/Bullets.png"),9,3); } catch(Exception e){} bullet.setPosition(20,30); Thread tt=new Thread(this); tt.start(); } public void run(){ Graphics g=getGraphics(); while(end){ update(); draw(g); try{Thread.sleep(20);} catch(Exception e){} } } private void update(){ bullet.move(Xbullets,0); } private void draw(Graphics g){ bullet.paint(g); flushGraphics(); } }

评论