문제

I want switch between Run and Jump animations, but i have some problems : If the Player run and i tap on the screen, the Player start Jumping (one time), and the Jumpanimation starts but don´t end , so the player is running with the Jumpanimation.

Do you know where my fault is? My code :

// Runanimation + Player Run
public void setRunning()
        {
                canRun = true;

                final long[] PLAYER_ANIMATE = new long[] { 100, 100, 100,};

                animate(PLAYER_ANIMATE, 0, 2, true);
        }
// Jumpanimation + Player Jump 
        public void jump()
        {
                if (footContacts < 1)
                {
                        return;
                }
                body.setLinearVelocity(new Vector2(body.getLinearVelocity().x, 10));

                final long[] PLAYER_JUMP_ANIMATE = new long[] { 100, 100, 100, 100, 100, 100};

                animate(PLAYER_JUMP_ANIMATE, 0, 5,true);

        }

Thx Seref

도움이 되었습니까?

해결책

You are animating with loop boolean set to true, which means its keep looping animation. You should have some kinds of flags (booleans) like jumping and running, so inside set running method you should check if jumping equals true, and if so, stopAnimation() and animate using different frames (in this case running)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top