📄 mobilebackground.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 + -