mirror of
https://github.com/flame-engine/flame.git
synced 2025-11-02 11:43:19 +08:00
add invert X or Y axis to position component
This commit is contained in:
committed by
Erick (CptBlackPixel)
parent
1dabf46712
commit
627e12bba2
@ -64,6 +64,8 @@ abstract class PositionComponent extends Component {
|
||||
double x = 0.0, y = 0.0, angle = 0.0;
|
||||
double width = 0.0, height = 0.0;
|
||||
Anchor anchor = Anchor.topLeft;
|
||||
bool renderFlipX = false;
|
||||
bool renderFlipY = false;
|
||||
|
||||
bool debugMode = false;
|
||||
|
||||
@ -128,6 +130,11 @@ abstract class PositionComponent extends Component {
|
||||
final double dy = -anchor.relativePosition.dy * height;
|
||||
canvas.translate(dx, dy);
|
||||
|
||||
// Handle inverted rendering by moving center and flipping.
|
||||
canvas.translate(width / 2, height / 2);
|
||||
canvas.scale(renderFlipX ? -1.0 : 1.0, renderFlipY ? -1.0 : 1.0);
|
||||
canvas.translate(-width / 2, -height / 2);
|
||||
|
||||
if (debugMode) {
|
||||
renderDebugMode(canvas);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user