CCTransition类--Cocos2D-Swift v3.3
CCTransition Class Reference
继承自: CCScene:CCNode:CCResponder:NSObject
声明自: CCTranslation.h
概述:
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.
当从view中移出当前scene时,transition激活一个新的scene显示。在调用CCDirector的prensentScene:withTransition方法时,transition是可选的参数.
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 a loading scene or merely a “fade to black” scene).
注意:在底层,所有的scenes都保留在内存中,transition可以会引发性能问题或内存警告。如果两个复杂的scenes不能有效的被transition,那么最好不要使用transitions或者引入一个仅仅会显示短时间的内置scene(比如载入scene或者渐渐变黑scene)。
Tasks
Creating a Fade Scene Transition
+ transitionCrossFadeWithDuration:
+ transitionFadeWithColor:duration:
+ transitionFadeWithDuration:
Creating a Directional Scene Transition
+ transitionMoveInWithDirection:duration:
+ transitionPushWithDirection:duration:
+ transitionRevealWithDirection:duration:
Transition Performance Settings
outgoingDownScale
propertyincomingDownScale
propertyretinaTransition
propertytransitionPixelFormat
propertytransitionDepthStencilFormat
property
Controlling Scene Animation during Transition
outgoingSceneAnimated
propertyincomingSceneAnimated
property
Transition Running Time and Progress
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
Declared In
CCTransition.h
incomingSceneAnimated
Defines whether incoming scene will be animated during transition. Default NO.
定义传入的scene在transition的过程中是否会被激活,默认为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.
可以缩减传出scene的规模。可以用作一个效果,或者在复杂scenes上减少底层处理所需的时间。
@property (nonatomic, assign) float outgoingDownScale
Declared In
CCTransition.h
outgoingSceneAnimated
Defines whether outgoing scene will be animated during transition. Default NO.
定义传出场景在transition过程中是否会被激活。默认NO
@property (nonatomic, getter=isOutgoingSceneAnimated) BOOL outgoingSceneAnimated
Declared In
CCTransition.h
progress
Normalized (percentage) transition progress in the range 0.0 to 1.0.
把transition的进度规范化在0.0到1.0的范围内(百分比形式)
@property (nonatomic, readonly) float progress
Declared In
CCTransition.h
retinaTransition
Transition will be performed 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.
实际的transition运行时间。
@property (nonatomic, readonly) NSTimeInterval runTime
Declared In
CCTransition.h
transitionDepthStencilFormat
Depth/stencil format used for transition. Default GL_DEPTH24_STENCIL8_OES
.
@property (nonatomic, assign) GLuint transitionDepthStencilFormat
Declared In
CCTransition.h
transitionPixelFormat
Pixel format used for transition. Default CCTexturePixelFormat_RGBA8888
.
@property (nonatomic, assign) CCTexturePixelFormat transitionPixelFormat
See Also
Declared In
CCTransition.h
Class Methods
transitionCrossFadeWithDuration:
Creates a cross fade transition directly from outgoing to incoming scene.
创建一个交叉渐变transition。(旧场景 alpha 值从 1 变为 0,新场景的 alpha 值从 0 变为 1,两个 cross 在一起)
+ (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.
创建一个渐变transition,通过一个color场景。(先从旧场景 cross fade 到这个颜色场景,再从颜色场景 cross fade 到新场景)
+ (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.
穿件一个渐变transition,通过一个black场景.
+ (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.
创建一个transtion(效果是新scene像盖子一样挪过来盖在旧scene上面)
注: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.
效果是新scene把旧scene推走,平行移动。
+ (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.
旧场景盖在新场景下面,然后像揭盖子一样把旧的揭掉,新的就露出来了。与 move in 相反,一个是新场景盖过来,一个是老场景揭出去。
+ (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
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。