⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mobilebackground.java

📁 一个j2me的3d游戏实例
💻 JAVA
字号:
package game.terrain;

import javax.microedition.m3g.*;


public class MobileBackground 
{
  private final static int STEP = 3;  

  private Background backGnd;
  private boolean isMoveable = false;

  private int width, height;

  public MobileBackground(Image2D backIm, int w, int h)
  {
    width = w;  height = h;
    backGnd = new Background();

    if (backIm != null) {
      backGnd.setImage( backIm );
      backGnd.setImageMode(Background.REPEAT, Background.REPEAT);
      backGnd.setCrop(backGnd.getCropX(), backGnd.getCropY(), width, height);
      isMoveable = true;
    }
    else 
      backGnd.setColor(0x00bffe); 
  }


  public Background getBackground()
  {  return backGnd;  }

  public void moveRight(int factor)
  { if (isMoveable)
      backGnd.setCrop(backGnd.getCropX()-(STEP*factor), 
                      backGnd.getCropY(), width, height);
  } 

  public void moveLeft(int factor)
  { if (isMoveable)
      backGnd.setCrop(backGnd.getCropX()+(STEP*factor), 
                      backGnd.getCropY(), width, height);
  }

}

⌨️ 快捷键说明

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