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
-
– playStart playback. Beware that the clip has to be added to a juggler, too!
-
– pausePause playback.
-
– stopStop playback. Resets currentFrame to beginning.
Properties
-
numFramesThe number of frames of the clip.
property -
totalTimeThe total duration of the clip in seconds.
property -
currentTimeThe time that has passed since the clip was started (each loop starts at zero).
property -
isPlayingIndicates if the movie is currently playing. Returns
propertyNOwhen the end has been reached. -
isCompleteIndicates if a (non-looping) movie has come to its end.
property -
loopIndicates if the movie is looping.
property -
currentFrameThe ID of the frame that is currently displayed.
property -
fpsThe 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 currentFrameDiscussion
The ID of the frame that is currently displayed.
Declared In
SPMovieClip.hcurrentTime
The time that has passed since the clip was started (each loop starts at zero).
@property (nonatomic, readonly) double currentTimeDiscussion
The time that has passed since the clip was started (each loop starts at zero).
Declared In
SPMovieClip.hfps
The default frames per second. Used when you add a frame without specifying a duration.
@property (nonatomic, assign) float fpsDiscussion
The default frames per second. Used when you add a frame without specifying a duration.
Declared In
SPMovieClip.hisComplete
Indicates if a (non-looping) movie has come to its end.
@property (nonatomic, readonly) BOOL isCompleteDiscussion
Indicates if a (non-looping) movie has come to its end.
Declared In
SPMovieClip.hisPlaying
Indicates if the movie is currently playing. Returns NO when the end has been reached.
@property (nonatomic, readonly) BOOL isPlayingDiscussion
Indicates if the movie is currently playing. Returns NO when the end has been reached.
Declared In
SPMovieClip.hloop
Indicates if the movie is looping.
@property (nonatomic, assign) BOOL loopDiscussion
Indicates if the movie is looping.
Declared In
SPMovieClip.hClass Methods
Instance Methods
addFrameWithTexture:
Adds a frame with a certain texture, using the default duration.
- (void)addFrameWithTexture:(SPTexture *)textureDiscussion
Adds a frame with a certain texture, using the default duration.
Declared In
SPMovieClip.haddFrameWithTexture:atIndex:
Inserts a frame at the specified index. The successors will move down.
- (void)addFrameWithTexture:(SPTexture *)texture atIndex:(int)frameIDDiscussion
Inserts a frame at the specified index. The successors will move down.
Declared In
SPMovieClip.haddFrameWithTexture:duration:
Adds a frame with a certain texture and duration.
- (void)addFrameWithTexture:(SPTexture *)texture duration:(double)durationDiscussion
Adds a frame with a certain texture and duration.
Declared In
SPMovieClip.haddFrameWithTexture:duration:atIndex:
Adds a frame with a certain texture and duration.
- (void)addFrameWithTexture:(SPTexture *)texture duration:(double)duration atIndex:(int)frameIDDiscussion
Adds a frame with a certain texture and duration.
Declared In
SPMovieClip.haddFrameWithTexture:duration:sound:
Adds a frame with a certain texture, duration and sound.
- (void)addFrameWithTexture:(SPTexture *)texture duration:(double)duration sound:(SPSoundChannel *)soundDiscussion
Adds a frame with a certain texture, duration and sound.
Declared In
SPMovieClip.haddFrameWithTexture: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)frameIDDiscussion
Adds a frame with a certain texture, duration and sound.
Declared In
SPMovieClip.hdurationAtIndex:
Returns the duration (in seconds) of a frame at a certain index.
- (double)durationAtIndex:(int)frameIDDiscussion
Returns the duration (in seconds) of a frame at a certain index.
Declared In
SPMovieClip.hinitWithFrame:fps:
Initializes a movie with the first frame and the default number of frames per second. Designated initializer.
- (instancetype)initWithFrame:(SPTexture *)texture fps:(float)fpsDiscussion
Initializes a movie with the first frame and the default number of frames per second. Designated initializer.
Declared In
SPMovieClip.hinitWithFrames:fps:
Initializes a movie with an array of textures and the default number of frames per second.
- (instancetype)initWithFrames:(NSArray *)textures fps:(float)fpsDiscussion
Initializes a movie with an array of textures and the default number of frames per second.
Declared In
SPMovieClip.hplay
Start playback. Beware that the clip has to be added to a juggler, too!
- (void)playDiscussion
Start playback. Beware that the clip has to be added to a juggler, too!
Declared In
SPMovieClip.hremoveFrameAtIndex:
Removes the frame at the specified index. The successors will move up.
- (void)removeFrameAtIndex:(int)frameIDDiscussion
Removes the frame at the specified index. The successors will move up.
Declared In
SPMovieClip.hsetDuration:atIndex:
Sets the duration of a certain frame in seconds.
- (void)setDuration:(double)duration atIndex:(int)frameIDDiscussion
Sets the duration of a certain frame in seconds.
Declared In
SPMovieClip.hsetSound:atIndex:
Sets the sound that will be played back when a certain frame is active.
- (void)setSound:(SPSoundChannel *)sound atIndex:(int)frameIDDiscussion
Sets the sound that will be played back when a certain frame is active.
Declared In
SPMovieClip.hsetTexture:atIndex:
Sets the texture of a certain frame.
- (void)setTexture:(SPTexture *)texture atIndex:(int)frameIDDiscussion
Sets the texture of a certain frame.
Declared In
SPMovieClip.hsoundAtIndex:
Returns the sound of a frame at a certain index.
- (SPSoundChannel *)soundAtIndex:(int)frameIDDiscussion
Returns the sound of a frame at a certain index.
Declared In
SPMovieClip.h