Skip to content

Commit 889a2fc

Browse files
committed
Fix bad custom animation example
The custom animation example suggests that a stack-allocated AnimationImplementation variable can be used, but this is incorrect. The variable is not copied and so must remain valid while the animation runs. For brevity, I have used a static qualifier to give the variable global lifespan without making it an explicit global variable. I have also added a note about the lifetime of the AnimationImplementation variable.
1 parent 97a39c6 commit 889a2fc

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

source/_guides/graphics-and-animations/animations.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ animation_set_delay(animation, 1000);
187187
animation_set_duration(animation, 1000);
188188
189189
// Create the AnimationImplementation
190-
const AnimationImplementation implementation = {
190+
static const AnimationImplementation implementation = {
191191
.setup = implementation_setup,
192192
.update = implementation_update,
193193
.teardown = implementation_teardown
@@ -198,6 +198,9 @@ animation_set_implementation(animation, &implementation);
198198
animation_schedule(animation);
199199
```
200200

201+
Note that the AnimationImplementation variable is not copied and must remain
202+
valid while the animation is running.
203+
201204
The output of the example above will look like the snippet shown below (edited
202205
for brevity). Note the effect of the easing ``AnimationCurve`` on the progress
203206
value:

0 commit comments

Comments
 (0)