android andengine png图像闪烁

时间:2013-02-22 11:39:44

标签: android png andengine

我是andengine游戏开发的新手,我在场景中添加了一个png图像,它在应用程序中显示但它闪烁我不知道为什么,请帮助我,提前致谢。

这是我的代码:

public static final int WIDTH = 800;
public static final int HEIGHT = 480;

private static final int DEFAULT_IMAGE_ROTATION = 90;

private Scene mScene;
private Camera mCamera;

private Sprite mArrowSprite;
private Sprite mMarbleSprite;

private ITextureRegion mArrowTextureRegion;
private ITextureRegion mMarbleTextureRegion;
BitmapTextureAtlas playerTexture;


@Override
public EngineOptions onCreateEngineOptions() 
{
    // TODO Auto-generated method stub

    mCamera = new Camera(0, 0, WIDTH, HEIGHT);

    final FixedStepEngine engine = new FixedStepEngine(new EngineOptions(true,
            ScreenOrientation.LANDSCAPE_FIXED, new RatioResolutionPolicy(
                    WIDTH, HEIGHT), mCamera),60);

    //EngineOptions engineOptions = new EngineOptions(true, ScreenOrientation.LANDSCAPE_FIXED, new FillResolutionPolicy(), mCamera);

    //engineOptions.getRenderOptions().setDithering(false);

    //return engineOptions;

    return engine.getEngineOptions();

}

@Override
public void onCreateResources(
        OnCreateResourcesCallback pOnCreateResourcesCallback)
        throws IOException 
        {
            // TODO Auto-generated method stub

            BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("gfx/");

            BuildableBitmapTextureAtlas mBitmapTextureAtlas = new BuildableBitmapTextureAtlas(mEngine.getTextureManager(), 128, 128, TextureOptions.BILINEAR_PREMULTIPLYALPHA);



            mArrowTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset(mBitmapTextureAtlas, this, "player.png");
            //mMarbleTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset(mBitmapTextureAtlas, this, "marble.png");

            try 
            {
                mBitmapTextureAtlas.build(new BlackPawnTextureAtlasBuilder<IBitmapTextureAtlasSource, BitmapTextureAtlas>(0, 0, 1));
            } 
            catch (TextureAtlasBuilderException e) 
            {
                e.printStackTrace();
            }

            mBitmapTextureAtlas.load();

            this.mEngine.getTextureManager().loadTexture(mBitmapTextureAtlas);

            pOnCreateResourcesCallback.onCreateResourcesFinished();

        }

@Override
public void onCreateScene(OnCreateSceneCallback pOnCreateSceneCallback)
        throws IOException 
        {
            // TODO Auto-generated method stub

            mScene = new Scene();

            mScene.setOnSceneTouchListener(this);

        }

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

        }

}

我在google上搜索并尝试过我发现但未成功的事情

1 个答案:

答案 0 :(得分:0)

您实际上是两次致电mBitmapTextureAtlas.load() 可能 就是问题所在。

128x128 player.png是否足够大?

闪烁也不是一个非常精确的问题描述= P