Texture button and rotation point

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By jospic
:warning: Old Version Published before Godot 3 was released.

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) ?

:bust_in_silhouette: Reply From: Wiskam

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.

→ TextureButton1
→ TextureButton2 …

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

func _ready():

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.

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.

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.

jospic | 2016-05-04 14:24