# Class AnimationObject

java.lang.Object
com.codename1.ui.animations.AnimationObject

public final class AnimationObject extends Object
An animation object is an element within the timeline that has a visibility state for rendering at a given point in time. E.g. the object can be queried of its position and render itself for any time.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final int`
  `MOTION_TYPE_LINEAR`
  Used to define the motion type used when manipulating an animation property
  `static final int`
  `MOTION_TYPE_SPLINE`
  Used to define the motion type used when manipulating an animation property

- ## Method Summary

  Modifier and Type
  Method
  Description
  `AnimationObject`
  `copy()`
  Creates a copy of the given animation object
  `static AnimationObject`
  `createAnimationImage(Image img, int x, int y)`
  Creates an animation object instance that can define the animation properties for an image
  `static AnimationObject`
  `createAnimationImage(String imageName, Resources res, int x, int y)`
  Creates an animation object instance that can define the animation properties for an image.
  `void`
  `defineFrames(int frameWidth, int frameHeight, int frameDelay)`
  Defines the frames of the animation if this is a frame changing animation (e.g. a sprite of a walking person).
  `void`
  `defineHeight(int motionType, int startTime, int duration, int start, int end)`
  Defines the height of the object starting at the given time/value and ending at the given position
  `void`
  `defineMotionX(int motionType, int startTime, int duration, int start, int end)`
  Defines a motion on the x axis starting at the given time/value and ending at the given position
  `void`
  `defineMotionY(int motionType, int startTime, int duration, int start, int end)`
  Defines a motion on the y axis starting at the given time/value and ending at the given position
  `void`
  `defineOpacity(int motionType, int startTime, int duration, int start, int end)`
  Defines opacity (translucency) starting at the given time/value and ending at the given position.
  `void`
  `defineOrientation(int motionType, int startTime, int duration, int start, int end)`
  Defines a rotation animation starting at the given time/value and ending at the given position
  `void`
  `defineWidth(int motionType, int startTime, int duration, int start, int end)`
  Defines the width of the object starting at the given time/value and ending at the given position
  `int`
  `getEndTime()`
  The end time of the animation determines when we finish actually drawing the animation object.
  `int`
  `getStartTime()`
  The start time of the animation determines when we start actually drawing the animation object.
  `void`
  `setEndTime(int endTime)`
  The end time of the animation determines when we finish actually drawing the animation object.
  `void`
  `setStartTime(int startTime)`
  The start time of the animation determines when we start actually drawing the animation object.

  ### Methods inherited from class Object

  `clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`
  Modifier and Type
  Method
  Description
  `protected Object`
  `clone()`
  `boolean`
  `equals(Object obj)`
  Indicates whether some other object is "equal to" this one.
  `final Class`
  `getClass()`
  Returns the runtime class of an object.
  `int`
  `hashCode()`
  Returns a hash code value for the object.
  `final void`
  `notify()`
  Wakes up a single thread that is waiting on this object's monitor.
  `final void`
  `notifyAll()`
  Wakes up all threads that are waiting on this object's monitor.
  `String`
  `toString()`
  Returns a string representation of the object.
  `final void`
  `wait()`
  Causes current thread to wait until another thread invokes the method or the method for this object.
  `final void`
  `wait(long timeout)`
  Causes current thread to wait until either another thread invokes the method or the method for this object, or a specified amount of time has elapsed.
  `final void`
  `wait(long timeout, int nanos)`
  Causes current thread to wait until another thread invokes the method or the method for this object, or some other thread interrupts the current thread, or a certain amount of real time has elapsed.

- ## Field Details

  - ### MOTION_TYPE_SPLINE

    public static final int MOTION_TYPE_SPLINE
    Used to define the motion type used when manipulating an animation property
    See Also:
      - Constant Field Values

  - ### MOTION_TYPE_LINEAR

    public static final int MOTION_TYPE_LINEAR
    Used to define the motion type used when manipulating an animation property
    See Also:
      - Constant Field Values

- ## Method Details

  - ### createAnimationImage

    public static AnimationObject createAnimationImage(Image img, int x, int y)

    Creates an animation object instance that can define the animation properties for an image

    ###### Parameters

    - `img`: the image to animate within the timeline

    - `x`: position of the animation

    - `y`: position of the animation

    ###### Returns

    new animation object

  - ### createAnimationImage

    public static AnimationObject createAnimationImage(String imageName, Resources res, int x, int y)

    Creates an animation object instance that can define the animation properties for an image. This version of the method is useful while a resource file is in the process of being loaded and not all images are in place. Loading will finish implicitly when the image is first used.

    ###### Parameters

    - `imageName`: the image to animate within the timeline

    - `res`: the resources file from which the image should be fetched.

    - `x`: position of the animation

    - `y`: position of the animation

    ###### Returns

    new animation object

  - ### copy

    public AnimationObject copy()

    Creates a copy of the given animation object

    ###### Returns

    a new instance of the Animation object with the same state

  - ### defineFrames

    public void defineFrames(int frameWidth, int frameHeight, int frameDelay)

    Defines the frames of the animation if this is a frame changing animation (e.g. a sprite of a walking person). Notice that this method must not be invoked more than once or after the image was initilized

    ###### Parameters

    - `frameWidth`: the width of the frame within the image object

    - `frameHeight`: the height of the frame within the image object

    - `frameDelay`: the delay of the frame

  - ### defineMotionX

    public void defineMotionX(int motionType, int startTime, int duration, int start, int end)

    Defines a motion on the x axis starting at the given time/value and ending at the given position

    ###### Parameters

    - `motionType`: the type of the motion (spline/linear)

    - `startTime`: the start time for the motion within the timeline timeframe

    - `duration`: the duration of the motion

    - `start`: the starting position (the value before startTime)

    - `end`: the ending position for the property (the value after endTime)

  - ### defineMotionY

    public void defineMotionY(int motionType, int startTime, int duration, int start, int end)

    Defines a motion on the y axis starting at the given time/value and ending at the given position

    ###### Parameters

    - `motionType`: the type of the motion (spline/linear)

    - `startTime`: the start time for the motion within the timeline timeframe

    - `duration`: the duration of the motion

    - `start`: the starting position (the value before startTime)

    - `end`: the ending position for the property (the value after endTime)

  - ### defineOrientation

    public void defineOrientation(int motionType, int startTime, int duration, int start, int end)

    Defines a rotation animation starting at the given time/value and ending at the given position

    ###### Parameters

    - `motionType`: the type of the motion (spline/linear)

    - `startTime`: the start time for the motion within the timeline timeframe

    - `duration`: the duration of the motion

    - `start`: the starting position (the value before startTime)

    - `end`: the ending position for the property (the value after endTime)

  - ### defineOpacity

    public void defineOpacity(int motionType, int startTime, int duration, int start, int end)

    Defines opacity (translucency) starting at the given time/value and ending at the given position. Values should rance from 0 (transparent) to 255 (opaque).

    ###### Parameters

    - `motionType`: the type of the motion (spline/linear)

    - `startTime`: the start time for the motion within the timeline timeframe

    - `duration`: the duration of the motion

    - `start`: the starting position (the value before startTime)

    - `end`: the ending position for the property (the value after endTime)

  - ### defineWidth

    public void defineWidth(int motionType, int startTime, int duration, int start, int end)

    Defines the width of the object starting at the given time/value and ending at the given position

    ###### Parameters

    - `motionType`: the type of the motion (spline/linear)

    - `startTime`: the start time for the motion within the timeline timeframe

    - `duration`: the duration of the motion

    - `start`: the starting position (the value before startTime)

    - `end`: the ending position for the property (the value after endTime)

  - ### defineHeight

    public void defineHeight(int motionType, int startTime, int duration, int start, int end)

    Defines the height of the object starting at the given time/value and ending at the given position

    ###### Parameters

    - `motionType`: the type of the motion (spline/linear)

    - `startTime`: the start time for the motion within the timeline timeframe

    - `duration`: the duration of the motion

    - `start`: the starting position (the value before startTime)

    - `end`: the ending position for the property (the value after endTime)

  - ### getStartTime

    public int getStartTime()

    The start time of the animation determines when we start actually drawing the animation object. -1 means the duration of the entire animation.

    ###### Returns

    the startTime in timeline time

  - ### setStartTime

    public void setStartTime(int startTime)

    The start time of the animation determines when we start actually drawing the animation object. -1 means the duration of the entire animation.

    ###### Parameters

    - `startTime`: the startTime to set

  - ### getEndTime

    public int getEndTime()

    The end time of the animation determines when we finish actually drawing the animation object. -1 means the duration of the entire animation.

    ###### Returns

    the endTime in timeline time

  - ### setEndTime

    public void setEndTime(int endTime)

    The end time of the animation determines when we finish actually drawing the animation object. -1 means the duration of the entire animation.

    ###### Parameters

    - `endTime`: the endTime to set