太阳系的情况可以使节点旋转,我想知道如何使对象上下动画吗? 这是太阳系的案例代码:
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);
答案 0 :(得分:0)
我相信,这是错误的考虑。因为ObjectAnimator只能为View的子类设置动画(例如TextView,Button等)。但不包括Node。 根据文档
节点表示场景图层次结构中的转换。 它可以包含可渲染的内容,以便渲染引擎进行渲染。
您需要对Node进行更多研究以使其旋转
答案 1 :(得分: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;