杂波没有做完整的动画。在
这是我当前的代码:
from gi.repository import Clutter, Gtk
import sys
def onClick(actor, event):
actor.animatev(Clutter.AnimationMode.LINEAR, 1000, ["x"], [280]) # clutter does not seem to be running this line
actor.animatev(Clutter.AnimationMode.LINEAR, 1000, ["x"], [20])
def main():
Clutter.init(sys.argv)
# Colors
red = Clutter.Color().new(255, 0, 0, 255)
black = Clutter.Color().new(0, 0, 0, 255)
# Create Stage
stage = Clutter.Stage()
stage.set_title("Basic Usage")
stage.set_size(400, 200)
stage.set_color(black)
# Rectangle Actor
actor = Clutter.Rectangle()
actor.set_size(100, 50)
actor.set_position(150, 100)
actor.set_color(red)
actor.set_reactive(True)
actor.connect("button-press-event", onClick)
# Add Actor to the Stage
stage.add_actor(actor)
stage.connect("destroy", lambda w: Clutter.main_quit())
stage.show_all()
Clutter.main()
if __name__ == '__main__':
main()
请看我的问题:
对于那些不喜欢礼物的人,我的问题是用文字描述的: 我要演员从中间移到右边,然后一直移到左边。相反,它只是从中间直接向左移动。在
是什么造成的,我该怎么解决?在
当你对一行接一行的时候
克拉特不用等另一个完成就可以完成这两个任务。这意味着在第二个命令接管之前,第一个命令几乎没有时间移动代理。在
以下是使用“已完成”信号的示例:
^{pr2}$Here is the documentation on clutter animations
Here is the documentation on the "completed" signal
Here is some working example code
尝试以下代码:
就像文档ClutterActor.animate()说:
这意味着以下代码:
完全等同于:
^{pr2}$这就是你所看到的。在
如果要链接两个动画,则必须使用
connect_after
函数连接到ClutterAnimation
的completed
信号,以便杂波可以创建新的动画:我想指出的是,}是不推荐使用的;可以使用显式
animatev()
和{Clutter.KeyframeTransition
或隐式转换来替换它们,例如:它可以任意地比这个复杂;您还需要记住断开
transition-stopped::x
信号处理程序,并恢复缓和状态,以避免每次更改actor的状态时都创建隐式动画,但我将把这作为练习留给读者。在相关问题 更多 >
编程相关推荐