renxin111 / andengine

Automatically exported from code.google.com/p/andengine
0 stars 0 forks source link

Andengine Sprites appear as black boxes #68

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Hi! all
I'm developing a simple game application using AndEngine. Its running fine on 
Android Galaxy S3 but when I launch the same app in Micromax Canvas A110, it 
shows black screen instead of showing sprites.
Below is my code. I have extended BaseGameActivity.

@Override
    public EngineOptions onCreateEngineOptions() {
        // TODO Auto-generated method stub
        camera = new Camera(0, 0, CAMERA_WIDTH, CAMERA_HEIGHT);
        engineOptions = new EngineOptions(true, ScreenOrientation.LANDSCAPE_FIXED, new RatioResolutionPolicy(CAMERA_WIDTH,CAMERA_HEIGHT), camera);
        engineOptions.getAudioOptions().setNeedsMusic(true);
        return engineOptions;
    }
    @Override
    public void onCreateResources(OnCreateResourcesCallback pOnCreateResourcesCallback) throws Exception {
        // TODO Auto-generated method stub
        BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("gfx/");

        textureAtlas = new BitmapTextureAtlas(getTextureManager(), 4096, 4096, TextureOptions.BILINEAR_PREMULTIPLYALPHA);

        //TRSplashScreen = BitmapTextureAtlasTextureRegionFactory.createFromAsset(textureAtlas, this, "splash.jpg", 0, 0);
        @SuppressWarnings("unused")
        Drawable obj = getResources().getDrawable(R.drawable.splash);
        TRSplashScreen = BitmapTextureAtlasTextureRegionFactory.createFromResource(textureAtlas, this, R.drawable.splash, 0, 0);
        TRSplashButton = BitmapTextureAtlasTextureRegionFactory.createTiledFromAsset(textureAtlas, this, "btn_choose_vehicle.png", 1280, 676,1,1);

        textureAtlas.load();

        pOnCreateResourcesCallback.onCreateResourcesFinished();
    }
    @Override
    public void onCreateScene(OnCreateSceneCallback pOnCreateSceneCallback) throws Exception {
        // TODO Auto-generated method stub

        splashScene = new Scene();
        //splashScene.setBackground(new Background(Color.WHITE));
        ParallaxBackground background = new ParallaxBackground(0, 0, 0);
        background.attachParallaxEntity(new ParallaxEntity(0, new Sprite(0, 0, TRSplashScreen, mEngine.getVertexBufferObjectManager())));
        splashScene.setBackground(background);
        pOnCreateSceneCallback.onCreateSceneFinished(splashScene);
    }
    @Override
    public void onPopulateScene(Scene pScene, OnPopulateSceneCallback pOnPopulateSceneCallback) throws Exception {
        // TODO Auto-generated method stub
        //music.setLooping(true);
        Sprite button = new Sprite(400, 688, TRSplashButton, this.mEngine.getVertexBufferObjectManager()){
            @Override
            public boolean onAreaTouched(TouchEvent pSceneTouchEvent, float X, float Y) 
            {   
                if(pSceneTouchEvent.isActionDown())
                    setScale(0.8f);
                if (pSceneTouchEvent.isActionUp())
                {
                    setScale(1);
                    registerUpdateHandler(new TimerHandler(0.1f, new ITimerCallback() {

                        @Override
                        public void onTimePassed(TimerHandler pTimerHandler) {
                            // TODO Auto-generated method stub
                            createMenuResources();
                            createMenuScene();
                            populateMenuScene();
                            splashScene.detachSelf();
                            mEngine.setScene(menuScene);
                        }
                    }));
                }
                return true;
            };
        };
        splashScene.attachChild(button);
        splashScene.registerTouchArea(button);

        pOnPopulateSceneCallback.onPopulateSceneFinished();
    }

Please suggest me how to proceed.

Original issue reported on code.google.com by sachin.a...@gmail.com on 5 Mar 2013 at 1:59

Attachments:

GoogleCodeExporter commented 9 years ago
did u figure out the solution to this? I have a similar problem where my 
sprites are loading fine on nexus 4 but show up as black boxes on a galaxy tab 
2 ...

In case you found out how to fix it please share.

Original comment by viral.y....@gmail.com on 2 Apr 2015 at 6:28