This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

Hi,
for splash screen of my game I have to animate some texture buttons.
Is there any way to change the rotation point (as for sprites by pressing the "V" key) ?
Thanks
-j

in Engine by (1,488 points)

1 Answer

+1 vote
Best answer

Hi Jospic.
When you say "Rotation point", you mean the origin of the rotation right?
If it's the case, you need to place a Node2D where you want your origin point of rotation and attach your TextureButton in this Node2D.

Node2D
-> TextureButton1
-> TextureButton2 ...

With this, you can move around your Node2D (and everything attached to it) to change where your rotation start with

func _ready():
     set_process_input(true)

func _input(event):
     if(event.type == InputEvent.KEY):
      if(event.scancode == KEY_V) && (event.pressed):
               ## Everytime you gonna press V, the rotation will add +0.5 to the current rot position, you can change it to make it smoother or faster.
               get_node("Node2D").set_rot(get_node("Node2D").get_rot()+0.5)

If you want to change the location of your rotation origin, just move around the Node2D like this (the movement won't be smoother with this method):

get_node("Node2D").set_pos( Vector2(x, y) )

Don't know if it's what you would like, but eh.

by (60 points)
selected by

Thaks for reply.
Sorry, my English is not very refined.
To "rotation point" I wanted to say the "center of rotation".
By default sprite rotates around its texture center. With the "v" key , Godot allows you to change the center and move it within the domain of the sprite.
I would like to know if there is also a way to change it for the texture button.

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 Frequently asked questions and 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 [email protected] with your username.