2012-09-26 3 views
2

Autoparallax AndEngine 검정 화면이 나타납니다.Autoparallax and blackgine : 검은 색 화면

public class MainActivity extends SimpleBaseGameActivity { 
    static final int CAMERA_WIDTH = 480; 
    static final int CAMERA_HEIGHT = 320; 
    int k = 700; 
    public Font mFont; 
    public Camera mCamera; 

    // A reference to the current scene 
    public Scene mCurrentScene; 

    public BitmapTextureAtlas mAutoParallaxBackgroundTexture; 
    public TextureRegion mParallaxLayer; 

    public static MainActivity instance; 

    public static MainActivity getSharedInstance() { 
     return instance; 
    } 

    @Override 
    public EngineOptions onCreateEngineOptions() { 
     instance = this; 
     mCamera = new Camera(0, 0, CAMERA_WIDTH, CAMERA_HEIGHT); 

     return new EngineOptions(true, ScreenOrientation.LANDSCAPE_FIXED, new RatioResolutionPolicy(CAMERA_WIDTH, CAMERA_HEIGHT), 
       mCamera); 
    } 

    @Override 
    protected void onCreateResources() { 
     BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("gfx/"); 

     mAutoParallaxBackgroundTexture = new BitmapTextureAtlas(this.getTextureManager(), 1024, 1024, TextureOptions.DEFAULT); 

     mParallaxLayer = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.mAutoParallaxBackgroundTexture, this, 
       "background.png", 0, 0); 
    } 

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

     mCurrentScene = new Scene(); 

     final AutoParallaxBackground autoParallaxBackground = new AutoParallaxBackground(0, 0, 0, 10); 
     autoParallaxBackground.attachParallaxEntity(new ParallaxEntity(5.0f, new Sprite(0, mCamera.getHeight() 
       - this.mParallaxLayer.getHeight(), this.mParallaxLayer, this.getVertexBufferObjectManager()))); 
     mCurrentScene.setBackground(autoParallaxBackground); 

     return mCurrentScene; 
    } 
} 

답변

1

TextureAtlas를로드하지 않는 것 같습니다. onCreateResources() 블록 끝에 다음을 추가하십시오.

mAutoParallaxBackgroundTexture.load();