1
我正在读这本名为Android的初级游戏。如何让图像旋转看起来干净? Android GL ES
在它在SpriteBatcher类下面的方法的书......
public void drawSprite(float x, float y, float width, float height, float angle, TextureRegion region) {
float halfWidth = width/2;
float halfHeight = height/2;
float rad = angle * Vector2.TO_RADIANS;
float cos = FloatMath.cos(rad);
float sin = FloatMath.sin(rad);
float x1 = -halfWidth * cos - (-halfHeight) * sin;
float y1 = -halfWidth * sin + (-halfHeight) * cos;
float x2 = halfWidth * cos - (-halfHeight) * sin;
float y2 = halfWidth * sin + (-halfHeight) * cos;
float x3 = halfWidth * cos - halfHeight * sin;
float y3 = halfWidth * sin + halfHeight * cos;
float x4 = -halfWidth * cos - halfHeight * sin;
float y4 = -halfWidth * sin + halfHeight * cos;
x1 += x;
y1 += y;
x2 += x;
y2 += y;
x3 += x;
y3 += y;
x4 += x;
y4 += y;
verticesBuffer[bufferIndex++] = x1;
verticesBuffer[bufferIndex++] = y1;
verticesBuffer[bufferIndex++] = region.u1;
verticesBuffer[bufferIndex++] = region.v2;
verticesBuffer[bufferIndex++] = x2;
verticesBuffer[bufferIndex++] = y2;
verticesBuffer[bufferIndex++] = region.u2;
verticesBuffer[bufferIndex++] = region.v2;
verticesBuffer[bufferIndex++] = x3;
verticesBuffer[bufferIndex++] = y3;
verticesBuffer[bufferIndex++] = region.u2;
verticesBuffer[bufferIndex++] = region.v1;
verticesBuffer[bufferIndex++] = x4;
verticesBuffer[bufferIndex++] = y4;
verticesBuffer[bufferIndex++] = region.u1;
verticesBuffer[bufferIndex++] = region.v1;
numSprites++;
}
我的问题是你如何顺利下方转动像一个图像,使图像不要”中的台词看起来像素化?
我确实拥有合适大小和DPI的图像,并且在旋转之前看起来很棒,但是当它旋转时,线条的边缘看起来并不那么棒。
拍摄了一个屏幕截图,而不是将一些随机图像从互联网上关联到......看看飞机的线条是如此...蹩脚? – Zeveso
是的一种锯齿状。你使用了什么样的抽样,你可以放置你的纹理创建代码?一些反锯齿也可能会有所帮助,但我不知道具体的代码。 – Tim
我在哪里可以阅读有关线性取样的更多信息,以便我可以应用这些?据我所知,我没有使用任何特定类型的抽样。我用来学习的项目的代码在这里:http://beginning-android-games.googlecode.com/svn/trunk/ch09-jumper/ – Zeveso