Libgdx 如何将SpriteBatch.draw()等效为Sprite.draw()?

Libgdx 如何将SpriteBatch.draw()等效为Sprite.draw()?,libgdx,Libgdx,我通过在精灵上调用draw,然后在SpriteBatch上调用draw来绘制相同的精灵 target.sprite.draw(game.batch); game.batch.draw(target.sprite, target.sprite.getX(), target.sprite.getY(), target.sprite.getOriginX(), target.sprite.getOriginY(), target.sp

我通过在精灵上调用
draw
,然后在SpriteBatch上调用
draw
来绘制相同的精灵

target.sprite.draw(game.batch);

game.batch.draw(target.sprite, target.sprite.getX(), target.sprite.getY(), 
                target.sprite.getOriginX(), target.sprite.getOriginY(),
                target.sprite.getWidth(), target.sprite.getHeight(),
                target.sprite.getScaleX(), target.sprite.getScaleY(),
                target.sprite.getRotation(), false);
。。。但是第二个调用与第一个调用相比以90度的角度绘制精灵。当我减去90度进行补偿时,精灵不会对齐,因为它们围绕着屏幕上的同一点旋转,但相对于自身的点不同(使用SpriteBatch.draw()调用绘制的点围绕使用Sprite.draw()绘制的点的原点旋转)


如何进行等效的
Sprite.Batch.draw()
调用?

从您发布的代码中可以看出这有点棘手,但我认为您正在调用以下函数:

/** Draws a rectangle with the texture coordinates rotated 90 degrees. The bottom left corner at x,y and stretching the region
 * to cover the given width and height. The rectangle is offset by originX, originY relative to the origin. Scale specifies the
 * scaling factor by which the rectangle should be scaled around originX, originY. Rotation specifies the angle of counter
 * clockwise rotation of the rectangle around originX, originY.
 * @param clockwise If true, the texture coordinates are rotated 90 degrees clockwise. If false, they are rotated 90 degrees
 *           counter clockwise. */
public void draw (TextureRegion region, float x, float y, float originX, float originY, float width, float height, float scaleX, float scaleY, float rotation, boolean clockwise);
这里需要注意的关键点是,第四个和第五个参数不是要旋转的原点,而是相对于该原点的偏移量。如果希望功能与sprite.draw()匹配,则应将0传递为originX和originY

如果您想避免90*旋转(这似乎是非常有意的;我认为可能是这样,您可以将0度或弧度定义为“向上”而不是“向右”,如果这有意义的话),您应该使用该函数的重载版本,该函数省略了最后一个参数(
布尔顺时针


您可以在(正在实现的)的libGDX源代码中找到所有这些内容。

您能详细说明一下为什么要这样做吗?我需要使用动画而不是精灵,因此我必须在游戏批处理中调用draw,而不是在精灵上调用draw。但由于动画未对齐,我尝试使用同一个精灵而不是动画来调用,以消除动画的嫌疑。哦,删除了我以前的评论。它与传递originX和originY无关(传递0不起作用),但它只是使用您建议的重载函数的问题。