-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a note about SceneTree.create_tween()
method
#81087
Add a note about SceneTree.create_tween()
method
#81087
Conversation
doc/classes/Tween.xml
Outdated
@@ -6,7 +6,8 @@ | |||
<description> | |||
Tweens are mostly useful for animations requiring a numerical property to be interpolated over a range of values. The name [i]tween[/i] comes from [i]in-betweening[/i], an animation technique where you specify [i]keyframes[/i] and the computer interpolates the frames that appear between them. Animating something with a [Tween] is called tweening. | |||
[Tween] is more suited than [AnimationPlayer] for animations where you don't know the final values in advance. For example, interpolating a dynamically-chosen camera zoom value is best done with a [Tween]; it would be difficult to do the same thing with an [AnimationPlayer] node. Tweens are also more light-weight than [AnimationPlayer], so they are very much suited for simple animations or general tasks that don't require visual tweaking provided by the editor. They can be used in a fire-and-forget manner for some logic that normally would be done by code. You can e.g. make something shoot periodically by using a looped [CallbackTweener] with a delay. | |||
A [Tween] can be created by using either [method SceneTree.create_tween] or [method Node.create_tween]. [Tween]s created manually (i.e. by using [code]Tween.new()[/code]) are invalid and can't be used for tweening values. | |||
A [Tween] can be created by using either [method SceneTree.create_tween] or [method Node.create_tween]. [Tween]s created manually (i.e. by using [code]Tween.new()[/code]) are invalid and can't be used for tweening values. | |||
[b]Note:[/b] When creating a [Tween] by using [method SceneTree.create_tween] the [Tween] will be detached from the actual [Node] and it won't be killed when the [Node] is freed. Prefer using [method Node.create_tween] if you want the [Tween] to be automatically killed when the [Node] is freed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this below to the other "Note" cases
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done! I've moved this note to the end of the description section, where the other notes are located.
Tween
class descriptionTween
class description
38a8698
to
639e527
Compare
@AThousandShips I've adjust the PR name and description, squashed all the commits and adjusted the commit message! |
Tween
class descriptionTween
creation in its class description
Like for #81088 (comment), I'd ask to amend the commit message to remove the Conventional Commit boilerplate which is not the format we use in this repo. This PR's title as we adjusted it would make a fine descriptive commit title. |
639e527
to
26f8207
Compare
Final nitpick: in the body of the commit message, you have a lot of past commit messages which are not relevant to the final state of this change: I would edit it to be simply:
|
26f8207
to
99dabaf
Compare
@akien-mga done! I forgot to adjust it earlier, but now the commit description looks good. Thanks for the patient and all the help :) |
99dabaf
to
08892d7
Compare
Looks good! No need to change it further, but FYI, technically that commit message still has a redundant title both in the title field (first line) and the first line of the commit body (third line). In the git log it will look like this:
|
doc/classes/Tween.xml
Outdated
@@ -91,6 +91,7 @@ | |||
[url=https://raw.githubusercontent.com/godotengine/godot-docs/master/img/tween_cheatsheet.webp]Tween easing and transition types cheatsheet[/url] | |||
[b]Note:[/b] Tweens are not designed to be re-used and trying to do so results in an undefined behavior. Create a new Tween for each animation and every time you replay an animation from start. Keep in mind that Tweens start immediately, so only create a Tween when you want to start animating. | |||
[b]Note:[/b] The tween is processed after all of the nodes in the current frame, i.e. node's [method Node._process] method would be called before the tween (or [method Node._physics_process] depending on the value passed to [method set_process_mode]). | |||
[b]Note:[/b] When creating a [Tween] by using [method SceneTree.create_tween] the [Tween] will be detached from the actual [Node] and it won't be killed when the [Node] is freed. Prefer using [method Node.create_tween] if you want the [Tween] to be automatically killed when the [Node] is freed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not entirely true. When a Node is freed, PropertyTweeners that target it will end automatically and Tween will kill itself if it has no Tweeners to animate. I think if Callable's get_object()
return value is reliable, we could add a similar safeguard to MethodTweener and CallbackTweener to prevent errors.
By "not entirely true" I mean that Tween will continue to animate, but it will finish if there is nothing to animate (this is mostly relevant if you are also animating other objects).
Also shouldn't this note be in SceneTree.create_tween()
description instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@KoBeWi I've rewritten the note and moved it to SceneTree
class reference file
08892d7
to
efe7199
Compare
Tween
creation in its class descriptioncreate_tween()
method of Scene
class
create_tween()
method of Scene
classcreate_tween()
method of SceneTree
class
efe7199
to
4447c22
Compare
doc/classes/SceneTree.xml
Outdated
@@ -90,6 +90,7 @@ | |||
<return type="Tween" /> | |||
<description> | |||
Creates and returns a new [Tween]. The Tween will start automatically on the next process frame or physics frame (depending on [enum Tween.TweenProcessMode]). | |||
[b]Note:[/b] When creating a [Tween] using [method SceneTree.create_tween], the [Tween] will be detached from the actual [Node]. It will continue to animate even if the [Node] is freed, but it will automatically finish if there's nothing left to animate. If you want the [Tween] to be automatically killed when the [Node] is freed, prefer using [method Node.create_tween]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[b]Note:[/b] When creating a [Tween] using [method SceneTree.create_tween], the [Tween] will be detached from the actual [Node]. It will continue to animate even if the [Node] is freed, but it will automatically finish if there's nothing left to animate. If you want the [Tween] to be automatically killed when the [Node] is freed, prefer using [method Node.create_tween]. | |
[b]Note:[/b] When creating a [Tween] using this method, the [Tween] will be detached from the actual [Node]. It will continue to animate even if the [Node] is freed, but it will automatically finish if there's nothing left to animate. If you want the [Tween] to be automatically killed when the [Node] is freed, prefer using [method Node.create_tween]. |
No need to mention the method itself here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, mention removed
4447c22
to
c172d1f
Compare
create_tween()
method of SceneTree
classSceneTree.create_tween()
method
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One last comment, otherwise looks ok.
Add note regarding SceneTree.create_tween() method behavior. Co-authored-by: A Thousand Ships <96648715+AThousandShips@users.noreply.github.com> Co-authored-by: Tomek <kobewi4e@gmail.com>
ec33813
to
5030549
Compare
Thanks! |
What I did
create_tween()
method ofSceneTree
class.Closes: #7796 (issue from godot-docs repo)