sprite stuck over game area

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

can someone help me please
i try to recreate tetris game following this tutorial

but i encounter a problem when the block almost arrive at bottom and i suddenly rotate it, it become over the game area, what should i do to fix it ?

i try to put box collision at bottom, but because the block only using 2dnode and sprite,it’s not working(i try to put collision box on block node but it’ not working)
is it the problem in my rotate code

func can_rotate(val) -> bool:
if Globals.inactive.has(Vector2(get_parent().position.x+val.x,get_parent().position.y+val.y)) or is_off_screen(Vector2(get_parent().position.x+val.x,get_parent().position.y+val.y)):
	return false
else:
	return true

func is_off_screen(vec) → bool:
if vec.x < 0:
return true
elif vec.x >= get_parent().get_parent().get_rect().size.x:
return true
elif vec.y < 0:
return true
elif vec.y >= get_parent().get_parent().get_rect().size.y:
return true
else:
return false

how to change is_off_screen to sprite size?

thank you for your help

problem