Cocos2d-iPhone V3 (2) scenario Conversion

Source: Internet
Author: User

Cocos2d-iPhone V3 (2) scenario Conversion
Cocos2d-iPhone V3 (2) scenario Conversion

  •  
  • 1. Preparations

    Can I create a scenario?

    #import cocos2d.h#import cocos2d-ui.h@interface MainScene : CCScene+ (MainScene *)scene;- (id)init;@end

    The basic methods must be implemented,scene,init,onEnter,onExitAndtouchBegan. If not, first look at the Cocos2d-iPhone V3 (1) BASIC Program Framework and Common Action Introduction This.

    Now, assume that you have created two custom scenario classes.MainSceneAndHomeScene.

    2. Transfer!

    SlaveMainSceneConvertHomeScene, InMainSceneIn a code:

    CCTransition *t = [CCTransition transitionPushWithDirection:CCTransitionDirectionRight                                                   duration:1.0f][CCDirector sharedDirector] replaceScene:[HomeScene scene] withTransition:t];

    CreateCCTransitionAnd then let the Director hold the audience.CCTransitionTo transferHomeScene, The function used is:

    - (void)replaceScene:(CCScene *)scene withTransition:(CCTransition *)transition;

    You need to feel like a movie director. Here are four elements of transition:

    1. Old scenarios
    2. New scenarios
    3. Transfer Mode: parameters such as transfer direction may be involved
    4. Transfer Time 3. Common Transfer Modes

      The above ispush, Specifically, the new scene is moved from the right to the left (to push the old scene to the left ). The six transfer methods are as follows:

      // Note: The following statement is not formal, just to be brief and clear // cross fadetransitionCrossFadeWithDuration :( NSTimeInterval) // fade with colortransitionFadeWithColor :( CCColor *) duration :( NSTimeInterval) // interval :( NSTimeInterval) // move interval :( CCTransitionDirection) duration :( NSTimeInterval) // interval :( duration) duration :( NSTimeInterval) // interval :( CCTransitionDirection) duration :( NSTimeInterval)
      • In cross fade, the alpha value of the old scenario changes from 1 to 0, the alpha value of the new scenario changes from 0 to 1, and the two cross nodes are combined.
      • Fade with color is to add a color scene between the old scene and the new scene, first from the old scene cross fade to the color scene, then from the color scene cross fade to the new scene.
      • Fade is a special case of fade with color, that is, the color scene is black.
      • The move in field refers to the move in field in the new scenario, that is, the new scene is moved to the old scenario like a lid.
      • In the new scenario, the push field is used to push the old scenario, and the two scenarios are moved in parallel.
      • Reveal transfer refers to the old scenario under the new scenario, 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.

        As a matter of fact, you can try coding and get a little longer to observe the duration settings.

        -

        Reprinted please indicate from: http://blog.csdn.net/prevention

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.