我正在学习AndEngine Anchor中心,我正在通过食谱。但是我在将图像加载到屏幕时遇到了一些麻烦(代码编译很好)。试图在oncreateResources方法中加载3个矩形(30x40,40x30,70x50),代码编译,但不显示images.Thanks
public class GameActivity extends BaseGameActivity {
// The following constants will be used to define the width and height
// of our game's camera view
private static final int WIDTH = 800;
private static final int HEIGHT = 480;
// Declare a Camera object for our activity
private Camera mCamera;
// Declare a Scene object for our activity
private Scene mScene;
@Override
public EngineOptions onCreateEngineOptions() {
// Define our mCamera object
mCamera = new Camera(0, 0, WIDTH, HEIGHT);
// Declare & Define our engine options to be applied to our Engine
// object
EngineOptions engineOptions = new EngineOptions(true,
ScreenOrientation.LANDSCAPE_FIXED, new FillResolutionPolicy(),
mCamera);
engineOptions.setWakeLockOptions(WakeLockOptions.SCREEN_ON);
return engineOptions;
}
@Override
public void onCreateResources(
OnCreateResourcesCallback pOnCreateResourcesCallback) {
BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("gfx/");
BitmapTextureAtlas mBitmapTextureAtlas = new BitmapTextureAtlas(mEngine.getTextureManager(), 120, 120);
ITextureRegion mRetangleOneTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset(mBitmapTextureAtlas, this, "rectangle_one.png", 10, 10);
ITextureRegion mRetangleTwoTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset(mBitmapTextureAtlas, this, "rectangle_two.png", 50, 10);
ITextureRegion mRetangleThreeTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset(mBitmapTextureAtlas, this, "rectangle_three.png", 10, 60);
mBitmapTextureAtlas.load();
pOnCreateResourcesCallback.onCreateResourcesFinished();
}
@Override
public void onCreateScene(OnCreateSceneCallback pOnCreateSceneCallback) {
mScene = new Scene();
pOnCreateSceneCallback.onCreateSceneFinished(mScene);
}
@Override
public void onPopulateScene(Scene pScene,
OnPopulateSceneCallback pOnPopulateSceneCallback) {
pOnPopulateSceneCallback.onPopulateSceneFinished();
}
}
答案 0 :(得分:1)
我还没有使用中心锚分支,但你的问题似乎是你需要用加载的ITextures创建精灵。然后,您需要在场景中附加这些精灵。