You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Manim中同一play内两个动画无法同时执行的问题求助

Manim中同时执行两个动画仅缩放生效的问题解决

我编写了如下Manim示例代码:

class IntroToEquation(Scene):
def construct(self):
    equation = MathTex(
        "2^x=3",
        substrings_to_isolate="x",
        font_size=144
    )
    equation.set_color_by_tex("x", YELLOW)

    self.play(FadeIn(equation))
    self.wait(2)
    self.play(equation.animate.to_edge(UP, buff=0.5), equation.animate.scale(0.75))
    self.wait(1)

其中第三个self.play()包含两个应同时执行的动画,但最终视频中仅缩放动画生效。我查阅资料后认为代码逻辑无误,恳请提供帮助,感谢您的时间。

问题根源在于你连续调用equation.animate的方式:Manim中同一个Mobject的多次animate调用会覆盖前序的动画属性,最终只有最后一个操作生效。

要实现两个动画同时执行,有两种可靠写法:

  • 链式调用animate方法(最简洁):将多个动画操作串联在同一个animate实例后
self.play(equation.animate.to_edge(UP, buff=0.5).scale(0.75))
  • 使用AnimationGroup组合动画:如果需要更灵活的动画控制,可创建独立动画对象后组合执行
move_anim = equation.animate.to_edge(UP, buff=0.5)
scale_anim = equation.animate.scale(0.75)
self.play(AnimationGroup(move_anim, scale_anim, lag_ratio=0))

内容的提问来源于stack exchange,提问作者defrood

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.19 00:04:55