繁体   English   中英

AndEngine不能显示精灵

[英]AndEngine can not shows sprite

在Android Studio中,我尝试使用AndEngine创建一个Sprite,但它无法显示Sprite,它仅显示黑屏。 我搜索并尝试了数小时的其他方法。

结构如下:

-myApplication 
   -andEngine
   -app
      -res
         -drawable
             -stand.png

这是代码:

@Override
    public void onCreateResources() {

        this.mBitmapTextureAtlas = new BitmapTextureAtlas(getTextureManager(), 30, 30, TextureOptions.DEFAULT);
        mPlayerTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromResource(mBitmapTextureAtlas, this, R.drawable.stand, 0, 0);
        mBitmapTextureAtlas.load();

    }

    @Override
    public Scene onCreateScene() {
        this.mEngine.registerUpdateHandler(new FPSLogger()); 

        this.mMainScene = new Scene();
        this.mMainScene.setBackground(new Background(1, 1, 1));

        final Sprite oPlayer = new Sprite(100, 100, mPlayerTextureRegion, getVertexBufferObjectManager());
        this.mMainScene.attachChild(oPlayer);

        return this.mMainScene;
    }

任何帮助将不胜感激

谢谢。

检查您的logcat,这可能是一个例外。

当我检查您的代码时,此行可能是异常原因。

mPlayerTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromResource(mBitmapTextureAtlas, this, R.drawable.stand, 0, 0);

在创建BitmapTextureAtlas对象时,请检查stand.png尺寸,该尺寸不应大于30*30否则传递更大的值。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM