CCTransition類--Cocos2D-Swift v3.3,cocos2dswift

來源:互聯網
上載者:User

CCTransition類--Cocos2D-Swift v3.3,cocos2dswift
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)。

 

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可以縮減傳入scene的規模。可以用作一個效果,或者在複雜scene中減少底層時間。Declared In CCTransition.h incomingSceneAnimated

Defines whether incoming scene will be animated during transition. Default NO.

定義傳入的scene在transition的過程中是否會被啟用,預設為NO。

@property (nonatomic, getter=isIncomingSceneAnimated) BOOL incomingSceneAnimatedDeclared 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 outgoingDownScaleDeclared In CCTransition.houtgoingSceneAnimated

Defines whether outgoing scene will be animated during transition. Default NO.

定義傳出情境在transition過程中是否會被啟用。預設NO

@property (nonatomic, getter=isOutgoingSceneAnimated) BOOL outgoingSceneAnimatedDeclared In CCTransition.hprogress

Normalized (percentage) transition progress in the range 0.0 to 1.0.

把transition的進度正常化在0.0到1.0的範圍內(百分比形式)

@property (nonatomic, readonly) float progressDeclared In CCTransition.hretinaTransition

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 retinaTransitionDeclared In CCTransition.hrunTime

The actual transition runtime in seconds.

實際的transition已耗用時間。

@property (nonatomic, readonly) NSTimeInterval runTimeDeclared In CCTransition.htransitionDepthStencilFormat

Depth/stencil format used for transition. Default GL_DEPTH24_STENCIL8_OES.

@property (nonatomic, assign) GLuint transitionDepthStencilFormatDeclared In CCTransition.htransitionPixelFormat

Pixel format used for transition. Default CCTexturePixelFormat_RGBA8888.

@property (nonatomic, assign) CCTexturePixelFormat transitionPixelFormatSee Also
  • CCTexturePixelFormat

Declared In CCTransition.h  Class MethodstransitionCrossFadeWithDuration:

Creates a cross fade transition directly from outgoing to incoming scene.

建立一個交叉漸層transition。(舊情境 alpha 值從 1 變為 0,新情境的 alpha 值從 0 變為 1,兩個 cross 在一起)

+ (CCTransition *)transitionCrossFadeWithDuration:(NSTimeInterval)durationParameters
duration

The duration of the transition in seconds.

Return Value

The CCTransition Object.

Declared In CCTransition.htransitionFadeWithColor:duration:

Creates a fade transition from outgoing to incoming scene, through color.

建立一個漸層transition,通過一個color情境。(先從舊情境 cross fade 到這個顏色情境,再從顏色情境 cross fade 到新情境)

+ (CCTransition *)transitionFadeWithColor:(CCColor *)color duration:(NSTimeInterval)durationParameters
color

The color to fade through

duration

The duration of the transition in seconds.

Return Value

The CCTransition Object.

See Also
  • CCColor

Declared In CCTransition.htransitionFadeWithDuration:

Creates a fade transition from outgoing to incoming scene, through black.

穿件一個漸層transition,通過一個black情境.

+ (CCTransition *)transitionFadeWithDuration:(NSTimeInterval)durationParameters
duration

The duration of the transition in seconds.

Return Value

The CCTransition Object.

Declared In CCTransition.htransitionMoveInWithDirection: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)durationParameters
direction

Direction to move the incoming scene.

duration

The duration of the transition in seconds.

Return Value

The CCTransition Object.

See Also
  • CCTransitionDirection

Declared In CCTransition.htransitionPushWithDirection:duration:

Creates a transition where the incoming scene pushed the outgoing scene out.

效果是新scene把舊scene推走,平行移動。

+ (CCTransition *)transitionPushWithDirection:(CCTransitionDirection)direction duration:(NSTimeInterval)durationParameters
direction

Direction to move incoming and outgoing scenes.

duration

The duration of the transition in seconds.

Return Value

The CCTransition Object.

See Also
  • CCTransitionDirection

Declared In CCTransition.htransitionRevealWithDirection:duration:

Creates a transition where the incoming scene is revealed by sliding the outgoing scene out.

舊情境蓋在新情境下面,然後像揭蓋子一樣把舊的揭掉,新的就露出來了。與 move in 相反,一個是新情境蓋過來,一個是老情境揭出去。

+ (CCTransition *)transitionRevealWithDirection:(CCTransitionDirection)direction duration:(NSTimeInterval)durationParameters
direction

Direction to slide outcoing scene.

duration

The duration of the transition in seconds.

Return Value

The CCTransition Object.

See Also
  • CCTransitionDirection

Declared In CCTransition.h

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.