2
플레이어를 왼쪽 및 오른쪽으로 움직이는 코드를 작성하고 플레이어가 왼쪽으로 이동하면 하나의 애니메이션이 있고 오른쪽으로 이동하면 다른 애니메이션이 생깁니다. LibGDX 가속도계 - Android
이
은 (DT가 deltaTime입니다) 코드입니다 :// Moving player desktop
if (Gdx.input.isKeyPressed(Keys.A)) // Left
{
position.x -= speed * dt;
currentFrame = animation.getKeyFrame(4 + (int) stateTime);
}
else if (Gdx.input.isKeyPressed(Keys.D)) // Right
{
position.x += speed * dt;
currentFrame = animation.getKeyFrame(8 + (int) stateTime);
}
else // Normal
{
currentFrame = animation.getKeyFrame(12);
}
그래서 나는 또한 가속도계 (모바일 기기) 플레이어를 이동하려는. 나는 그 일을하지만 지금은 플레이어가 왼쪽으로 이동 또는 오른쪽으로 그에게 다른 애니메이션
을주고 있는지 확인하는 방법을 모르는내 코드 :
// Moving player android
// position.x -= Gdx.input.getAccelerometerX() * speed * dt;
if(PLAYER MOVING LEFT)
{
// Player moving left....
currentFrame = animation.getKeyFrame(4 + (int) stateTime);
}
else if (PLAYER MOVING RIGHT)
{
// Player moving right....
currentFrame = animation.getKeyFrame(8 + (int) stateTime);
}
else
currentFrame = animation.getKeyFrame(12);
고마워,이 작품은 다음과 같습니다 : D 그냥 달 산책처럼 가고 있기 때문에 애니메이션 (8-4)을 변경하십시오 : D – KiKo