0

太阳系案例可以让节点旋转,我想知道如何让一个物体上下动画?这是太阳系案例代码:

Quaternion orientation1 = Quaternion.axisAngle(new Vector3(0.0f, 1.0f, 0.0f), 0);
Quaternion orientation2 = Quaternion.axisAngle(new Vector3(0.0f, 1.0f, 0.0f), 120);
Quaternion orientation3 = Quaternion.axisAngle(new Vector3(0.0f, 1.0f, 0.0f), 240);
Quaternion orientation4 = Quaternion.axisAngle(new Vector3(0.0f, 1.0f, 0.0f), 360);
ObjectAnimator orbitAnimation = new ObjectAnimator();
orbitAnimation.setObjectValues(orientation1, orientation2, orientation3, orientation4);
orbitAnimation.setPropertyName("localRotation");
orbitAnimation.setEvaluator(new QuaternionEvaluator());
orbitAnimation.setRepeatCount(ObjectAnimator.INFINITE);
orbitAnimation.setRepeatMode(ObjectAnimator.RESTART);
orbitAnimation.setInterpolator(new LinearInterpolator());
orbitAnimation.setAutoCancel(true);
4

2 回答 2

0

我相信,这是错误的考虑。因为ObjectAnimator只能对View的子类(如 TextView、Button 等)进行动画处理。但不包括Node。根据文档,

节点表示场景图层次结构中的转换。它可以包含渲染引擎渲染的可渲染对象。

您需要对Node进行更多研究 才能进行旋转

于 2018-11-20T07:54:04.780 回答
0

我在这段代码中工作:

Vector3 vector1 = new Vector3(getRandom(), getRandom(), playNode.getLocalPosition().z);
    ObjectAnimator dropAnimation = new ObjectAnimator();
    dropAnimation.setObjectValues(vector1);
    dropAnimation.setPropertyName("localPosition");
    dropAnimation.setEvaluator(new Vector3Evaluator());
    dropAnimation.setRepeatCount(ObjectAnimator.INFINITE);
    dropAnimation.setRepeatMode(ObjectAnimator.RESTART);
    dropAnimation.setInterpolator(new LinearInterpolator());
    dropAnimation.setAutoCancel(true);

    return dropAnimation;
于 2018-11-21T01:46:48.827 回答