CCTransition class -- Cocos2D-Swift v3.3, cocos2dswift
CCTransition Class Reference
Inherited from: CCScene: CCNode: CCResponder: NSObject
Declared From: CCTranslation. h
Overview:
A transition animates the presentation of a new scene while moving the current scene out of view. A transition is optionally played when calling one of the presentScene: withTransition: methods of CCDirector.
When the current scene is removed from the view, transition activates a new scene display. When the prensentScene: withTransition method of CCDirector is called, transition is an optional parameter.
Note:Since both scenes remain in memory and are being rendered, a transition may raise performance issues or memory warnings. if two complex scenes can not be reliably transitioned from/to it is best to not use transitions or to introduce an in-between scene that is presented only for a short period of time (ie loading scene or merely a "fade to black" scene ).
Note: At the underlying layer, all scenes are stored in the memory. transition can cause performance problems or memory warnings. If two complex scenes cannot be effectively transition, it is recommended that you do not use transitions or introduce a built-in scene that only shows a short period of time (such as loading scene or gradually blackening scene ).
TasksCreating a Fade Scene Transition
+ transitionCrossFadeWithDuration:
+ transitionFadeWithColor:duration:
+ transitionFadeWithDuration:
Creating a Directional Scene Transition
+ transitionMoveInWithDirection:duration:
+ transitionPushWithDirection:duration:
+ transitionRevealWithDirection:duration:
Transition Performance Settings
outgoingDownScale
Property
incomingDownScale
Property
retinaTransition
Property
transitionPixelFormat
Property
transitionDepthStencilFormat
Property
Controlling Scene Animation during Transition
outgoingSceneAnimated
Property
incomingSceneAnimated
Property
Transition Running Time and Progress
runTime
Property
progress
Property
Properties
IncomingDownScale
Will downscale incoming scene. Can be used as an effect, or to decrease render time on complex scenes. Default 1.0.
@property (nonatomic, assign) float incomingDownScale
You can reduce the size of the input scene. It can be used as an effect or reduce the underlying time in complex scene. Declared In
CCTransition.h
IncomingSceneAnimated
Defines whether incoming scene will be animated during transition. Default NO.
Specifies whether the transferred scene will be activated during the transition process. The default value is NO.
@property (nonatomic, getter=isIncomingSceneAnimated) BOOL incomingSceneAnimated
Declared In
CCTransition.h
OutgoingDownScale
Will downscale outgoing scene. Can be used as an effect, or to decrease render time on complex scenes. Default 1.0.
This can reduce the size of the outgoing scene. It can be used as an effect, or reduce the time required for underlying processing on complex scenes.
@property (nonatomic, assign) float outgoingDownScale
Declared In
CCTransition.h
OutgoingSceneAnimated
Defines whether outgoing scene will be animated during transition. Default NO.
Define whether the output scenario is activated during the transition process. NO by default
@property (nonatomic, getter=isOutgoingSceneAnimated) BOOL outgoingSceneAnimated
Declared In
CCTransition.h
SS
Normalized (percentage) transition progress in the range 0.0 to 1.0.
Normalize the transition progress within the range of 0.0 to 1.0 (in percent form)
@property (nonatomic, readonly) float progress
Declared In
CCTransition.h
RetinaTransition
Transition will be performed med in retina resolution. Will force outgoingDownScale and incomingDownScale to 1.0 on non retina devices, and 2.0 on retina devices if not set. Default YES.
@property (nonatomic, getter=isRetinaTransition) BOOL retinaTransition
Declared In
CCTransition.h
RunTime
The actual transition runtime in seconds.
The actual transition running time.
@property (nonatomic, readonly) NSTimeInterval runTime
Declared In
CCTransition.h
TransitionDepthStencilFormat
Depth/stencel format used for transition. DefaultGL_DEPTH24_STENCIL8_OES
.
@property (nonatomic, assign) GLuint transitionDepthStencilFormat
Declared In
CCTransition.h
TransitionPixelFormat
Pixel format used for transition. DefaultCCTexturePixelFormat_RGBA8888
.
@property (nonatomic, assign) CCTexturePixelFormat transitionPixelFormat
See Also
Declared In
CCTransition.h
Class MethodstransitionCrossFadeWithDuration:
Creates a cross fade transition directly from outgoing to incoming scene.
Create a cross-gradient transition. (In the old scenario, the alpha value changes from 1 to 0, the alpha value of the new scenario changes from 0 to 1, and the two cross nodes are together)
+ (CCTransition *)transitionCrossFadeWithDuration:(NSTimeInterval)duration
Parameters
-
Duration
-
The duration of the transition in seconds.
Return Value
The CCTransition Object.
Declared In
CCTransition.h
TransitionFadeWithColor: duration:
Creates a fade transition from outgoing to incoming scene, through color.
Create a gradient transition using a color scenario. (First from the old scene cross fade to the color scene, then from the color scene cross fade to the new scene)
+ (CCTransition *)transitionFadeWithColor:(CCColor *)color duration:(NSTimeInterval)duration
Parameters
-
Color
-
The color to fade through
-
Duration
-
The duration of the transition in seconds.
Return Value
The CCTransition Object.
See Also
Declared In
CCTransition.h
TransitionFadeWithDuration:
Creates a fade transition from outgoing to incoming scene, through black.
Wear a gradient transition through a black scene.
+ (CCTransition *)transitionFadeWithDuration:(NSTimeInterval)duration
Parameters
-
Duration
-
The duration of the transition in seconds.
Return Value
The CCTransition Object.
Declared In
CCTransition.h
TransitionMoveInWithDirection: duration:
Creates a transition where the incoming scene is moved in over the outgoing scene.
Create a transtion (the effect is that the new scene is moved to the old scene like a lid)
Note: CCTransitionDirection:
typedef NS_ENUM(NSInteger, CCTransitionDirection ) {
CCTransitionDirectionUp,
CCTransitionDirectionDown,
CCTransitionDirectionRight,
CCTransitionDirectionLeft,
CCTransitionDirectionInvalid = -1,
};
+ (CCTransition *)transitionMoveInWithDirection:(CCTransitionDirection)direction duration:(NSTimeInterval)duration
Parameters
-
Direction
-
Direction to move the incoming scene.
-
Duration
-
The duration of the transition in seconds.
Return Value
The CCTransition Object.
See Also
Declared In
CCTransition.h
TransitionPushWithDirection: duration:
Creates a transition where the incoming scene pushed the outgoing scene out.
The effect is that the new scene pushes the old scene and moves it in parallel.
+ (CCTransition *)transitionPushWithDirection:(CCTransitionDirection)direction duration:(NSTimeInterval)duration
Parameters
-
Direction
-
Direction to move incoming and outgoing scenes.
-
Duration
-
The duration of the transition in seconds.
Return Value
The CCTransition Object.
See Also
Declared In
CCTransition.h
TransitionRevealWithDirection: duration:
Creates a transition where the incoming scene is revealed by sliding the outgoing scene out.
The old scene is covered in the new scene, and then the old one is removed like the old one, and the new one is revealed. In contrast to moving in, one is built in a new scenario, and the other is revealed in an old scenario.
+ (CCTransition *)transitionRevealWithDirection:(CCTransitionDirection)direction duration:(NSTimeInterval)duration
Parameters
-
Direction
-
Direction to slide outcoing scene.
-
Duration
-
The duration of the transition in seconds.
Return Value
The CCTransition Object.
See Also
Declared In
CCTransition.h