spritemanager.java~3~

来自「基于数字机顶盒J2me平台开发的互动游戏《金鼠财神》游戏」· JAVA~3~ 代码 · 共 53 行

JAVA~3~
53
字号
package WealthGod105;

import javax.microedition.lcdui.*;
import javax.microedition.lcdui.game.*;

public class SpriteManager extends LayerManager implements Runnable{
  Graphics g;
  protected Sprites sp;
  protected Sprites sp1;
  protected Sprites sp2;
  public SpriteManager() {
    sp = null;
    sp1 = null;
    sp2 = null;
  }

  public void run()
  {
    g = getGraphics();
    while(true)
    {
      for(int i=0;i<this.getSize();i++)
      {
        sp = (Sprites) this.getLayerAt(i);
        if(sp != null)
        {
          if(sp.Draw(g) == 1){
            this.remove(sp);
            sp = null;
          }
          if(sp.SPRITE_TYPE == 1)
            sp1 = sp;
          if(sp.SPRITE_TYPE == 2)
            sp2 = sp;
          if(Math.abs(sp1.x - sp2.x)<40 && Math.abs(sp1.y - sp2.y)<40){

            this.remove(sp2);
          }
        }
      }
    }
  }

  /**
   * getGraphics
   *
   * @return Graphics
   */
  private Graphics getGraphics() {
    return null;
  }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?