From c0f9737c1bb91888af02461d0493045e652f0a97 Mon Sep 17 00:00:00 2001 From: ronny abraham Date: Sat, 16 Nov 2024 22:02:10 +0200 Subject: [PATCH] added custom signals --- _subsections/sec03/lesson-11.org | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/_subsections/sec03/lesson-11.org b/_subsections/sec03/lesson-11.org index f5feae6..30793ef 100644 --- a/_subsections/sec03/lesson-11.org +++ b/_subsections/sec03/lesson-11.org @@ -4,7 +4,8 @@ * Links - [[../../toc.org][TOC - Godot Notes]] -- [[https://www.udemy.com/course/jumpstart-to-2d-game-development-godot-4-for-beginners/learn/lecture/45070477#announcements][S03:L20.11 - Signals]] +- [[https://www.udemy.com/course/jumpstart-to-2d-game-development-godot-4-for-beginners/learn/lecture/45070477#announcements][S03:L22.11 - Signals]] +- [[https://www.udemy.com/course/jumpstart-to-2d-game-development-godot-4-for-beginners/learn/lecture/45070479#announcements][S03:L23.12 - Custom Signals]] * Notes ** signals @@ -43,3 +44,31 @@ - #+ATTR_HTML: :width 600px [[file:../../../_share/media/albert/img/section03/S03_L11_EX03.png]] + +** Custom Signals +*** declare the signal +to create a signal, use the following format: + #+BEGIN_SRC godot + signal name_of_signal + #+END_SRC + +*** activate the signal +#+BEGIN_SRC godot +name_of_signal.emit() +#+END_SRC + +*** register to signal +- go to the scene you want to attach the signal to +- pick the node +- the signal should be available under Inspector->Node->Signals +- connect the signal, and give the function a name you want, this will be your receiver function + - if you want to attach another node to the same receiver function, use "pick" when connecting the signal + - + #+ATTR_HTML: :width 700px + [[file:../../../_share/media/albert/img/section03/S03_L12_EX01.png]] + +- if you have more than one node connected to a receiver function you can see which are connected by clicking on the green icon next to the receiver function + + - + #+ATTR_HTML: :width 600px + [[file:../../../_share/media/albert/img/section03/S03_L12_EX02.png]]