0 votes

I'm trying to show that a button is selected by making it a bit bigger then all the other buttons in this VBoxContainer. I'm using an AnimationPlayer to make the buttons slide in from the right.

I've tried:

func _ready():
    # get children
    list_buttons = get_children() # this gets the children so I can change their size
    list_buttons[1].set_scale(Vector2(200, 100))
    list_buttons[1].set_size(Vector2(200, 100))
    list_buttons[1].set_pos(Vector2(200, 100))
    #none of these set functions do the trick 
    pass

Am I missing some kind of update that I need to be doing?

in Engine by (74 points)
edited by

Not sure if it is the problem or not, but your setting the scale to 200 by 100. That is 200 by 100 times as big. Try setting scale to (1,1).

I did (1.5, 1.5) and it didn't make it 50% bigger.

2 Answers

0 votes
Best answer

I have found that I'm an idiot once again.

You can change the size of nodes in various ways:

set_size(Vector2 (200, 100)) # Change size manually 
set_scale (Vector2(1.5, 1.5)) # Make 50% bigger

When using these you can use them anywhere you like.

func _process(delta):
func _ready():

But if your node is being used in the AnimationPlayer your changes will not be kept when using func _ready(): because your animationPlayer will just use all your keyframes for the nodes you are using. We will need to use func _process(delta): or change the size somewhere after the animation is over.

by (74 points)
0 votes

So it needs to be done in func _process(delta):

func _ready():
    # get children
    list_buttons = get_children()
    list_buttons[0].set_scale(Vector2(1.5, 1.5)) # doesn't work here
    set_process(true)

func _process(delta):
    list_buttons[0].set_scale(Vector2(1.5, 1.5)) # works here

When using Kinematic2D node you can set it's scale, pos, or rotation in func _ready() you cannot seem to do that with a button node. I don't know if I'm doing something wrong but using func _process(delta) seemed to work.

by (74 points)
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.