Commit c629461
committed
RandomFrameSpriteBehavior: Randomize frame progress too
Previously this behaviour would randomize the starting frame of the
parent AnimatedSprite2D. But this can still lead to unwanted
synchronicity between instances of the sprite. For example, in Fray's
End we have a big field of barley. The barley animation has 2 frames
(actually it has 4 but it's 2 unique frames each duplicated once), and
so there are only 4 possible starting positions, leading the field to
have a quite visible lock-step sway.
As well as setting the `frame` property, also set `frame_progress`,
which is the position within the chosen frame (between 0.0 for the start
and 1.0 for the end).
In addition, reset both `frame` and `frame_progress` when saving the
containing scene. (Setting `AnimatedSprite2D.frame` implicitly sets
`AnimatedSprite2D.frame_progress` to `0.0`.) Previously we only cleared
`frame_progress` which means that, for instance, `cat.tscn` has a
particular `frame` saved.1 parent 67fe109 commit c629461
1 file changed
Lines changed: 5 additions & 2 deletions
Lines changed: 5 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
14 | 17 | | |
15 | 18 | | |
16 | 19 | | |
17 | 20 | | |
18 | 21 | | |
19 | | - | |
| 22 | + | |
0 commit comments