iOS Developer Library

Developer

SpriteKit Framework Reference SKKeyframeSequence Class Reference

Options
Deployment Target:

On This Page
Language:

SKKeyframeSequence

An SKKeyframeSequence object specifies values for keyframes so that when a particle in an emitter node is simulated, that particle gets its keyframe values from the keyframe sequence (instead of from the normal emitter properties controlling that particle). The sequence specifies the values for these keyframes. More...

Inheritance


Conforms To


Import Statement


import SpriteKit @import SpriteKit;

Availability


Available in iOS 7.0 and later.
  • Initializes a keyframe sequence with an initial set of values and times.

    Declaration

    Swift

    init!(keyframeValues values: [AnyObject], times times: [AnyObject])

    Objective-C

    - (instancetype)initWithKeyframeValues:(NSArray *)values times:(NSArray *)times

    Parameters

    values

    An array of value objects that define the keyframe values for the sequence.

    times

    An array of NSNumber objects containing floating-point values that specify the time values for the keyframes.

    Return Value

    A newly initialized sequence.

    Discussion

    The two arrays must have an identical number of elements. The keyframes in the new sequence are stored in the same order as the input arrays.

    Import Statement

    import SpriteKit

    Availability

    Available in iOS 7.0 and later.

  • Initializes a new keyframe sequence.

    Declaration

    Swift

    convenience init(capacity numItems: Int)

    Objective-C

    - (instancetype)initWithCapacity:(NSUInteger)numItems

    Parameters

    numItems

    The initial capacity of the new sequence.

    Return Value

    A newly initialized empty sequence.

    Discussion

    Import Statement

    import SpriteKit

    Availability

    Available in iOS 7.0 and later.

  • Adds a keyframe to the sequence.

    Declaration

    Swift

    func addKeyframeValue(_ value: AnyObject, time time: CGFloat)

    Objective-C

    - (void)addKeyframeValue:(id)value time:(CGFloat)time

    Parameters

    value

    An object that defines the value to add. It must have the same class as other value objects stored in the sequence.

    time

    The corresponding time.

    Discussion

    The new keyframe is appended to the end of the array.

    Import Statement

    import SpriteKit

    Availability

    Available in iOS 7.0 and later.

  • Removes a keyframe from the sequence.

    Declaration

    Swift

    func removeKeyframeAtIndex(_ index: Int)

    Objective-C

    - (void)removeKeyframeAtIndex:(NSUInteger)index

    Parameters

    index

    The index of the keyframe value to remove.

    Import Statement

    import SpriteKit

    Availability

    Available in iOS 7.0 and later.

  • Removes the last value in the sequence.

    Declaration

    Swift

    func removeLastKeyframe()

    Objective-C

    - (void)removeLastKeyframe

    Import Statement

    import SpriteKit

    Availability

    Available in iOS 7.0 and later.

  • Changes the time for a specific keyframe.

    Declaration

    Swift

    func setKeyframeTime(_ time: CGFloat, forIndex index: Int)

    Objective-C

    - (void)setKeyframeTime:(CGFloat)time forIndex:(NSUInteger)index

    Parameters

    time

    The new time value for the keyframe.

    index

    The index of the keyframe to change.

    Import Statement

    import SpriteKit

    Availability

    Available in iOS 7.0 and later.

  • Changes the value for a specific keyframe.

    Declaration

    Swift

    func setKeyframeValue(_ value: AnyObject, forIndex index: Int)

    Objective-C

    - (void)setKeyframeValue:(id)value forIndex:(NSUInteger)index

    Parameters

    value

    The new value for the keyframe.

    index

    The index of the keyframe to change.

    Import Statement

    import SpriteKit

    Availability

    Available in iOS 7.0 and later.

  • Replaces a keyframe in the sequence with a new keyframe.

    Declaration

    Swift

    func setKeyframeValue(_ value: AnyObject, time time: CGFloat, forIndex index: Int)

    Objective-C

    - (void)setKeyframeValue:(id)value time:(CGFloat)time forIndex:(NSUInteger)index

    Parameters

    value

    The new value for the keyframe.

    time

    The new time for the keyframe.

    index

    The index of the keyframe to change.

    Import Statement

    import SpriteKit

    Availability

    Available in iOS 7.0 and later.

  • The number of keyframes in the sequence.

    Declaration

    Swift

    func count() -> Int

    Objective-C

    - (NSUInteger)count

    Return Value

    The number of keyframes in the sequence.

    Import Statement

    import SpriteKit

    Availability

    Available in iOS 7.0 and later.

  • Gets the time for a keyframe in the sequence.

    Declaration

    Swift

    func getKeyframeTimeForIndex(_ index: Int) -> CGFloat

    Objective-C

    - (CGFloat)getKeyframeTimeForIndex:(NSUInteger)index

    Parameters

    index

    The index of the keyframe.

    Return Value

    The time value for the keyframe.

    Import Statement

    import SpriteKit

    Availability

    Available in iOS 7.0 and later.

  • Gets the value for a keyframe in the sequence.

    Declaration

    Swift

    func getKeyframeValueForIndex(_ index: Int) -> AnyObject

    Objective-C

    - (id)getKeyframeValueForIndex:(NSUInteger)index

    Parameters

    index

    The index of the keyframe.

    Return Value

    The value object for the keyframe.

    Import Statement

    import SpriteKit

    Availability

    Available in iOS 7.0 and later.

  • Calculates the sample at a particular time.

    Declaration

    Swift

    func sampleAtTime(_ time: CGFloat) -> AnyObject!

    Objective-C

    - (id)sampleAtTime:(CGFloat)time

    Parameters

    time

    The time value to sample.

    Return Value

    An object that contains the interpolated sample. The class of this object matches the class of the values stored in the keyframe sequence.

    Import Statement

    import SpriteKit

    Availability

    Available in iOS 7.0 and later.

  • The modes used to interpolate between keyframes in the sequence.

    Declaration

    Swift

    enum SKInterpolationMode : Int { case Linear case Spline case Step }

    Objective-C

    typedef NS_ENUM (NSInteger, SKInterpolationMode ) { SKInterpolationModeLinear = 1, SKInterpolationModeSpline = 2, SKInterpolationModeStep = 3, };

    Constants

    • Linear

      SKInterpolationModeLinear

      Values between two keyframes are interpolated linearly.

      Available in iOS 7.0 and later.

    • Spline

      SKInterpolationModeSpline

      Values between two keyframes using a spline curve.

      Available in iOS 7.0 and later.

    • Step

      SKInterpolationModeStep

      Values between two keyframes are not interpolated. Instead, the value is that of the most recent keyframe.

      Available in iOS 7.0 and later.

    Import Statement

    import SpriteKit

    Availability

    Available in iOS 7.0 and later.

  • The modes used to determine how the sequence repeats.

    Declaration

    Swift

    enum SKRepeatMode : Int { case Clamp case Loop }

    Objective-C

    typedef NS_ENUM (NSInteger, SKRepeatMode ) { SKRepeatModeClamp = 1, SKRepeatModeLoop = 2, };

    Constants

    • Clamp

      SKRepeatModeClamp

      When a sample is calculated, the time value is clamped to the range of time values found in the sequence. For example, if the time value of the last keyframe in the sequence was 0.5, then a sample at any time value from 0.5 to 1.0 returns the last keyframe’s value.

      Available in iOS 7.0 and later.

    • Loop

      SKRepeatModeLoop

      When a sample is calculated, the sequence loops back to the beginning of the sequence. For example, if the time value of the last keyframe in the sequence was 0.5, then a sample at any time value from 0.5 to 1.0 returns the same value as the sequence did from 0.0 to 0.5.

      Available in iOS 7.0 and later.

    Import Statement

    import SpriteKit

    Availability

    Available in iOS 7.0 and later.