Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
SlideShare a Scribd company logo
2011/6/25   1
2011/6/25   2
2011/6/25   3
2011/6/25   4
2011/6/25   5
2011/6/25   6
2011/6/25   7
2011/6/25   8
2011/6/25   9
2011/6/25   10
2011/6/25   11
2011/6/25   12
2011/6/25   13
2011/6/25   14
2011/6/25   15
2011/6/25   16
2011/6/25   17
2011/6/25   18
2011/6/25   19
2011/6/25   20
2011/6/25   21
2011/6/25   22
2011/6/25   23
/        .::::::::::::::::::::::::;;:;;::,                        ::::
                      l        ,       rj,r    '"'"'"                   l :::::::
                           Y                                                      ,! :::::::
                           |                                                                ::::::::
                           | __                 --                                i::::,r
              `'' -                '               ´           ,                   }::;! , .
                                                 """"´                                             L_
                                   /                                                i          ,        /|                     r
            ≡ -           ´        ,,.._                                      i             't-'        | ,               ,r
            , yx=''"                   {       ,-                         ;             l                '    r       '
                                               `--                                      /!                        `
                   _,, -                             ''                                 ;                                 `
            -''"_,, -''"                                               ;;'         ,'          /
            -''"                               `          ''       ;;;;' ,'
2011/6/25                                                                                                                          24
                                           /                             _ =
#import “YourScene.h”

            [[CCDirector sharedDirector] replaceScene: [YourScene scene]];

2011/6/25                                                                    25
#import “YourScene.h”
              id transition = [CCTransitionFade transitionWithDuration:0.5f
            scene:[YourScene scene];
              [[CCDirector sharedDirector] replaceScene:transition];



2011/6/25                                                                     26
-(void) registerWithTouchDispatcher{
              [[CCTouchDispatcher sharedDispatcher] addTargetedDelegate:self
            priority:0 swallowsTouches:YES];
            }




2011/6/25                                                                      27
- (BOOL)ccTouchBegan:(UITouch *)touch withEvent:(UIEvent *)event{
              //
                return YES;
            }
2011/6/25                                                                       28
-(id) init{
              if( (self=[super init])) {
                 // create and initialize a Label
                 CCLabelTTF *label = [CCLabelTTF labelWithString:@"Hello World" fontName:@"Marker
            Felt" fontSize:64];

                  // ask director the the window size
                  CGSize size = [[CCDirector sharedDirector] winSize];

                  // position the label on the center of the screen
                  label.position = ccp( size.width /2 , size.height/2 );

                  // add the label as a child to this Layer
                  [self addChild: label];

                  self.isTouchEnabled = YES;
                }
                return self;
            }

            -(void) registerWithTouchDispatcher{
              [[CCTouchDispatcher sharedDispatcher] addTargetedDelegate:self priority:0
            swallowsTouches:YES];
            }

            - (BOOL)ccTouchBegan:(UITouch *)touch withEvent:(UIEvent *)event{
              id transition = [CCTransitionFade transitionWithDuration:0.5f scene:[YourScene scene];
              [[CCDirector sharedDirector] replaceScene:transition];
              return YES;
            }
2011/6/25                                                                                              29
CCSprite sprite = [CCSprite spriteWithFile:@”sprite.png”];
            //
                 sprite.position = ccp(100, 100); //
                 [self addChild:sprite]; //        Sprite




2011/6/25                                                                     30
// 240, 160   3           Action
            id move = [CCMoveTo actionWithDuration:3 position:ccp(240, 160)];
            // 2       360        Action
            id rotate = [CCRotateBy actionWithDuration:2 angle:360];
            // 4             127              Action
            id fade = [CCFadeTo actionWithDuration:4 opacity:127];
            //        Action   Sequence
            CCSequence* sequence = [CCSequence actions:move, rotate, fade, nil];
            // Sequence Sprite
            [sprite runAction:sequence];


2011/6/25                                                                          31
2011/6/25   32
2011/6/25   33
2011/6/25   34
2011/6/25   35
2011/6/25   36
2011/6/25   37
2011/6/25   38
2011/6/25   39
2011/6/25   40
2011/6/25   41

More Related Content

cocos2d入門

  • 10. 2011/6/25 10
  • 11. 2011/6/25 11
  • 12. 2011/6/25 12
  • 13. 2011/6/25 13
  • 14. 2011/6/25 14
  • 15. 2011/6/25 15
  • 16. 2011/6/25 16
  • 17. 2011/6/25 17
  • 18. 2011/6/25 18
  • 19. 2011/6/25 19
  • 20. 2011/6/25 20
  • 21. 2011/6/25 21
  • 22. 2011/6/25 22
  • 23. 2011/6/25 23
  • 24. / .::::::::::::::::::::::::;;:;;::, :::: l , rj,r '"'"'" l ::::::: Y ,! ::::::: | :::::::: | __ -- i::::,r `'' - ' ´ , }::;! , . """"´ L_ / i , /| r ≡ - ´ ,,.._ i 't-' | , ,r , yx=''" { ,- ; l ' r ' `-- /! ` _,, - '' ; ` -''"_,, -''" ;;' ,' / -''" ` '' ;;;;' ,' 2011/6/25 24 / _ =
  • 25. #import “YourScene.h” [[CCDirector sharedDirector] replaceScene: [YourScene scene]]; 2011/6/25 25
  • 26. #import “YourScene.h” id transition = [CCTransitionFade transitionWithDuration:0.5f scene:[YourScene scene]; [[CCDirector sharedDirector] replaceScene:transition]; 2011/6/25 26
  • 27. -(void) registerWithTouchDispatcher{ [[CCTouchDispatcher sharedDispatcher] addTargetedDelegate:self priority:0 swallowsTouches:YES]; } 2011/6/25 27
  • 28. - (BOOL)ccTouchBegan:(UITouch *)touch withEvent:(UIEvent *)event{ // return YES; } 2011/6/25 28
  • 29. -(id) init{ if( (self=[super init])) { // create and initialize a Label CCLabelTTF *label = [CCLabelTTF labelWithString:@"Hello World" fontName:@"Marker Felt" fontSize:64]; // ask director the the window size CGSize size = [[CCDirector sharedDirector] winSize]; // position the label on the center of the screen label.position = ccp( size.width /2 , size.height/2 ); // add the label as a child to this Layer [self addChild: label]; self.isTouchEnabled = YES; } return self; } -(void) registerWithTouchDispatcher{ [[CCTouchDispatcher sharedDispatcher] addTargetedDelegate:self priority:0 swallowsTouches:YES]; } - (BOOL)ccTouchBegan:(UITouch *)touch withEvent:(UIEvent *)event{ id transition = [CCTransitionFade transitionWithDuration:0.5f scene:[YourScene scene]; [[CCDirector sharedDirector] replaceScene:transition]; return YES; } 2011/6/25 29
  • 30. CCSprite sprite = [CCSprite spriteWithFile:@”sprite.png”]; // sprite.position = ccp(100, 100); // [self addChild:sprite]; // Sprite 2011/6/25 30
  • 31. // 240, 160 3 Action id move = [CCMoveTo actionWithDuration:3 position:ccp(240, 160)]; // 2 360 Action id rotate = [CCRotateBy actionWithDuration:2 angle:360]; // 4 127 Action id fade = [CCFadeTo actionWithDuration:4 opacity:127]; // Action Sequence CCSequence* sequence = [CCSequence actions:move, rotate, fade, nil]; // Sequence Sprite [sprite runAction:sequence]; 2011/6/25 31
  • 32. 2011/6/25 32
  • 33. 2011/6/25 33
  • 34. 2011/6/25 34
  • 35. 2011/6/25 35
  • 36. 2011/6/25 36
  • 37. 2011/6/25 37
  • 38. 2011/6/25 38
  • 39. 2011/6/25 39
  • 40. 2011/6/25 40
  • 41. 2011/6/25 41

Editor's Notes