【问题标题】:Rotating a sprite and counter rotation旋转精灵和反向旋转
【发布时间】:2014-03-14 03:25:23
【问题描述】:

我正在开发一款手机游戏,并尝试实现与 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;

【问题讨论】:

  • 我能看到getANGLE() 的代码吗?这可能是找出问题所在的重要部分,getANGLE() 是调整角度的地方。
  • 我让它工作了。而是旋转纹理区域。谢谢

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


【解决方案1】:

改为通过批处理旋转纹理区域

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-01-24
    • 2011-10-03
    • 2013-03-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多