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
SPEventTypeCompleted
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
Initialization
-
– 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
-
– addFrameWithTexture:
Adds a frame with a certain texture, using the default duration.
-
– addFrameWithTexture:duration:
Adds a frame with a certain texture and duration.
-
– addFrameWithTexture:duration:sound:
Adds a frame with a certain texture, duration and sound.
-
– addFrameWithTexture:atIndex:
Inserts a frame at the specified index. The successors will move down.
-
– addFrameWithTexture:duration:atIndex:
Adds a frame with a certain texture and duration.
-
– addFrameWithTexture:duration:sound:atIndex:
Adds a frame with a certain texture, duration and sound.
-
– removeFrameAtIndex:
Removes the frame at the specified index. The successors will move up.
-
– setTexture: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.
-
– textureAtIndex:
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 -
totalTime
The total duration of the clip in seconds.
property -
currentTime
The time that has passed since the clip was started (each loop starts at zero).
property -
isPlaying
Indicates if the movie is currently playing. Returns
propertyNO
when the end has been reached. -
isComplete
Indicates if a (non-looping) movie has come to its end.
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
currentTime
The time that has passed since the clip was started (each loop starts at zero).
@property (nonatomic, readonly) double currentTime
Discussion
The time that has passed since the clip was started (each loop starts at zero).
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
isComplete
Indicates if a (non-looping) movie has come to its end.
@property (nonatomic, readonly) BOOL isComplete
Discussion
Indicates if a (non-looping) movie has come to its end.
Declared In
SPMovieClip.h
isPlaying
Indicates if the movie is currently playing. Returns NO
when the end has been reached.
@property (nonatomic, readonly) BOOL isPlaying
Discussion
Indicates if the movie is currently playing. Returns NO
when the end has been reached.
Declared In
SPMovieClip.h
loop
Indicates if the movie is looping.
@property (nonatomic, assign) BOOL loop
Discussion
Indicates if the movie is looping.
Declared In
SPMovieClip.h
Class Methods
Instance Methods
addFrameWithTexture:
Adds a frame with a certain texture, using the default duration.
- (void)addFrameWithTexture:(SPTexture *)texture
Discussion
Adds a frame with a certain texture, using the default duration.
Declared In
SPMovieClip.h
addFrameWithTexture:atIndex:
Inserts a frame at the specified index. The successors will move down.
- (void)addFrameWithTexture:(SPTexture *)texture atIndex:(int)frameID
Discussion
Inserts a frame at the specified index. The successors will move down.
Declared In
SPMovieClip.h
addFrameWithTexture:duration:
Adds a frame with a certain texture and duration.
- (void)addFrameWithTexture:(SPTexture *)texture duration:(double)duration
Discussion
Adds a frame with a certain texture and duration.
Declared In
SPMovieClip.h
addFrameWithTexture:duration:atIndex:
Adds a frame with a certain texture and duration.
- (void)addFrameWithTexture:(SPTexture *)texture duration:(double)duration atIndex:(int)frameID
Discussion
Adds a frame with a certain texture and duration.
Declared In
SPMovieClip.h
addFrameWithTexture:duration:sound:
Adds a frame with a certain texture, duration and sound.
- (void)addFrameWithTexture:(SPTexture *)texture duration:(double)duration sound:(SPSoundChannel *)sound
Discussion
Adds a frame with a certain texture, duration and sound.
Declared In
SPMovieClip.h
addFrameWithTexture:duration:sound:atIndex:
Adds a frame with a certain texture, duration and sound.
- (void)addFrameWithTexture:(SPTexture *)texture duration:(double)duration sound:(SPSoundChannel *)sound atIndex:(int)frameID
Discussion
Adds a frame with a certain texture, duration and sound.
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
initWithFrame:fps:
Initializes a movie with the first frame and the default number of frames per second. Designated initializer.
- (instancetype)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.
- (instancetype)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
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 specified index. The successors will move up.
- (void)removeFrameAtIndex:(int)frameID
Discussion
Removes the frame at the specified index. The successors will move up.
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
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
setTexture:atIndex:
Sets the texture of a certain frame.
- (void)setTexture:(SPTexture *)texture atIndex:(int)frameID
Discussion
Sets the texture of a certain frame.
Declared In
SPMovieClip.h
soundAtIndex:
Returns the sound of a frame at a certain index.
- (SPSoundChannel *)soundAtIndex:(int)frameID
Discussion
Returns the sound of a frame at a certain index.
Declared In
SPMovieClip.h