2013-05-23 2 views
0

키를 누를 때 spaceshipSprite이 화면에 나타나지 않게하려면 어떻게해야합니까? 우주선이 화면에서 나가는 것을 원하지 않습니다.이동 키를 누를 때 화면에 스프라이트 유지

public void render() {  
    if(Gdx.input.isKeyPressed(Keys.DPAD_LEFT)) 
     movex -= Gdx.graphics.getDeltaTime() *speed; 
    if(Gdx.input.isKeyPressed(Keys.DPAD_RIGHT)) 
     movex += Gdx.graphics.getDeltaTime() * speed; 
    if(Gdx.input.isKeyPressed(Keys.DPAD_UP)) 
     moveY += Gdx.graphics.getDeltaTime() * speed; 
    if(Gdx.input.isKeyPressed(Keys.DPAD_DOWN)) 
     moveY -= Gdx.graphics.getDeltaTime() * speed; 
    Gdx.gl.glClearColor(0,0,0,0); 
    Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT); 
    Gdx.gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); 

    batch.setProjectionMatrix(camera.combined); 
    batch.begin(); 
    //sprite.draw(batch); 
    batch.draw(background, 0, 0); 
    batch.draw(spaceshipSprite, movex, moveY); 
    //spaceshipSprite.draw(batch); 
    batch.end(); 
} 

답변

관련 문제