From 4026a6580a36fe80b7fc796033467e7a71a65ca3 Mon Sep 17 00:00:00 2001 From: jaysunxiao Date: Mon, 17 Jan 2022 18:33:01 +0800 Subject: [PATCH] doc --- doc/demo03_lifecycle/image/owner01.png | Bin 0 -> 3595 bytes doc/demo03_lifecycle/image/owner01.png.import | 34 ++++++++++++++++ doc/demo03_lifecycle/lifecycle.md | 37 ++++++++++++++++++ doc/demo04_signal/signal.md | 22 ++++++++++- 4 files changed, 92 insertions(+), 1 deletion(-) create mode 100644 doc/demo03_lifecycle/image/owner01.png create mode 100644 doc/demo03_lifecycle/image/owner01.png.import diff --git a/doc/demo03_lifecycle/image/owner01.png b/doc/demo03_lifecycle/image/owner01.png new file mode 100644 index 0000000000000000000000000000000000000000..77447ab0cb2cf15f5b6c64a9f242a6d4d18778bc GIT binary patch literal 3595 zcmeH~`CC(08pmZU(h&h2N1!64)v4$xP(jf~mZEG*B@8YI0ir}%Opp$cM3y8iRg@x9 zQCR{QEc=qg5R(8QM2dh^mQo-I2@o-?S%`p1Ac16Vd}f|`oc;mxOMkido^zgi&wD=K z_x+x8vw{Ns%r@`bykWxzvs3=w!N6U(VS^Fv<4wR*)!C>Hp#Qg1-d^W!l*q@ln1{DY zyBBpw7B8MK8nk>>`NV(!N6o`FJE)H;Plt>JQxI`h^d_JB^R;t~3lUP%Gh?s)Rz}U6 z|D4tC&@BKh6Vufur%!)-vtlptlrsesIeWud?2_a>pzSTO@0bm+Im!-tKBo;1koNw` zm&pIr8@YA2>&M${Zr(9F@nX|wQQvQ+w(mH&+FzF{m17X1HY`dd8aG)n(nE4D!j3ovZEAr>Fv!;u2Q3Dv~Y_ z=p)nAwhbnrlm^4#6V6llaW%I^X|q%J^C6vVg3WTOG1Y4mHy!W4(}|WVO(oBtbZqp< z+IZWXN9Q@k@|}16@u{zU+>ibI1YC3QIsmz#PI-{pe26^DH#}BE*AUIcfh< z`Rp6MqwBEvu0K-k*-CYKwx8F>no`yB`lO}{y4y$1QyUCHyQ@8dDQqg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6zaF_wRtyLQl}Pet1l{I|}Ie7aRC^VZ?hlIi5w6#uHyNv3 zN)RDe5a9b?*YJJAXb$^evAUmx03~E!5wmrY(s9Fe((=AvfD14pgX-_#0sl0^+jh~a z?BZ and it's owner is <" + owner_name + ">" ) + +``` + +``` +node_3's parent is and it's owner is +node_2's parent is and it's owner is +node_1's parent is and it's owner is +node_0's parent is and it's owner is +``` + +- 动态创建的节点的Owner是null \ No newline at end of file diff --git a/doc/demo04_signal/signal.md b/doc/demo04_signal/signal.md index 3d09109..1137bda 100644 --- a/doc/demo04_signal/signal.md +++ b/doc/demo04_signal/signal.md @@ -53,8 +53,28 @@ disconnect("mySignal", 1, 2) # 3. 异步回调yield - yield, to produce a result, answer, or piece of information,立即结束当前函数调用,无需等待 + +``` +其本质,就是能让一个函数在执行过程中暂停(挂起),然后在接收到恢复指令以后继续执行的机制。 +``` + - yield(obj, signal),函数立即返回,并且保存当前执行的位置和状态 + +``` +GDScriptFunctionState yield( Object object=null, String signal="" ) +``` + - yield返回GDScriptFunctionState类型对象,类似于Java的CompleteFuture + +``` +GDScriptFunctionState 是记录一个协程状态的对象,实际上它就代表(引用)着该协程。 +``` + - resume恢复GDScriptFunctionState保存的调用函数状态 -![Image text](image/yield.JPG) \ No newline at end of file +![Image text](image/yield.JPG) + +- yield的三种用法 +1. yield()和resmue()组合,yield()来挂起,用resmue()来恢复 +2. yield(节点对象N,信号S)的形式,把这个协程(即 GDScriptFunctionState)注册为 节点N上信号S的接收者,当 节点N发出信号S以后,函数会恢复执行。 +3. yield(协程对象C,"completed")的形式,协程失效(即GDScriptFunctionState的is_valid为false)以后,它会释放一个"completed"信号,用这个信号恢复上一层协程。