旋转精灵和反旋转

时间:2014-03-14 03:25:24

标签: libgdx game-engine game-physics flappy-bird-clone

我正在构建一款手机游戏并尝试实现与Flappy bird相同的图像旋转概念。

我能够通过重力旋转图像计数器时钟,当我触摸屏幕时,旋转是顺时针

我的问题是当我触摸屏幕以使鸟儿飞翔时,我没有顺时针顺时针旋转。这只鸟看起来就像船一样摇摆。 我知道它与原点有关,但我被困在这里。

查看我的代码

private void updateAnimation(){
    stateTime += Gdx.graphics.getDeltaTime();                      


    if(!Play.hit && Play.state != Play.GAME_OVER)
       currentFrame = walkAnimation.getKeyFrame(stateTime, true); 


     anim = new Sprite(currentFrame);
     anim.setSize(BODY_WIDTH, BODY_HEIGHT);
     anim.setOrigin(BODY_WIDTH/2, BODY_HEIGHT/2);
     anim.setPosition(SCREEN_X-BODY_WIDTH/2, Player.position.y);

     if(Play.state == Play.GAME_RUNNING ){
         if(ANGLE >= -75){

            if(!Gdx.input.justTouched()){
                updateRotation();
            }

         }

         anim.setRotation(getANGLE());
     } 

     anim.draw(batch); 
}

public void  updateRotation(){
    ANGLE = Player.velocity.y / 8;
}

这是顺时针旋转设置的代码

if(GameWorld.ANGLE <= 10){
    GameWorld.setANGLE(5* Gdx.graphics.getDeltaTime());
}
Player.velocity.y = 320;

1 个答案:

答案 0 :(得分:0)

通过批次

旋转纹理区域