mobilebackground.java

来自「J2ME3D手机赛车游戏 开发环境JBuilder」· Java 代码 · 共 47 行

JAVA
47
字号
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 + =
减小字号Ctrl + -
显示快捷键?