0

There is a hello animation example, where, apparently, predefined character with predefined animations is used.

But what if I want to create some animation on-the-fly, programmatically? Suppose I want just cube perform some movements and rotations?

I found a class Animation which allows adding a tracks. One of the tracks type is SpatialTrack which has obvious structure: it apparently consists of a series of transformations and rotations over time.

But what to do with such an object, once it was created? How to "apply" or "execute" it on some geometry?

UPDATE

I found another pattern: first create MotionPath, then wrap it into MotionEvent and then add resulting object to the object you want to behave with addControl() method. Probably object will follow the path. Unfortunately, I can't find, how to set the orientation. Despite the fact that MotionEvent class has getRotation() method, which is documented as returning rotation of target object, I can't see any methods to set rotations in MotionPath, which constitues the MotionEvent.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Suzan Cioc
  • 29,281
  • 63
  • 213
  • 385

1 Answers1

1

I recommend using Cinematics for what you are attempting to do. All you have to do is create a cinematic object, add the appropriate events to it, and then use objectName.play().

The best part is that you are able to use both your original idea of animation objects as well as through your edited idea of using MotionPaths. You just have to use AnimationEvents and MotionEvents respectively.

You can also implement looping through a simple function that the wikipedia page gives you as well as being able to set direction for the movement.

Matthew Ludwig
  • 745
  • 6
  • 24