类型对象 'Animation' 没有属性 'mobject'
type object 'Animation' has no attribute 'mobject'
我练习例子here
从SuccessionExample1开始,只要存在:
Succession(Animation, Mobject(),...
会出现如下错误:
AttributeError: type object 'Animation' has no attribute 'mobject'
我检查了animation.py,发现self.mobject = mobject,即Animation class有mobject属性,那些样本是否过时了?还是其他原因?
这是因为那是旧版本的代码(我在教程中使用的是2月3日的版本),我忘记在你上一个问题中告诉你只渲染更新功能,而不是继承的功能。要使用 Successions,必须更改代码格式,this is the code for the recent version。
如果是 SuccessionExample1:
class SuccessionExample1(Scene):
def construct(self):
number_line=NumberLine(x_min=-2,x_max=2)
text=TextMobject("Text")\
.next_to(number_line,DOWN)
dashed_line=DashedLine(
number_line.get_left(),
number_line.get_right(),
color=YELLOW,
).set_stroke(width=11)
self.add(number_line)
self.wait(0.3)
self.play(
LaggedStart(
*[ShowCreationThenDestruction(dashed_segment)
for dashed_segment in dashed_line],
run_time=5
),
AnimationGroup(
Animation(Mobject(),run_time=2.1),
Write(text),lag_ratio=1
)
)
self.wait()
我练习例子here
从SuccessionExample1开始,只要存在:
Succession(Animation, Mobject(),...
会出现如下错误:
AttributeError: type object 'Animation' has no attribute 'mobject'
我检查了animation.py,发现self.mobject = mobject,即Animation class有mobject属性,那些样本是否过时了?还是其他原因?
这是因为那是旧版本的代码(我在教程中使用的是2月3日的版本),我忘记在你上一个问题中告诉你只渲染更新功能,而不是继承的功能。要使用 Successions,必须更改代码格式,this is the code for the recent version。
如果是 SuccessionExample1:
class SuccessionExample1(Scene):
def construct(self):
number_line=NumberLine(x_min=-2,x_max=2)
text=TextMobject("Text")\
.next_to(number_line,DOWN)
dashed_line=DashedLine(
number_line.get_left(),
number_line.get_right(),
color=YELLOW,
).set_stroke(width=11)
self.add(number_line)
self.wait(0.3)
self.play(
LaggedStart(
*[ShowCreationThenDestruction(dashed_segment)
for dashed_segment in dashed_line],
run_time=5
),
AnimationGroup(
Animation(Mobject(),run_time=2.1),
Write(text),lag_ratio=1
)
)
self.wait()