Design Patterns - Observer Pattern with Signals

preview_player
Показать описание
Hey there, after the classes relationship study is time to get known to Design Patterns, they are "typical solutions to commonly occurring
problems in software design". In this video we will see a very old, yet useful one: the Observer Pattern.

################################################

Follow me!

How about becoming my patron?

################################################

#gamedevelopment #gamedesign #programming #designpatterns
Рекомендации по теме
Комментарии
Автор

Hey there! The desktop sound was turned off, so you may not listen to the sound playing, the mic captured the sound effect tho, but the volume is very low.

In this series I'm using 4 references:

Design Patterns Explained Simply, which is a "downgrade" of Dive into Design Patterns, so I dont have the link to acquire it

pigdev
Автор

I've just been watching all of these godot videos because I struggle with keeping my projects clean and well-structured, thanks so much for all your videos, they are really well done and helpful.

HeraldOD
Автор

Great explanation on how to implement the Observer Pattern in Godot! Thank you for that! It really is a helpful pattern to prevent too many checks in the process functions.

What I usually like to do is to move the sognal connection to a parent node. This allows the sibling nodes to still not know about each other. In that example adding a script to the interface and doing something like:
_ready():
$Button.connect("button_up", $ClickSound, "play")

I have no clue whether that's a smart idea to do it like that but I usually dislike the idea of coupling siblings like that. Having the parent control the communication between its children makes sense to me.

Tornadowarnung
Автор

Yeah, but what if i have multiple instances of the same scene? Ho can i connect signal dinamically?

vincipaoloesposito
Автор

I would use _physics_process and would do an onready var button = $"../Button" . Physics process is tied to the physics loop and runs much slower . $ or get_node is a search and is very expensive. By setting the pointer object to the node via onready you only search once.

wizardscrollstudio
Автор

Great explanation on how to implement the Observer Pattern in Godot! Thank you for that! It really is a helpful pattern to prevent too many checks in the process functions.

What I usually like to do is to move the sognal connection to a parent node. This allows the sibling nodes to still not know about each other. In that example adding a script to the interface and doing something like:
_ready():
$Button.connect("button_up", $ClickSound, "play")

I have no clue whether that's a smart idea to do it like that but I usually dislike the idea of coupling siblings like that. Having the parent control the communication between its children makes sense to me.

Tornadowarnung