【问题标题】:SpriteBatch is not applicable for the arguments JAVA libgdxSpriteBatch 不适用于参数 JAVA libgdx
【发布时间】:2014-07-12 10:53:28
【问题描述】:

我正在尝试使用精灵批处理来旋转具有如下纹理的矩形:

game.batch.draw(图像, (float)x, (float)y, (float)42.5, (float)33, (float)85, (float)66, (float)1, (float)1 , (float)angleDegrees);

但我得到了错误:

The method draw(Texture, float, float, float, float, float, float, float, float) in the type SpriteBatch is not applicable for the arguments (Texture, float, float, float, float, float, float, float, float, float)

我认为我有正确数量的参数,它们都是浮点数,我缺少什么。

【问题讨论】:

  • 我在文档中找不到该数学签名:libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/… 请您尝试调用这些方法中的哪一个。
  • @kajacx 绘制一个矩形,其左下角位于 x,y 并拉伸该区域以覆盖给定的宽度和高度。矩形相对于原点偏移 originX、originY。 Scale 指定矩形应围绕 originX、originY 缩放的缩放因子。 Rotation 指定矩形围绕 originX、originY 逆时针旋转的角度。指定者:draw(...) in Batch 参数:region x y originX originY width height scaleX scaleY rotation
  • @kajacx void com.badlogic.gdx.graphics.g2d.Batch.draw(TextureRegion region, float x, float y, float originX, float originY, float width, float height, float scaleX, float scaleY,浮动旋转)
  • 啊,我没有看到那个,因为它需要 TextureRegion 而不是 Texture,但它们不在子类型关系中,因此出现错误。然后尝试将您的纹理转换为TextureRegion

标签: java libgdx spritebatch


【解决方案1】:

您没有正确数量的参数。你有一个浮动太多。 这就是我将它放在编辑器中的方式,以查看这么多参数的问题。

The method draw(
Texture, float, float, float, float, float, float, float, float) 
in the type SpriteBatch is not applicable for the arguments (
Texture, float, float, float, float, float, float, float, float, **float**)

【讨论】:

  • 你确定'(region, x, y, originX, originY, width, height, scaleX, scaleY, rotation)'有什么想法吗?
  • 从您的错误消息中:是的。将错误消息复制到编辑器格式,您可以看到 falsy 参数,这就是我所做的。
  • 您可以在每个编辑器中执行此操作,它只是可视化 java 抱怨哪个参数的工具。
  • ic now 但问题是如果我摆脱了旋转,那么我该如何旋转项目?
猜你喜欢
  • 1970-01-01
  • 2014-10-28
  • 1970-01-01
  • 2014-05-10
  • 2019-06-22
  • 2018-07-19
  • 2015-12-20
  • 1970-01-01
  • 2015-08-03
相关资源
最近更新 更多