0

i am new to andengine game development, i am adding a png image on the scene, it is shown in app but it is flickering i dont know why, kindly help me, Thanks in advance.

Here is my code:

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

        }

}

i have searched on google and tried things i found but no success till

4

1 に答える 1

0

mBitmapTextureAtlas.load()あなたは事実上2回電話しています。それが問題かもしれません

128x128十分な大きさですかplayer.png

また、ちらつきは非常に正確な問題の説明ではありません = P

于 2013-02-26T18:15:08.907 に答える