mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 10:48:00 +00:00
Use rotation transform to render tapped cards so overlays can be rotated too
This commit is contained in:
@@ -20,6 +20,7 @@ import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment;
|
|||||||
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
|
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
|
||||||
import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType;
|
import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType;
|
||||||
import com.badlogic.gdx.math.Rectangle;
|
import com.badlogic.gdx.math.Rectangle;
|
||||||
|
import com.badlogic.gdx.math.Vector3;
|
||||||
import com.badlogic.gdx.scenes.scene2d.utils.ScissorStack;
|
import com.badlogic.gdx.scenes.scene2d.utils.ScissorStack;
|
||||||
import com.badlogic.gdx.utils.Clipboard;
|
import com.badlogic.gdx.utils.Clipboard;
|
||||||
|
|
||||||
@@ -892,6 +893,23 @@ public class Forge implements ApplicationListener {
|
|||||||
endClip();
|
endClip();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setRotateTransform(float originX, float originY, float rotation) {
|
||||||
|
batch.end();
|
||||||
|
float dx = adjustX(originX);
|
||||||
|
float dy = adjustY(originY, 0);
|
||||||
|
batch.getTransformMatrix().translate(dx, dy, 0);
|
||||||
|
batch.getTransformMatrix().rotate(Vector3.Z, rotation);
|
||||||
|
batch.getTransformMatrix().translate(-dx, -dy, 0);
|
||||||
|
batch.begin();
|
||||||
|
//shapeRenderer.setTransformMatrix(matrix);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clearTransform() {
|
||||||
|
batch.end();
|
||||||
|
batch.getTransformMatrix().idt();
|
||||||
|
batch.begin();
|
||||||
|
}
|
||||||
|
|
||||||
public void drawRotatedImage(Texture image, float x, float y, float w, float h, float originX, float originY, float rotation) {
|
public void drawRotatedImage(Texture image, float x, float y, float w, float h, float originX, float originY, float rotation) {
|
||||||
batch.draw(image, adjustX(x), adjustY(y, h), originX - x, h - (originY - y), w, h, 1, 1, rotation, 0, 0, image.getWidth(), image.getHeight(), false, false);
|
batch.draw(image, adjustX(x), adjustY(y, h), originX - x, h - (originY - y), w, h, 1, 1, rotation, 0, 0, image.getWidth(), image.getHeight(), false, false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -86,10 +86,13 @@ public class FCardPanel extends FDisplayObject {
|
|||||||
Texture image = ImageCache.getImage(card);
|
Texture image = ImageCache.getImage(card);
|
||||||
if (tapped) {
|
if (tapped) {
|
||||||
float edgeOffset = w / 2f;
|
float edgeOffset = w / 2f;
|
||||||
g.drawRotatedImage(image, x, y, w, h, x + edgeOffset, y + h - edgeOffset, tappedAngle);
|
g.setRotateTransform(x + edgeOffset, y + h - edgeOffset, tappedAngle);
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
g.drawImage(image, x, y, w, h);
|
g.drawImage(image, x, y, w, h);
|
||||||
|
|
||||||
|
if (tapped) {
|
||||||
|
g.clearTransform();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user