If I want to increase sprite.set_region_rect

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Italianes

if I want increase in time sprite.set_region_rect(Rect2(0,0,100,100))
how can I do that?
with cycle for?
or haw I don’t understand?

:bust_in_silhouette: Reply From: Zylo_X

I think it should be like this

$sprite.region_rect = Rect2 ( Vector2 position, Vector2 size )

Or you can just type

$sprite.region_rect= Rect2 ( float x, float y, float width, float height )

Yes, you wrote cool, but I probably didn’t add a little and when I corrected you, you already replied)
I need to change this number in time
let’s say I press a key and see how the sprite appears in parts

Italianes | 2023-03-30 23:52

You can try this

func _input(event):
    if Input.is_key_pressed(KEY_W): # if you pressed W key
        $sprite.region_rect= Rect2 ( float x1, float y1, float width1, float height1 )
    elif Input.is_key_pressed(KEY_Q): # if you pressed Q key
        $sprite.region_rect= Rect2 ( float x2, float y2, float width2, float height2

Zylo_X | 2023-03-31 07:53