Proposal: Tilemap changes

That’s what I do:

// rotation : Float
// scale : Float
// positionX : Float
// positionY : Float
// pivotX : Float
// pivotY : Float

var mat = tile.matrix;

mat.a = Math.cos(rotation) * scale;
mat.c = Math.sin(rotation) * scale;
mat.b = - mat.c;
mat.d = mat.a;

// set matrix **before** setting x and y, because they are setters, and they set
// internal flag __transformDirty
tile.x = positionX - pivotX * mat.a - pivotY * mat.c;
tile.y = positionY - pivotX * mat.b - pivotY * mat.d;

It seems that Matrix has method setRotation(theta : Float, scale : Float), but unfortunately it is private :frowning:

1 Like