【问题标题】:how to animate/spin actor around it's center point?如何围绕它的中心点动画/旋转演员?
【发布时间】:2013-11-12 17:39:49
【问题描述】:

我正在使用 Clutter 和 Vala 为不同的东西制作动画。但是,例如,当我围绕 z 轴旋转一个演员时,它并不仅仅是围绕自己旋转。相反,它围绕左上角旋转,就好像它是中心点一样。我认为它与绑定约束有关,但找不到太多关于它的信息。

所以我的问题是:如何让演员围绕自身的中心点旋转?

感谢任何例子:)提前感谢

【问题讨论】:

    标签: gnome vala clutter


    【解决方案1】:

    您想使用Clutter.Actor.pivot_point 属性,它描述了所有变换(旋转、缩放、平移)的参考点。

    重要的是要注意pivot_point 属性是在标准化坐标空间中表示的,相对于actor 本身的大小。所以:

    actor.pivot_point = Clutter.Point() { x = 0.0, y = 0.0 };
    

    是演员的左上角;

    actor.pivot_point = Clutter.Point() { x = 1.0, y = 1.0 };
    

    是演员的右下角;和

    actor.pivot_point = Clutter.Point() { x = 0.5, y = 0.5 };
    

    是actor的中心——与actor的Clutter.Actor.widthClutter.Actor.height属性中的值无关。

    更多信息请参见 API 参考:https://developer.gnome.org/clutter/stable/ClutterActor.html#ClutterActor--pivot-point

    【讨论】:

    • 这正是我所要求的。不得不修改代码但基本一样:public Clutter.Point center () { Clutter.Point a; a = Clutter.Point.alloc(); a.init(0.5f, 0.5f); return a; }
    猜你喜欢
    • 1970-01-01
    • 2018-01-17
    • 1970-01-01
    • 1970-01-01
    • 2015-07-27
    • 1970-01-01
    • 2019-07-19
    • 1970-01-01
    • 2013-09-22
    相关资源
    最近更新 更多