SPMovieClip Class Reference
Inherits from | SPImage : SPQuad : SPDisplayObject : SPEventDispatcher : NSObject |
Conforms to | SPAnimatable |
Declared in | SPMovieClip.h |
Overview
An SPMovieClip is a simple way to display an animation depicted by a list of textures.
You can add the frames one by one or pass them all at once (in an array) at initialization time. The movie clip will have the width and height of the first frame.
At initialization, you can specify the desired framerate. You can, however, manually give each frame a custom duration. You can also play a sound whenever a certain frame appears.
The methods play
and pause
control playback of the movie. You will receive an event of type
SP_EVENT_TYPE_MOVIE_COMPLETED
when the movie finished playback. When the movie is looping,
the event is dispatched once per loop.
As any animated object, a movie clip has to be added to a juggler (or have its advanceTime:
method called regularly) to run.
Tasks
Initializers
-
– initWithFrame:fps:
Initializes a movie with the first frame and the default number of frames per second. Designated initializer.
-
– initWithFrames:fps:
Initializes a movie with an array of textures and the default number of frames per second.
-
+ movieWithFrame:fps:
Factory method.
-
+ movieWithFrames:fps:
Factory method.
Frame Manipulation Methods
-
– addFrame:
Adds a frame with the default duration.
-
– addFrame:withDuration:
Adds a frame with a specified duration.
-
– insertFrame:atIndex:
Inserts a frame at the index specified.
-
– removeFrameAtIndex:
Removes the frame at the index specified.
-
– setFrame:atIndex:
Sets the texture of a certain frame.
-
– setSound:atIndex:
Sets the sound that will be played back when a certain frame is active.
-
– setDuration:atIndex:
Sets the duration of a certain frame in seconds.
-
– frameAtIndex:
Returns the texture of a frame at a certain index.
-
– soundAtIndex:
Returns the sound of a frame at a certain index.
-
– durationAtIndex:
Returns the duration (in seconds) of a frame at a certain index.
Playback Methods
-
– play
Start playback. Beware that the clip has to be added to a juggler, too!
-
– pause
Pause playback.
-
– stop
Stop playback. Resets currentFrame to beginning.
Properties
-
numFrames
The number of frames of the clip.
property -
duration
The accumulated duration of all frames.
property -
isPlaying
Indicates if the movie is currently playing.
property -
loop
Indicates if the movie is looping.
property -
currentFrame
The ID of the frame that is currently displayed.
property -
fps
The default frames per second. Used when you add a frame without specifying a duration.
property
Properties
currentFrame
The ID of the frame that is currently displayed.
@property (nonatomic, assign) int currentFrame
Discussion
The ID of the frame that is currently displayed.
Declared In
SPMovieClip.h
duration
The accumulated duration of all frames.
@property (nonatomic, readonly) double duration
Discussion
The accumulated duration of all frames.
Declared In
SPMovieClip.h
fps
The default frames per second. Used when you add a frame without specifying a duration.
@property (nonatomic, assign) float fps
Discussion
The default frames per second. Used when you add a frame without specifying a duration.
Declared In
SPMovieClip.h
isPlaying
Indicates if the movie is currently playing.
@property (nonatomic, readonly) BOOL isPlaying
Discussion
Indicates if the movie is currently playing.
Declared In
SPMovieClip.h
Class Methods
Instance Methods
addFrame:
Adds a frame with the default duration.
- (int)addFrame:(SPTexture *)texture
Discussion
Adds a frame with the default duration.
Declared In
SPMovieClip.h
addFrame:withDuration:
Adds a frame with a specified duration.
- (int)addFrame:(SPTexture *)texture withDuration:(double)duration
Discussion
Adds a frame with a specified duration.
Declared In
SPMovieClip.h
durationAtIndex:
Returns the duration (in seconds) of a frame at a certain index.
- (double)durationAtIndex:(int)frameID
Discussion
Returns the duration (in seconds) of a frame at a certain index.
Declared In
SPMovieClip.h
frameAtIndex:
Returns the texture of a frame at a certain index.
- (SPTexture *)frameAtIndex:(int)frameID
Discussion
Returns the texture of a frame at a certain index.
Declared In
SPMovieClip.h
initWithFrame:fps:
Initializes a movie with the first frame and the default number of frames per second. Designated initializer.
- (id)initWithFrame:(SPTexture *)texture fps:(float)fps
Discussion
Initializes a movie with the first frame and the default number of frames per second. Designated initializer.
Declared In
SPMovieClip.h
initWithFrames:fps:
Initializes a movie with an array of textures and the default number of frames per second.
- (id)initWithFrames:(NSArray *)textures fps:(float)fps
Discussion
Initializes a movie with an array of textures and the default number of frames per second.
Declared In
SPMovieClip.h
insertFrame:atIndex:
Inserts a frame at the index specified.
- (void)insertFrame:(SPTexture *)texture atIndex:(int)frameID
Discussion
Inserts a frame at the index specified.
Declared In
SPMovieClip.h
play
Start playback. Beware that the clip has to be added to a juggler, too!
- (void)play
Discussion
Start playback. Beware that the clip has to be added to a juggler, too!
Declared In
SPMovieClip.h
removeFrameAtIndex:
Removes the frame at the index specified.
- (void)removeFrameAtIndex:(int)frameID
Discussion
Removes the frame at the index specified.
Declared In
SPMovieClip.h
setDuration:atIndex:
Sets the duration of a certain frame in seconds.
- (void)setDuration:(double)duration atIndex:(int)frameID
Discussion
Sets the duration of a certain frame in seconds.
Declared In
SPMovieClip.h
setFrame:atIndex:
Sets the texture of a certain frame.
- (void)setFrame:(SPTexture *)texture atIndex:(int)frameID
Discussion
Sets the texture of a certain frame.
Declared In
SPMovieClip.h
setSound:atIndex:
Sets the sound that will be played back when a certain frame is active.
- (void)setSound:(SPSoundChannel *)sound atIndex:(int)frameID
Discussion
Sets the sound that will be played back when a certain frame is active.
Declared In
SPMovieClip.h