|
我决定采用AndEngine 开始开发游戏
可是一入门就遇到了一个背景图片无法填满整个画面
我的代码如下:
public class DrawSpriter extends BaseGameActivity {
private Camera mCamera;
private static final int CAMERA_WIDTH = 720;
private static final int CAMERA_HEIGHT = 480;
private Texture mTexture;
private Texture mAutoParallaxBackgroundTexture,mFaceTexture;
private TextureRegion mBackgroundTextureRegion;
private TextureRegion mFaceTextureRegion;
@Override
public void onLoadComplete() {
// TODO Auto-generated method stub
}
@Override
public Engine onLoadEngine() {
this.mCamera = new Camera(0, 0, CAMERA_WIDTH, CAMERA_HEIGHT);
return new Engine(new EngineOptions(true, ScreenOrientation.PORTRAIT, new RatioResolutionPolicy(CAMERA_WIDTH, CAMERA_HEIGHT), this.mCamera));
}
@Override
public void onLoadResources() {
this.mTexture = new Texture(1024, 1024, TextureOptions.DEFAULT);
TextureRegionFactory.setAssetBasePath("gfw/");
this.mBackgroundTextureRegion = TextureRegionFactory.createFromAsset(this.mTexture, this, "snake_background.png",0,0);
this.mFaceTexture = new Texture(32, 32, TextureOptions.BILINEAR_PREMULTIPLYALPHA);
this.mFaceTextureRegion = TextureRegionFactory.createFromAsset(this.mFaceTexture, this, "face_box.png", 0, 0);
this.mEngine.getTextureManager().loadTextures(this.mTexture,this.mFaceTexture);
}
@Override
public Scene onLoadScene() {
// TODO Auto-generated method stub
// Toast.makeText(this, "onLoadScene", Toast.LENGTH_LONG).show();
this.mEngine.registerUpdateHandler(new FPSLogger());
final Scene scene = new Scene(2);
scene.setBackgroundEnabled(false);
scene.getLayer(0).addEntity(new Sprite(0, 10, this.mBackgroundTextureRegion));
return scene;
}
}
复制代码
我在assets/gfw 放置了一张背景图,然后用mBackgroundTextureRegion 来载入背景
可是执行之后,背景图只有放在中间
我这张背景图原来的尺寸是640x480
请问我那里做错了呢
有人可以指点一下吗
谢谢 |
|