1

最近、AndEngine について学び始めましたが、実行に問題があります。基本についてのチュートリアルを学んでいて、ロードしたいのですがpng image、エラーが発生してプロジェクトが失敗しています。

ここにソースコードがあります

public class MainActivity extends BaseGameActivity {
    protected static final int WIDTH = 800;
    public static final int HEIGHT = 460;
    BitmapTextureAtlas playerTexture;
    ITextureRegion playerTexureRegion;
    Scene scene;

    @Override
    public EngineOptions onCreateEngineOptions() {
        Camera mCamera = new Camera(0, 0, WIDTH, HEIGHT);
        EngineOptions engine = new EngineOptions(true, ScreenOrientation.LANDSCAPE_FIXED, new RatioResolutionPolicy(WIDTH, HEIGHT), mCamera);

        return engine;
        // TODO Auto-generated method stub

    }

    @Override
    public void onCreateResources(OnCreateResourcesCallback pOnCreateResourcesCallback) throws Exception {
        // TODO Auto-generated method stub
        loadsfx();
        pOnCreateResourcesCallback.onCreateResourcesFinished();
    }

    private void loadsfx() {
    // TODO Auto-generated method stub
        BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("assets/");

        playerTexture = new BitmapTextureAtlas(getTextureManager(),64,64);
        playerTexureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset(playerTexture, this, "fred1.png",0,0);
        playerTexture.load();
    }

    @Override
    public void onCreateScene(OnCreateSceneCallback pOnCreateSceneCallback) throws Exception {
        // TODO Auto-generated method stub
        this.scene = new Scene();
        this.scene.setBackground(new Background(0,125,58));

        pOnCreateSceneCallback.onCreateSceneFinished(this.scene);

    }

    @Override
    public Engine onCreateEngine(EngineOptions pEngineOptions) {
        // TODO Auto-generated method stub
        return super.onCreateEngine(pEngineOptions);
    }

    @Override
    public void onPopulateScene(Scene pScene, OnPopulateSceneCallback pOnPopulateSceneCallback) throws Exception {
        // TODO Auto-generated method stub

        Sprite sPlayer = new Sprite(WIDTH / 2, HEIGHT / 2, playerTexureRegion, this.mEngine.getVertexBufferObjectManager());
        sPlayer.setRotation(45.0f);
        this.scene.attachChild(sPlayer);
        pOnPopulateSceneCallback.onPopulateSceneFinished();
    }

これがLogCatが言っていることです

05-20 18:11:28.110: E/AndEngine(6616): at android.content.res.AssetManager.openAsset(Native Method)
05-20 18:11:28.110: E/AndEngine(6616): at android.content.res.AssetManager.open(AssetManager.java:315)
05-20 18:11:28.110: E/AndEngine(6616): at android.content.res.AssetManager.open(AssetManager.java:289)
05-20 18:11:28.110: E/AndEngine(6616): at org.andengine.opengl.texture.atlas.bitmap.source.AssetBitmapTextureAtlasSource.onLoadBitmap(AssetBitmapTextureAtlasSource.java:86)
05-20 18:11:28.110: E/AndEngine(6616): at org.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlas.writeTextureToHardware(BitmapTextureAtlas.java:154)
05-20 18:11:28.110: E/AndEngine(6616): at org.andengine.opengl.texture.Texture.loadToHardware(Texture.java:137)
05-20 18:11:28.110: E/AndEngine(6616): at org.andengine.opengl.texture.TextureManager.updateTextures(TextureManager.java:254)
05-20 18:11:28.110: E/AndEngine(6616): at org.andengine.engine.Engine.onDrawFrame(Engine.java:613)
05-20 18:11:28.110: E/AndEngine(6616): at org.andengine.opengl.view.EngineRenderer.onDrawFrame(EngineRenderer.java:105)
05-20 18:11:28.110: E/AndEngine(6616): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1363)
05-20 18:11:28.110: E/AndEngine(6616): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1118)

エンジンについて学びたいと強く思っていますが、うまくいきません。

4

1 に答える 1

1
BitmapTextureAtlasTextureRegionFactory.setAssetBasePath(path);

"setAssetBasePath" set assets path from "assets" directory. In your code full path to sprite image must be "/assets/assets/fred1.png". If path to sprite "/assets/fred1.png" simply delete BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("assets/");

于 2013-05-20T15:11:53.600 に答える