I have problems with transitioning to Godot 4.x from Godot 3.x

Godot Version

4.4.1

Question

How do i rewrite this


To newer version??

I already have this

But i keep getting errors like this

And popup windows, that should appear only if i press gate and about button, are spawning right from game start, with inappropriate resolution

For future reference, if you paste your code in using tick marks (```) at the top and bottom it’s easy to read, and it’s easy for people to copy and paste and show you how your code should look. I’m not re-typing all that.

Instead I will say that your code is in the wrong place. A tween is a fire-and-forget variable. Creating it as a permanent variable at the top of you your class to always exist is a waste of memory. It also means you have to clear it out by running tween.kill() before you run it. Also, a tween executes as soon as you stop giving it instructions, which means you are running it in your _ready() function before everything is in fact even ready, and then never again.

So:

  1. Delete line 3
  2. Take lines 6 to 11 and put them between 15 and 16.
  3. Change line 6 (after you move it) to:
var tween = create_tween()
1 Like

Thanks a lot!

I did this!

extends Window

func _ready():	
	connect("about_to_popup", _on_about_to_popup) 
	connect("close_requested",close_requested)

func _on_about_to_popup():
	var viewport_size = get_viewport().get_visible_rect().size
	self.size = viewport_size  
	var tween = create_tween()	
	tween.set_trans(Tween.TRANS_LINEAR)
	tween.set_ease(Tween.EASE_IN)
	tween.set_trans(Tween.TRANS_LINEAR)
	tween.set_ease(Tween.EASE_IN)
	self.move_to_center()	
	await tween.finished	

func close_requested():
	hide() 

It works but i still get errors
image

If you copy and paste those errors they’re more helpful. You can also expand them and see what line they happened on.