2016-08-31 8 views
0

나는이 슬로우 모션 문제에 집착했다. 슬로우 모션으로 플레이어를 오른쪽과 왼쪽으로 이동하고 싶습니다. 어떻게해야합니까? 플레이어를 이동할 수는 있지만 멋지지 않습니다. 플레이어가 움직일 때 슬로우 모션을보고 싶습니다. 내 코드를 추가했습니다.Libgdx 슬로우 모션을 플레이어에 추가하기

// 편집 됨

플레이어가 y 축을 통과합니다. 나는 왼쪽과 오른쪽으로 움직이기 위해 2 개의 버튼을 가지고있다. 플레이어를 직접 위치로 이동할 수 있습니다. 하지만 슬로우 모션을 사용하고 싶습니다.

this is my PlayScreen screenshot

public float speed = 0.09f; 

buttonimage.addListener(new ClickListener() { 
     public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) 
     { 

      player.position.x -= 300 * speed; 



      return true; 
     } 
    }); 

방법을 렌더링의 나이 페이지에서 Box2D

예를 사용하여

public void render(float delta) { 


    Gdx.gl.glClearColor(0, 0, 2f, 1); 
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); 



    player.position.y += 500 * Gdx.graphics.getDeltaTime(); 
    sb.setProjectionMatrix(camera.combined); 
    sb.begin(); 
    sb.draw(bg, 0, camera.position.y - (camera.viewportHeight/2)); 
    sb.draw(player.texture, player.getPosition().x , player.getPosition().y); 
    for (Tube tube : tubes) { 
     sb.draw(tube.getlefttube(), tube.getposlefttube().x, tube.getposlefttube().y); 
     sb.draw(tube.getrighttube(), tube.getposrighttube().x, tube.getposrighttube().y); 
     sb.draw(tube.getLight() , tube.getPoslight().x , tube.getPoslight().y); 
    } 





    delta*=speed; 
    sb.end(); 
    update(delta); 

    stage.draw(); 


    app.batch.begin(); 
    app.font23.draw(app.batch,"Lights collected :" + dropsGathered , 0, 720); 
    app.batch.end(); 


} 
+0

전체 렌더링 방법을 보여주고 무엇을하고 있는지 더 설명하십시오. 마찬가지로 플레이어가 이미 움직이고 있으며, 특정 키를 누르는 동안 속도를 늦추고 싶습니까? – Tenfour04

+0

내 게시물을 편집했습니다. 내 선수가 y 축을 따라 갈거야. 부드러운 동작을 위해 슬로우 모션에서 좌우로 움직여야합니다. –

+0

모션 용 버튼이 있습니다 –

답변

0

내가 그렇게 얼마나 내가 당신을 말할 수 :

// apply right impulse, but only if max velocity is not reached yet 
if (Gdx.input.isKeyPressed(Keys.D) && vel.x < MAX_VELOCITY) { 
    this.player.body.applyLinearImpulse(0.80f, 0, pos.x, pos.y, true); 
} 

그러면 플레이어에 비례하여 스프라이트를 그릴 수 있습니다 .body

+0

이렇게하면 몸이 움직이지만 내 선수는 움직이지 않습니다. –

+0

플레이어가 어떻게 생겼는지는 모르겠지만 player : class Player에서 상속받은 새로운 플레이어 클래스를 만들어야합니다. 'class MyPlayer extends Player'. 그런 다음 본문 위치에서 MyPlayer의 렌더링 및 그리기 메서드를 재정의합니다. – Marius