再次from the documentation,但为了方便使用,我在这里复制了一些,所以我可以更好地解释一下。
x - the x-coordinate in screen space
y - the y-coordinate in screen space
这两个值表示在屏幕空间(游戏空间)中绘制纹理的位置。非常不言自明。
originX - the x-coordinate of the scaling and rotation origin relative to the screen space coordinates
originY - the y-coordinate of the scaling and rotation origin relative to the screen space coordinates
这两个值表示相对于屏幕空间发生旋转(和缩放)的位置。因此,例如,如果您在此处给出值 0, 0,则旋转和缩放将围绕纹理的一个角(我相信是左下角)发生,而如果您给出中心(宽度/2,高度/2 ),旋转和缩放将围绕纹理的中心进行(这可能是您想要的任何“正常”旋转)
width - the width in pixels
height - the height in pixels
在屏幕上绘制纹理的尺寸。
scaleX - the scale of the rectangle around originX/originY in x
scaleY - the scale of the rectangle around originX/originY in y
代表矩形比例的值,其中 0 和 1 之间的值将缩小矩形,大于 1 的值将扩大矩形。请注意,这是相对于您之前给出的原点,这意味着如果这不是中心,图像可能看起来会失真。
rotation - the angle of counter clockwise rotation of the rectangle around originX/originY
图像旋转的角度。同样,这是在前面给出的原点附近,所以如果原点不是图像的中心,旋转可能看起来不“正确”
srcX - the x-coordinate in texel space
srcY - the y-coordinate in texel space
这两个值是您希望使用的图像文件(.png、.jpg 等)的实际区域的起始位置,以像素为单位。基本上是你的形象的开始。
srcWidth - the source with in texels
srcHeight - the source height in texels
同样,这两个值是您正在使用的图像文件的实际区域的宽度和高度,以像素为单位。
flipX - whether to flip the sprite horizontally
flipY - whether to flip the sprite vertically
最后,这两个布尔值用于水平或垂直翻转图像。
现在您可能会注意到类似的method for drawing TextureRegions 没有 srcX、srcY、srcWidth 或 srcHeight。这是因为那些是values you give to a texture region when you create it from a texture。
基本上这意味着命令
//with TextureRegions
SpriteBatch.draw(textureRegion, x, y, originX, originY, width, height, scaleX, scaleY, rotation);
等价于
//with Textures from TextureRegions
SpriteBatch.draw(textureRegion.getTexture(), x, y, originX, originY, width, height, scaleX, scaleY, rotation, textureRegion.getRegionX(), textureRegion.getRegionY(), textureRegion.getRegionWidth(), textureRegion.getRegionHeight(), false, false);