PMTweenGroup Class Reference
Inherits from | NSObject |
Conforms to | PMTweenTempoDelegate PMTweening |
Declared in | PMTweenGroup.h PMTweenGroup.m |
Overview
PMTweenGroup handles the tweening of one or more objects which conform to the PMTweening
protocol, either being instances of PMTweenUnit
or other custom classes. The PMTweenGroup class is a good solution when you want to easily synchronize the operation of many tweens.
Tasks
Creating an Instance
Setting Up a Group
-
– addTween:
-
– addTween:useTweenTempo:
-
– addTweens:
-
– removeTween:
-
delay
property -
repeating
property -
numberOfRepeats
property -
syncTweensWhenReversing
property
Tween State
-
tweenState
property -
tweenDirection
property -
tweens
property -
cyclesCompletedCount
property
Notification Blocks
-
startBlock
property -
stopBlock
property -
updateBlock
property -
repeatCycleBlock
property -
reverseBlock
property -
pauseBlock
property -
resumeBlock
property -
completeBlock
property
Controlling a Tween
Properties
completeBlock
This notification block is executed when a tween operation has completed (or when all tween cycles have completed, if repeating
is set to YES
).
@property (nonatomic, copy) PMTweenDidCompleteBlock completeBlock
Declared In
PMTweenGroup.h
cyclesCompletedCount
The number of completed tween cycles. (read-only)
@property (readonly, nonatomic, assign) NSUInteger cyclesCompletedCount
Discussion
@remarks A cycle represents the total length of tweening operation.
See Also
Declared In
PMTweenGroup.h
delay
The delay, in seconds, before a tween operation begins.
@property (nonatomic, assign) NSTimeInterval delay
Discussion
Warning: Setting this parameter after a tween operation has begun has no effect.
Declared In
PMTweenGroup.h
numberOfRepeats
The number of tween cycle operations to repeat.
@property (nonatomic, assign) NSUInteger numberOfRepeats
Discussion
@remarks This property is only used when repeating
is set to YES
. Negative values are clamped to 0. The default value is 0.
See Also
Declared In
PMTweenGroup.h
pauseBlock
This notification block is executed when calling the pauseTween
method on this instance causes a tween operation to pause.
@property (nonatomic, copy) PMTweenDidPauseBlock pauseBlock
See Also
Declared In
PMTweenGroup.h
repeatCycleBlock
This notification block is executed when a tween cycle has completed.
@property (nonatomic, copy) PMTweenDidRepeatBlock repeatCycleBlock
Declared In
PMTweenGroup.h
repeating
A Boolean which determines whether a group’s tween operation should repeat.
@property (nonatomic, assign) BOOL repeating
Discussion
@remarks When set to YES
, each tween object in the group repeats its tween cycle for the number of times specified by the numberOfRepeats
property. The default value is NO
.
See Also
Declared In
PMTweenGroup.h
resumeBlock
This notification block is executed when calling the resumeTween
method on this instance causes a tween operation to resume.
@property (nonatomic, copy) PMTweenDidResumeBlock resumeBlock
See Also
Declared In
PMTweenGroup.h
reverseBlock
This notification block is executed when this instance’s tweenDirection
property changes to PMTweenDirectionReverse
.
@property (nonatomic, copy) PMTweenDidReverseBlock reverseBlock
See Also
@property tweenDirection, reversing
Declared In
PMTweenGroup.h
startBlock
This notification block is executed when calling the startTween
method on this instance causes a tween operation to start.
@property (nonatomic, copy) PMTweenDidStartBlock startBlock
See Also
Declared In
PMTweenGroup.h
stopBlock
This notification block is executed when calling the stopTween
method on this instance causes a tween operation to stop.
@property (nonatomic, copy) PMTweenDidStopBlock stopBlock
See Also
Declared In
PMTweenGroup.h
syncTweensWhenReversing
A Boolean which determines whether a group’s tween objects should pause until all objects are ready to reverse directions.
@property (nonatomic, assign) BOOL syncTweensWhenReversing
Discussion
@remarks When set to YES
, the group does not reverse direction until all objects have completed their current tween. This property only has an effect when reversing
is set to YES
. It posts a PMTweenDidReverseNotification
notification when all of its tween objects are ready to reverse. When set to NO
, its tween objects will reverse independently of each other. The default value is YES
.
Declared In
PMTweenGroup.h
tweenDirection
A PMTweenDirection
enum which represents the current direction of the tween operation. (read-only)
@property (readonly, nonatomic, assign) PMTweenDirection tweenDirection
Declared In
PMTweenGroup.h
tweenState
A PMTweenState
enum which represents the current state of the tween operation. (read-only)
@property (readonly, nonatomic, assign) PMTweenState tweenState
Declared In
PMTweenGroup.h
tweens
An array comprising the tween objects which are controlled by this PMTweenGroup object. (read-only)
@property (readonly, nonatomic, strong) NSArray *tweens
Declared In
PMTweenGroup.h
updateBlock
This notification block is executed when the updateWithTimeInterval:currentTime:
method is called on this instance while this instance’s tweenState
is PMTweenStateTweening
.
@property (nonatomic, copy) PMTweenDidUpdateBlock updateBlock
Declared In
PMTweenGroup.h
Instance Methods
addTween:
Adds an object which conforms to the PMTweening
protocol to the tweening group.
- (void)addTween:(NSObject<PMTweening> *)tween
Parameters
- tween
An object which adopts the
PMTweening
protocol.@remarks All tween objects added via this method will have their
updateWithTimeInterval:currentTime:
method called by the PMTweenGroup instance.
Discussion
Warning: A NSInternalInconsistencyException will be raised if the provided object does not adopt the PMTweening
protocol.
Declared In
PMTweenGroup.h
addTween:useTweenTempo:
Adds an object which conforms to the PMTweening
protocol to the tweening group.
- (void)addTween:(NSObject<PMTweening> *)tween useTweenTempo:(BOOL)useTweenTempo
Parameters
- tween
An object which adopts the
PMTweening
protocol.
- useTweenTempo
When
YES
, the tween object should use its own tempo to update its tween progress, and thus theupdateWithTimeInterval:currentTime:
method will not be called on the object by the PMTweenGroup instance.
Discussion
Warning: A NSInternalInconsistencyException will be raised if the provided object does not adopt the PMTweening
protocol.
Declared In
PMTweenGroup.h
addTweens:
Adds an array of objects which should conform to the PMTweening
protocol to the tweening group.
- (void)addTweens:(NSArray *)tweens
Parameters
- tweens
An array of objects which should conform to the
PMTweening
protocol.@remarks All tween objects added via this method will have their
updateWithTimeInterval:currentTime:
method called by the PMTweenGroup instance.
Discussion
Warning: A NSInternalInconsistencyException will be raised if the provided array contains an object which does not adopt the PMTweening
protocol.
Declared In
PMTweenGroup.h
initWithTweens:options:
Initializes a new PMTweenGroup object and registers the provided array of tween objects.
- (instancetype)initWithTweens:(NSArray *)tweens options:(PMTweenOptions)options
Parameters
- tweens
An array of objects which should conform to the
PMTweening
protocol.
- options
A bitmask of
PMTweenOptions
configuration values.
Return Value
A new instance of this class.
Discussion
Warning: A NSInternalInconsistencyException will be raised if the provided array contains an object which does not adopt the PMTweening
protocol.
Declared In
PMTweenGroup.h
isReversing
A Boolean which determines whether a tween operation, when it has tweened to the ending value, should tween from the ending value back to the starting value.
- (BOOL)isReversing
Discussion
@remarks When set to YES
, the tween plays in reverse after completing a forward tween. In this state, a tween cycle represents the combination of the forward and back tweens. The default value is NO
.
Declared In
PMTweening.h
pauseTween
Pauses a tween that is currently tweening. (required)
- (void)pauseTween
Discussion
@remarks When this method is called, a tween should only enter a paused state if it is currently tweening.
Declared In
PMTweening.h
removeTween:
Removes the specified tween object from the tweening group.
- (void)removeTween:(NSObject<PMTweening> *)tween
Parameters
- tween
The tween object to remove.
Declared In
PMTweenGroup.h
resumeTween
Resumes a tween that is currently paused. (required)
- (void)resumeTween
Discussion
@remarks When this method is called, a tween should only resume tweening if it is currently paused.
Declared In
PMTweening.h
setReversing:
A Boolean which determines whether a tween operation, when it has tweened to the ending value, should tween from the ending value back to the starting value.
- (void)setReversing:(BOOL)reversing
Discussion
@remarks When set to YES
, the tween plays in reverse after completing a forward tween. In this state, a tween cycle represents the combination of the forward and back tweens. The default value is NO
.
Declared In
PMTweening.h
setTempo:
A concrete PMTweenTempo
subclass that provides an update “beat” while a tween operation occurs.
- (void)setTempo:(PMTweenTempo *)tempo
Discussion
@remarks While you don’t have to implement PMTweenTempo for your own class updating, other tween collection classes like PMTweenGroup
will try to remove any tempos of tween objects added to them.
Declared In
PMTweening.h
startTween
Starts a tween that is currently stopped. (required)
- (void)startTween
Discussion
@remarks When this method is called, a tween should only start tweening if it is stopped.
Declared In
PMTweening.h
stopTween
Stops a tween that is currently tweening. (required)
- (void)stopTween
Discussion
@remarks When this method is called, a tween should only enter a stopped state if it currently tweening.
Declared In
PMTweening.h
tempo
A concrete PMTweenTempo
subclass that provides an update “beat” while a tween operation occurs.
- (PMTweenTempo *)tempo
Discussion
@remarks While you don’t have to implement PMTweenTempo for your own class updating, other tween collection classes like PMTweenGroup
will try to remove any tempos of tween objects added to them.
Declared In
PMTweening.h
tempoBeatWithTimestamp:
Sends an update beat that should prompt tweening classes to recalculate tween values.
- (void)tempoBeatWithTimestamp:(NSTimeInterval)timestamp
Parameters
- timestamp
A timestamp with the current time, by which tween classes can calculate new tween values.
Declared In
PMTweenTempo.h