Ich habe diesen Code meine Parallaxe Hintergrund für das ZeichnenParallax XY und Rotation - Fliese Berechnung
pGLState.pushModelViewGLMatrix();
final float cameraWidth = pCamera.getWidth();
final float cameraHeight = pCamera.getHeight();
final float shapeWidthScaled = this.mShape.getWidthScaled();
final float shapeHeightScaled = this.mShape.getHeightScaled();
//reposition
float baseOffsetX = (pParallaxValueX * this.mParallaxFactorX);
if (this.mRepeatX) {
baseOffsetX = baseOffsetX % shapeWidthScaled;
while(baseOffsetX > 0) {
baseOffsetX -= shapeWidthScaled;
}
}
float baseOffsetY = (pParallaxValueY * this.mParallaxFactorY);
if (this.mRepeatY) {
baseOffsetY = baseOffsetY % shapeHeightScaled;
while(baseOffsetY > 0) {
baseOffsetY -= shapeHeightScaled;
}
}
//draw
pGLState.translateModelViewGLMatrixf(baseOffsetX, baseOffsetY, 0);
float currentMaxX = baseOffsetX;
float currentMaxY = baseOffsetY;
do {
//rows
this.mShape.onDraw(pGLState, pCamera);
if (this.mRepeatY) {
currentMaxY = baseOffsetY;
//columns
do {
pGLState.translateModelViewGLMatrixf(0, shapeHeightScaled, 0);
currentMaxY += shapeHeightScaled;
this.mShape.onDraw(pGLState, pCamera);
} while(currentMaxY < cameraHeight);
//end columns
pGLState.translateModelViewGLMatrixf(0, -currentMaxY + baseOffsetY, 0);
}
pGLState.translateModelViewGLMatrixf(shapeWidthScaled, 0, 0);
currentMaxX += shapeWidthScaled;
} while (this.mRepeatX && currentMaxX < cameraWidth);
//end rows
pGLState.popModelViewGLMatrix();
Alles funktioniert gut, wenn die Kamera nicht gedreht wird.
Wenn es gedreht wird, denke ich, Kachel (this.mShape
) sollte vier weitere Male (oben, unten, links und rechts) gezeichnet werden, so dass kein leerer Raum in der Ecke sichtbar ist. Zum Beispiel, wenn die Rotation 45 Grad ist, aber ich kann nicht herausfinden, wie das geht.
Können Sie ein Bild aufstellen, das das Problem erklärt? Ich denke ich weiß was du meinst, aber ich will nur sichergehen. – Tim