Frage

i'm using Clutter and Vala to animate different stuff. But when I for example rotate an actor around the z-axis, it dosen't just spin around itself. Instead it spins around the top-left cornor as if it was the center point. I think it has something to do with a bindcontraint but couldn't find much information about it.

so my question is: how can I make the actor spin around the center point of itself?

any examples is appreciated :) thanks in advance

War es hilfreich?

Lösung

you want to use the Clutter.Actor.pivot_point property, which describes the reference point for all transformations (rotation, scaling, translation).

it's important to note that the pivot_point property is expressed in a normalized coordinate space, relative to the size of the actor itself. so:

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

is the top-left corner of the actor;

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

is the bottom-right corner of the actor; and

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

is the center of the actor — regardless of the values in the Clutter.Actor.width and Clutter.Actor.height properties of the actor.

more information is available in the API reference: https://developer.gnome.org/clutter/stable/ClutterActor.html#ClutterActor--pivot-point

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top