瀏覽代碼

Update docs for `Tween.stop` to clarify behavior

Apply suggestions from code review

Co-authored-by: A Thousand Ships <[email protected]>
Co-authored-by: Micky <[email protected]>

Updated wording in comments to be more concise
Malcolm Anderson 10 月之前
父節點
當前提交
0304f8fd57
共有 1 個文件被更改,包括 16 次插入0 次删除
  1. 16 0
      doc/classes/Tween.xml

+ 16 - 0
doc/classes/Tween.xml

@@ -280,6 +280,22 @@
 			<return type="void" />
 			<description>
 				Stops the tweening and resets the [Tween] to its initial state. This will not remove any appended [Tweener]s.
+				[b]Note:[/b] This does [i]not[/i] reset targets of [PropertyTweener]s to their values when the [Tween] first started.
+				[codeblock]
+				var tween = create_tween()
+
+				# Will move from 0 to 500 over 1 second.
+				position.x = 0.0
+				tween.tween_property(self, "position:x", 500, 1.0)
+
+				# Will be at (about) 250 when the timer finishes.
+				await get_tree().create_timer(0.5).timeout
+
+				# Will now move from (about) 250 to 500 over 1 second,
+				# thus at half the speed as before.
+				tween.stop()
+				tween.play()
+				[/codeblock]
 				[b]Note:[/b] If a Tween is stopped and not bound to any node, it will exist indefinitely until manually started or invalidated. If you lose a reference to such Tween, you can retrieve it using [method SceneTree.get_processed_tweens].
 			</description>
 		</method>