2017-06-08 5 views
0

タイルマップとアニメーションがあります。しかし、この地図はこの最後をカバーしており、理由はわかりません。私がアニメーションだけを追加した場合、私はそれを見ることができますが、マップを追加した場合は表示されません。私に答えてください、私は解決策を見つけることができません!Android LibGDX:タイルマップでアニメーションをカバーする

public class MyGdxGame extends ApplicationAdapter implements GestureDetector.GestureListener 
{ 

Texture texture; 
SpriteBatch batch; 
Sprite sprite; 
TextureAtlas textureAtlas; 
Animation animation; 
float time; 
OrthographicCamera orthographicCamera; 

Texture corridore; 
Sprite spriteCorridore; 

TiledMap map; 
OrthogonalTiledMapRenderer renderer; 

@Override 
public void create() { 

    batch = new SpriteBatch(); 
    corridore = new Texture("a.png"); 
    spriteCorridore = new Sprite(corridore); 
    orthographicCamera = new OrthographicCamera(500,500); 
    orthographicCamera.position.x=500; 
    orthographicCamera.position.y=250; 
    map = new TmxMapLoader().load("mappa.tmx"); 
    renderer = new OrthogonalTiledMapRenderer(map); 
    textureAtlas = new TextureAtlas(Gdx.files.internal("corsa.atlas")); 
    animation = new Animation(1/20f,textureAtlas.findRegion("a"),textureAtlas.findRegion("b"), 
      textureAtlas.findRegion("c"),textureAtlas.findRegion("d"),textureAtlas.findRegion("e"), 
      textureAtlas.findRegion("f"),textureAtlas.findRegion("g"),textureAtlas.findRegion("h"), 
      textureAtlas.findRegion("i")); 
} 

@Override 
public void render() { 
    time = time + Gdx.graphics.getDeltaTime(); 
    Gdx.gl.glClearColor(1, 1, 1, 1); 
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); 

    batch.setProjectionMatrix(orthographicCamera.combined); 
    batch.begin(); 
    batch.draw((TextureRegion)animation.getKeyFrame(time,true),orthographicCamera.position.x-spriteCorridore.getWidth()/2,orthographicCamera.position.y-spriteCorridore.getHeight()/2); 
    renderer.setView(orthographicCamera); 
    renderer.render(); 

    orthographicCamera.translate(1, 0); 
    orthographicCamera.update(); 

    batch.end(); 
} 

} 

答えて

1

はので、あなたのレンダリング順序を変更するTiledMapRendererの上部にアニメーションをレンダリングします

は、ここに私のコードです。

@Override 
public void render() { 
    time = time + Gdx.graphics.getDeltaTime(); 
    Gdx.gl.glClearColor(1, 1, 1, 1); 
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); 

    renderer.setView(orthographicCamera); 
    renderer.render(); 

    batch.setProjectionMatrix(orthographicCamera.combined); 
    batch.begin(); 
    batch.draw((TextureRegion)animation.getKeyFrame(time,true),orthographicCamera.position.x-spriteCorridore.getWidth()/2,orthographicCamera.position.y-spriteCorridore.getHeight()/2); 
    batch.end(); 

    orthographicCamera.translate(1, 0); 
    orthographicCamera.update(); 
} 
+0

Yeeeeeeeeeeeeeeeeeeeeeeeeeeeeeessssssssssssssssssssssssssssssssssssssss !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! – Curio

関連する問題