gpt4 book ai didi

android - 我的 Sprite 如何从 andEngine 中的当前位置旋转(平滑旋转)给定角度?

转载 作者:行者123 更新时间:2023-11-29 01:54:32 25 4
gpt4 key购买 nike

目前我正在使用 andEngine 版本 1 在 android 中创建一个游戏演示应用程序。

目前我的 Sprite 旋转的角度如下代码所示

 aircraft.setRotation((float) rotationAngle);

但我的 Sprite 每次都从其初始位置旋转,但我想从其当前位置而不是其初始位置进行旋转。因为在我的游戏应用程序中, Sprite 以不同的角度重复旋转(多次)。所以它看起来很糟糕! (因为每次都有 SCSS )所以我想要我的 Sprite 平滑旋转我该怎么做?

我也使用这段代码进行平滑旋转,但我仍然没有得到平滑旋转..?

//这是为了使飞机平稳旋转

for (int i = 0; i <= rotationAngle; i++) {

_aircraft.setRotation((float) i);

}

最佳答案

如果我没看错你的问题,这就是你想要的:每次调用“setRotation”时,您都希望旋转考虑当前旋转加上“rotationAngle”变量指定的额外旋转量。如果是这样的话,那么解决方案就很简单了。

代替:

 aircraft.setRotation((float) rotationAngle);

使用:

 aircraft.setRotation((float) (aircraft.getRotation()+rotationAngle));

通过这种方式,您可以随时将飞机旋转一个设定角度(rotationAngle),并将该角度添加到飞机的当前旋转角度。

关于android - 我的 Sprite 如何从 andEngine 中的当前位置旋转(平滑旋转)给定角度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15972517/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com