|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object hermes.animation.Animation
public class Animation
This class is used to store the PImages that make up a single animation and some properties that aid in playing that animation. These properties values should be thought of as "default" for this particular Animation, values that you know will work well or be used the most often.
The key properties are:
If set to true, the AnimatedSprite will immediately switch to the new Animation.
If set to false, this Animation will play to completion before changing If numberOfTimesToPlay is set to INFINITE_LOOPS, it will play to the end of the cycle before switching. Otherwise, the Animation will play through the remaining cycles it has left before switching. Upon completion of playback, if setActiveAnimation has been called one or more times, the AnimatedSprite's activeAnimation will be set to the one specified by the most recent call.
numberOfTimesToPlay - Specifies how many times this animation will play. It can be set to any positive integer value, or INFINITE_LOOPS for looping the Animation infinitely. By default, this is set to INFINITE_LOOPS on construction. If the animation completes playing through its numberOfTimesToPlay and no calls to AnimatedSprite's setActiveAnimation were made, the Animation will display its defaultFrame.
defaultFrame - the index of the frame that completed animations will rest on. By default this is set to 0 (the first frame in the Animation) on construction.
Field Summary |
---|
Fields inherited from interface hermes.animation.AnimationConstants |
---|
INFINITE_LOOPS |
Constructor Summary | |
---|---|
Animation(java.util.ArrayList<PImage> someArrayListOfPImages,
int millisecondsPerFrame)
Builds a new Animation from an ArrayList of PImages and adds it to the Sprite's collection of Animations |
|
Animation(PImage[] someArrayOfPImages,
int millisecondsPerFrame)
Builds a new Animation from a PImage[] and adds it to the Sprite's collection of Animations |
|
Animation(java.lang.String imageSequenceNamePrefix,
int startIndex,
int endIndex,
java.lang.String fileType,
int millisecondsPerFrame)
Builds an Animation from several image files on disk (where each is an individual frame in the Animation), and adds it to the Sprite's collection of Animations |
|
Animation(java.lang.String imageSequenceNamePrefix,
int numberOfImagesToLoad,
java.lang.String fileType,
int millisecondsPerFrame)
Builds an Animation from several image files on disk (where each is an individual frame in the Animation), and adds it to the Sprite's collection of Animations |
Method Summary | |
---|---|
int |
getDefaultFrame()
|
PImage |
getFrame(int index)
|
boolean |
getInterruptible()
|
int |
getMillisecondsPerFrame()
|
int |
getNumberOfFrames()
|
int |
getNumberOfTimesToPlay()
|
void |
setDefaultFrame(int indexOfDefaultFrame)
|
void |
setInterruptible(boolean interruptible)
This is used to determine what happens when an AnimatedSprite's setActiveAnimation is called while this Animation is playing. |
void |
setMillisecondsPerFrame(int millisecondsPerFrame)
Sets how many milliseconds each Animation frame will play for Note: if you only want to change this value for one call to AnimatedSprite's setActiveAnimation, use the overrideMillisecondsPerFrame() method in the AnimatedSprite class. |
void |
setNumberOfTimesToPlay(int numberOfTimesToPlay)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Animation(java.lang.String imageSequenceNamePrefix, int numberOfImagesToLoad, java.lang.String fileType, int millisecondsPerFrame)
The method loads files with numbers starting from 0 to (numberOfImagesToLoad-1) and assumes numerical contiguity
ex. Explosion0.jpg, Explosion1.jpg, Explosion2.jpg would have method call:
addAnimationFromSequenceOfImages("Explosion", 3, ".jpg");
Works with all image filetypes supported by PImage: .gif, .jgp, tga, .png
imageSequenceNamePrefix
- file prefix of all of the images to be loaded into this Animation ex. "Explosion"numberOfImagesToLoad
- total number of images to load (note: your names should be indexed starting from 0)fileType
- file extension including the 'dot' - supports: ".gif" ".jgp" ".tga" ".png"millisecondsPerFrame
- amount of time each frame in the Animation is displayed, in millisecondspublic Animation(java.lang.String imageSequenceNamePrefix, int startIndex, int endIndex, java.lang.String fileType, int millisecondsPerFrame)
The method loads files within the specified number range and assumes numerical contiguity
ex. Explosion1.jpg, Explosion2.jpg, Explosion3.jpg would have method call:
addAnimationFromSequenceOfImages("Explosion", 1, 3, ".jpg");
Works with all image filetypes supported by PImage: .gif, .jgp, tga, .png
imageSequenceNamePrefix
- file prefix of all of the images to be loaded into this Animation ex. "Explosion"startIndex
- starting index to load fromendIndex
- ending index to load fromfileType
- file extension including the 'dot' - supports: ".gif" ".jgp" ".tga" ".png"millisecondsPerFrame
- amount of time each frame in the Animation is displayed, in millisecondspublic Animation(java.util.ArrayList<PImage> someArrayListOfPImages, int millisecondsPerFrame)
someArrayListOfPImages
- an ArrayList of PImages you'd like to use as an Animation for a spritemillisecondsPerFrame
- amount of time each frame in the Animation is displayedpublic Animation(PImage[] someArrayOfPImages, int millisecondsPerFrame)
someArrayOfPImages
- a PImage[] you'd like to use as an Animation for a spritemillisecondsPerFrame
- amount of time each frame in the Animation is displayedMethod Detail |
---|
public int getNumberOfFrames()
public PImage getFrame(int index)
index
- The index of the frame you'd like to retrieve
public int getMillisecondsPerFrame()
public void setMillisecondsPerFrame(int millisecondsPerFrame)
public boolean getInterruptible()
public void setInterruptible(boolean interruptible)
If set to true (default), the AnimatedSprite will immediately switch to the new Animation.
If set to false, this Animation will play to completion before changing (If it is looping, it will play to the end of the Animation. If it isn't looping, the Animation will play through the remaining cycles it has left).
Upon completion of uninterrupted playback, there are two cases:
interruptible
- boolean to specify if Animation should be interruptiblepublic int getNumberOfTimesToPlay()
public void setNumberOfTimesToPlay(int numberOfTimesToPlay)
numberOfTimesToPlay
- the number of times this animation is set to play through all its frames
Note: use INFINITE_LOOPS to set animation to loop infinitelypublic int getDefaultFrame()
public void setDefaultFrame(int indexOfDefaultFrame)
indexOfDefaultFrame
- the index of the default frame
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |