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

Frame Manipulation Methods

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 NO when the end has been reached.

    property
  •   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

numFrames

The number of frames of the clip.

@property (nonatomic, readonly) int numFrames

Discussion

The number of frames of the clip.

Declared In

SPMovieClip.h

totalTime

The total duration of the clip in seconds.

@property (nonatomic, readonly) double totalTime

Discussion

The total duration of the clip in seconds.

Declared In

SPMovieClip.h

Class Methods

movieWithFrame:fps:

Factory method.

+ (instancetype)movieWithFrame:(SPTexture *)texture fps:(float)fps

Discussion

Factory method.

Declared In

SPMovieClip.h

movieWithFrames:fps:

Factory method.

+ (instancetype)movieWithFrames:(NSArray *)textures fps:(float)fps

Discussion

Factory method.

Declared In

SPMovieClip.h

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

pause

Pause playback.

- (void)pause

Discussion

Pause playback.

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

stop

Stop playback. Resets currentFrame to beginning.

- (void)stop

Discussion

Stop playback. Resets currentFrame to beginning.

Declared In

SPMovieClip.h

textureAtIndex:

Returns the texture of a frame at a certain index.

- (SPTexture *)textureAtIndex:(int)frameID

Discussion

Returns the texture of a frame at a certain index.

Declared In

SPMovieClip.h