英文:
Two manim animations not displaying at the same time
问题
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)
英文:
I have a sample of code that goes like this:
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)
and the third self.play() contains two things that should be going at the same time, but only the scaling is played in the final video. From everything that I've looked at this should be working. Any help is appreciated, and thank you for your time.
答案1
得分: 1
由于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).scale(0.75))
self.wait(1)
英文:
Because of the way animations are handled in Manim, you cannot have two different animations on the same object at the same time. But you can make a composite animation by stacking the individual transformations:
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).scale(0.75))
self.wait(1)
Come over to Discord if you want to learn more tips and tricks
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论