【问题标题】:Sprite Being Skewed When Rotated旋转时 Sprite 倾斜
【发布时间】:2014-03-21 08:50:58
【问题描述】:

我一直在使用 RatioResolutionPolicy,现在尝试切换到 FillResolutionPolicy。但是每当我设置精灵的旋转()时,它会根据旋转角度以某个角度倾斜。我已经检查了 Entity 类中 applyRotation() 的 andengine 源代码,就是这样。有什么办法可以避免精灵歪斜吗?

protected void applyRotation(final GL10 pGL) { 最终浮动旋转 = this.mRotation;

    if(rotation != 0) {
        final float rotationCenterX = this.mRotationCenterX;
        final float rotationCenterY = this.mRotationCenterY;

        pGL.glTranslatef(rotationCenterX, rotationCenterY, 0);
        pGL.glRotatef(rotation, 0, 0, 1);
        pGL.glTranslatef(-rotationCenterX, -rotationCenterY, 0);
    }
}

【问题讨论】:

  • FillResolutionPolicy 会倾向于这样做,因为它必须在一个轴上拉伸图像(以与场景拉伸相同的量)以使其适合。使用 RatioResolutionPolicy 可能会更好。是什么促使你做出改变?
  • 谢谢...我知道为什么 FillResolution 会这样做,但我改用它是因为与 RatioResolution Policy 相比,它更容易管理屏幕,它在某些屏幕分辨率上给我带来了黑点。有没有办法可以覆盖特定精灵的 onDraw 调用并设置不同的规则来绘制它并避免倾斜?
  • 我认为没有完美的解决方案 - 已经讨论过很多次了。一个流行的想法是使用 RatioResolutionPolicy 但根据屏幕的比例进行调整 - 类似于本问题底部讨论的内容 - stackoverflow.com/questions/11399045/…

标签: android rotation andengine


【解决方案1】:

也许您应该尝试不同的 ResolutionPolicy,例如自定义 CropResolutionPolicy。看一些使用这个的例子,也许它有帮助 AndEngine ResolutionPolicy

【讨论】:

  • 是的,我切换回 RatioResolutionPolicy,我将手动处理一些问题
  • 我尝试了Martin创建的另一个解析策略,来源在这里github.com/sm4/AndEngine/blob/GLES2-AnchorCenter/src/org/…
  • 我写信给你,非常好的政策。您可以根据屏幕边缘设置HUD,而不是根据像素。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-01-05
  • 1970-01-01
  • 2012-10-17
  • 2019-05-09
  • 1970-01-01
相关资源
最近更新 更多