Add support for rotating animations - move the origin to the animation frame center and add xAngle property to Direction enum
This commit is contained in:
@@ -7,18 +7,20 @@ import static java.lang.Math.PI;
|
|||||||
import static org.joml.Math.atan2;
|
import static org.joml.Math.atan2;
|
||||||
|
|
||||||
public enum Direction {
|
public enum Direction {
|
||||||
UP(0, -1),
|
RIGHT(1, 0, 0),
|
||||||
DOWN(0, 1),
|
UP(0, -1, 90),
|
||||||
LEFT(-1, 0),
|
LEFT(-1, 0, 180),
|
||||||
RIGHT(1, 0);
|
DOWN(0, 1, 270);
|
||||||
|
|
||||||
public final int x;
|
public final int x;
|
||||||
public final int y;
|
public final int y;
|
||||||
|
public final int xAngle;
|
||||||
public final Vector2ic vector;
|
public final Vector2ic vector;
|
||||||
|
|
||||||
Direction(int x, int y) {
|
Direction(int x, int y, int xAngle) {
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.y = y;
|
this.y = y;
|
||||||
|
this.xAngle = xAngle;
|
||||||
this.vector = new Vector2i(x, y);
|
this.vector = new Vector2i(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -74,6 +74,6 @@ public class DefaultAnimationManager implements AnimationManager {
|
|||||||
var texture = material.getTexture();
|
var texture = material.getTexture();
|
||||||
var spriteWidth = texture.getWidth() / columns;
|
var spriteWidth = texture.getWidth() / columns;
|
||||||
var spriteHeight = texture.getHeight() / rows;
|
var spriteHeight = texture.getHeight() / rows;
|
||||||
return meshManager.createQuad(spriteWidth, spriteHeight, spriteWidth / 2f, spriteHeight * 0.9f);
|
return meshManager.createQuad(spriteWidth, spriteHeight, spriteWidth / 2f, spriteHeight / 2f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user