0 votes

Let's take this example:

https://imgur.com/a/36VrBUe

UPDATE 1:
I have seen that I have to make the posrectangle to (0,0):
posrectangle = new Rect2(0,0, sprite.Size.Width * scale.x, sprite.Size.Height * scale.y);
and then transform the origin, now it is rotating better.
Now I have to find the details to make it work perfect.
.......................

Where I set the relative center rotation about (0.5f,0.95f)

This is what I would like to set by code:

float rot = rotationdegrees * degTorad;
Transform2D t = Transform2D.Identity;
t.x.x = t.y.y = Mathf.Cos(rot);
t.x.y = t.y.x = Mathf.Sin(rot);
t.y.x *= -1;

//Do not know how to set this origin:
t.origin = new Vector2(0.5f,0.95f);
//or
t.origin = new Vector2(pixelsoriginx, pixelsoriginy);

spritebatch.DrawSetTransformMatrix(t);
spritebatch.DrawTextureRectRegion(texture, posrectangle, sourcerectangle, modulate:color);

Where spritebatch is an standard CanvasItem.

How can I make that?, because the rotations are made from (0,0) of the CanvasItem.
What is the equivalent of the image to code?

Thank you!

in Engine by (14 points)

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.