Successfully reported this slideshow.
Advanced cocos2d
My Profile
Today’s agenda
Today’s agenda•Introduction cocos2d
Today’s agenda•Introduction cocos2d•How to learn cocos2d
Today’s agenda•Introduction cocos2d•How to learn cocos2d•Advanced technics
Introduction cocos2d
What is cocos2d ?
What is cocos2d?
What is cocos2d?
What is cocos2d?
What is cocos2d?
What is cocos2d?
What is cocos2d?
4      de coX
http://d.hatena.ne.jp/Seasons/20110602/1307037640
cocos2d News
cocos2d News
cocos2d News
cocos2d News
How to learn cocos2d
Advanced Technics
CCTitleScene   CCOptionScene
CCTitleScene                        replaceScene     CCOptionScene[[CCDirector sharedDirector] replaceScene:[CCTransitionC...
replaceScene
replaceScene
replaceScene
replaceScene
replaceScene
replaceScene
replaceScene
replaceScene
pushScene
pushScene
pushScene
pushScene
pushScene
pushScene
popScene
popScene
So            lupushScene             t io                 n
CCTransitionScene
CCTransitionScene
CCTransitionScene
Scene AScene B
Scene ApushScene            Scene B
Scene ApushScene             popScene            Scene B
Scene ApushScene             popScene            Scene B
CCTransitionScene   Scene A     pushScene                popScene                    Scene B
CCTransitionScene   Scene A     pushScene                popScene                    Scene B
So                                                                                              lu                        ...
TexturePackerhttp://www.texturepacker.com/
n          t io     luSo
n          t io     luSo
CCSprite *sprite = nil;[CCSprite spriteWithFile:@"Icon.png"];
x5   10 speed up!!
new
new
new
n          t io     luSo
PVRTC
n          t io     luSo                     Extrude
n          t io     luSo                     Extrude
n          t io     luSo                     Extrude
n          t io     luSo                     Extrude
n          t io     luSo                     Extrude
So                      lu                       t io                           nExtrude          Extrude=2
So                      lu                       t io                           nExtrude          Extrude=2
IMA-ADPCMima   PCM
afconvert -f caff -d ima4@22050 “   ”
So                                                           lu                                                           ...
#import “cocos2d.h”#import “XXXXX.h” #undef ccp #define ccp(__X__,__Y__) CGPointMake((__X__),(480.0f-(__Y__)))
#import “cocos2d.h”#import “XXXXX.h” #undef ccp #define ccp(__X__,__Y__) CGPointMake((__X__),(480.0f-(__Y__)))
CCBumper  Hello World
CCBumper  Hello World
- (void) applicationDidFinishLaunching:(UIApplication*)application{    /*     */! // Run the intro Scene! [[CCDirector sha...
- (void) applicationDidFinishLaunching:(UIApplication*)application{    /*     */! // Run the intro Scene! [[CCDirector sha...
Demo
CCResourceAsyncLoaderCCResourceAsyncLoader                        TextureA.png                        TextureB.png        ...
CCResourceAsyncLoaderCCResourceAsyncLoader    TextureA.png                        TextureB.png                        Text...
CCResourceAsyncLoaderCCResourceAsyncLoader    TextureA.png     TextureB.png                        TextureC.png
CCResourceAsyncLoaderCCResourceAsyncLoader    TextureA.png     TextureB.png     TextureC.png
CCResourceAsyncLoaderCCResourceAsyncLoader    TextureA.png        resourceCount = 3     TextureB.png     TextureC.png
CCResourceAsyncLoaderCCResourceAsyncLoader     TextureB.png       resourceCount = 2                                       ...
CCResourceAsyncLoaderCCResourceAsyncLoader                        resourceCount = 2                                       ...
CCResourceAsyncLoaderCCResourceAsyncLoader                        resourceCount = 3     TextureC.png       resourceCount =...
CCResourceAsyncLoaderCCResourceAsyncLoader                        resourceCount = 3                        resourceCount =...
CCResourceAsyncLoaderCCResourceAsyncLoader                        Loading Complete!!                        resourceCount ...
CCResourceAsyncLoader *loader = nil;NSArray *resourceNames = [NSArray arrayWithObjects:                          @"1.tif",...
CCResourceAsyncLoader *loader = nil;NSArray *resourceNames = [NSArray arrayWithObjects:                          @"1.tif",...
CCResourceAsyncLoader *loader = nil;NSArray *resourceNames = [NSArray arrayWithObjects:                          @"1.tif",...
CCResourceAsyncLoader *loader = nil;NSArray *resourceNames = [NSArray arrayWithObjects:                          @"1.tif",...
- (void) loadComplete {    CCNode *obj = [self getChildByTag:kTag_CCBumper_Loader];    NSAssert([obj isKindOfClass:[CCReso...
- (void) loadComplete {    CCNode *obj = [self getChildByTag:kTag_CCBumper_Loader];    NSAssert([obj isKindOfClass:[CCReso...
- (void) loadComplete {    CCNode *obj = [self getChildByTag:kTag_CCBumper_Loader];    NSAssert([obj isKindOfClass:[CCReso...
- (void) loadComplete {    CCNode *obj = [self getChildByTag:kTag_CCBumper_Loader];    NSAssert([obj isKindOfClass:[CCReso...
Demo
Enjoy cocos2d programming
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Advanced cocos2d
Upcoming SlideShare
Loading in …5
×

Advanced cocos2d

17,478 views

Published on

cocos2d iPhone advanced technics.

Published in: Technology
  • Be the first to comment

Advanced cocos2d

  1. 1. Advanced cocos2d
  2. 2. My Profile
  3. 3. Today’s agenda
  4. 4. Today’s agenda•Introduction cocos2d
  5. 5. Today’s agenda•Introduction cocos2d•How to learn cocos2d
  6. 6. Today’s agenda•Introduction cocos2d•How to learn cocos2d•Advanced technics
  7. 7. Introduction cocos2d
  8. 8. What is cocos2d ?
  9. 9. What is cocos2d?
  10. 10. What is cocos2d?
  11. 11. What is cocos2d?
  12. 12. What is cocos2d?
  13. 13. What is cocos2d?
  14. 14. What is cocos2d?
  15. 15. 4 de coX
  16. 16. http://d.hatena.ne.jp/Seasons/20110602/1307037640
  17. 17. cocos2d News
  18. 18. cocos2d News
  19. 19. cocos2d News
  20. 20. cocos2d News
  21. 21. How to learn cocos2d
  22. 22. Advanced Technics
  23. 23. CCTitleScene CCOptionScene
  24. 24. CCTitleScene replaceScene CCOptionScene[[CCDirector sharedDirector] replaceScene:[CCTransitionCrossFade transitionWithDuration:1.0 scene:[HelloWorldLayer scene]]];
  25. 25. replaceScene
  26. 26. replaceScene
  27. 27. replaceScene
  28. 28. replaceScene
  29. 29. replaceScene
  30. 30. replaceScene
  31. 31. replaceScene
  32. 32. replaceScene
  33. 33. pushScene
  34. 34. pushScene
  35. 35. pushScene
  36. 36. pushScene
  37. 37. pushScene
  38. 38. pushScene
  39. 39. popScene
  40. 40. popScene
  41. 41. So lupushScene t io n
  42. 42. CCTransitionScene
  43. 43. CCTransitionScene
  44. 44. CCTransitionScene
  45. 45. Scene AScene B
  46. 46. Scene ApushScene Scene B
  47. 47. Scene ApushScene popScene Scene B
  48. 48. Scene ApushScene popScene Scene B
  49. 49. CCTransitionScene Scene A pushScene popScene Scene B
  50. 50. CCTransitionScene Scene A pushScene popScene Scene B
  51. 51. So lu t io popSceneWithTransition n-(void) popSceneWithTransition: (Class)transitionClass duration:(ccTime)t{! NSAssert( runningScene_ != nil, @"A running Scene is needed");! [scenesStack_ removeLastObject];! NSUInteger c = [scenesStack_ count];! if( c == 0 ) {! ! [self end];! } else {! ! CCScene* scene = [transitionClass transitionWithDuration:t scene:[scenesStack_ objectAtIndex:c-1]];! ! [scenesStack_ replaceObjectAtIndex:c-1 withObject:scene];! ! nextScene_ = scene;! }} http://www.cocos2d-iphone.org/forum/topic/1076
  52. 52. TexturePackerhttp://www.texturepacker.com/
  53. 53. n t io luSo
  54. 54. n t io luSo
  55. 55. CCSprite *sprite = nil;[CCSprite spriteWithFile:@"Icon.png"];
  56. 56. x5 10 speed up!!
  57. 57. new
  58. 58. new
  59. 59. new
  60. 60. n t io luSo
  61. 61. PVRTC
  62. 62. n t io luSo Extrude
  63. 63. n t io luSo Extrude
  64. 64. n t io luSo Extrude
  65. 65. n t io luSo Extrude
  66. 66. n t io luSo Extrude
  67. 67. So lu t io nExtrude Extrude=2
  68. 68. So lu t io nExtrude Extrude=2
  69. 69. IMA-ADPCMima PCM
  70. 70. afconvert -f caff -d ima4@22050 “ ”
  71. 71. So lu t io n#undef ccp#define ccp(__X__,__Y__) CGPointMake((__X__),(480.0f-(__Y__)))#undef ccp#define ccp(__X__,__Y__) CGPointMake((__X__),(320.0f-(__Y__)))#define ccop(__X__,__Y__) CGPointMake( (__X__),(__Y__) )
  72. 72. #import “cocos2d.h”#import “XXXXX.h” #undef ccp #define ccp(__X__,__Y__) CGPointMake((__X__),(480.0f-(__Y__)))
  73. 73. #import “cocos2d.h”#import “XXXXX.h” #undef ccp #define ccp(__X__,__Y__) CGPointMake((__X__),(480.0f-(__Y__)))
  74. 74. CCBumper Hello World
  75. 75. CCBumper Hello World
  76. 76. - (void) applicationDidFinishLaunching:(UIApplication*)application{ /* */! // Run the intro Scene! [[CCDirector sharedDirector] runWithScene: [CCBumper scene]];}CCBumper sceneHelloWorldLayer scene
  77. 77. - (void) applicationDidFinishLaunching:(UIApplication*)application{ /* */! // Run the intro Scene! [[CCDirector sharedDirector] runWithScene: [CCBumper scene]];}CCBumper sceneHelloWorldLayer scene
  78. 78. Demo
  79. 79. CCResourceAsyncLoaderCCResourceAsyncLoader TextureA.png TextureB.png TextureC.png
  80. 80. CCResourceAsyncLoaderCCResourceAsyncLoader TextureA.png TextureB.png TextureC.png
  81. 81. CCResourceAsyncLoaderCCResourceAsyncLoader TextureA.png TextureB.png TextureC.png
  82. 82. CCResourceAsyncLoaderCCResourceAsyncLoader TextureA.png TextureB.png TextureC.png
  83. 83. CCResourceAsyncLoaderCCResourceAsyncLoader TextureA.png resourceCount = 3 TextureB.png TextureC.png
  84. 84. CCResourceAsyncLoaderCCResourceAsyncLoader TextureB.png resourceCount = 2 3 TextureC.png
  85. 85. CCResourceAsyncLoaderCCResourceAsyncLoader resourceCount = 2 3 TextureC.png
  86. 86. CCResourceAsyncLoaderCCResourceAsyncLoader resourceCount = 3 TextureC.png resourceCount = 2 1
  87. 87. CCResourceAsyncLoaderCCResourceAsyncLoader resourceCount = 3 resourceCount = 2 1
  88. 88. CCResourceAsyncLoaderCCResourceAsyncLoader Loading Complete!! resourceCount = 3 resourceCount = 2 0
  89. 89. CCResourceAsyncLoader *loader = nil;NSArray *resourceNames = [NSArray arrayWithObjects: @"1.tif", @"2.tif", @"3.tif", nil];CCSendMessages *message = [CCSendMessages actionWithTarget:self];[[message addMessage] loadComplete];loader = [CCResourceAsyncLoader loaderWithCount:[resourceNames count]];loader.tag = kTag_CCBumper_Loader;for (NSString *path in resourceNames) { [loader addLoadAsyncTexture:path message:message];}[self addChild:loader];
  90. 90. CCResourceAsyncLoader *loader = nil;NSArray *resourceNames = [NSArray arrayWithObjects: @"1.tif", @"2.tif", @"3.tif", nil];CCSendMessages *message = [CCSendMessages actionWithTarget:self];[[message addMessage] loadComplete];loader = [CCResourceAsyncLoader loaderWithCount:[resourceNames count]];loader.tag = kTag_CCBumper_Loader;for (NSString *path in resourceNames) { [loader addLoadAsyncTexture:path message:message];}[self addChild:loader];
  91. 91. CCResourceAsyncLoader *loader = nil;NSArray *resourceNames = [NSArray arrayWithObjects: @"1.tif", @"2.tif", @"3.tif", nil];CCSendMessages *message = [CCSendMessages actionWithTarget:self];[[message addMessage] loadComplete];loader = [CCResourceAsyncLoader loaderWithCount:[resourceNames count]];loader.tag = kTag_CCBumper_Loader;for (NSString *path in resourceNames) { [loader addLoadAsyncTexture:path message:message];}[self addChild:loader];
  92. 92. CCResourceAsyncLoader *loader = nil;NSArray *resourceNames = [NSArray arrayWithObjects: @"1.tif", @"2.tif", @"3.tif", nil];CCSendMessages *message = [CCSendMessages actionWithTarget:self];[[message addMessage] loadComplete];loader = [CCResourceAsyncLoader loaderWithCount:[resourceNames count]];loader.tag = kTag_CCBumper_Loader;for (NSString *path in resourceNames) { [loader addLoadAsyncTexture:path message:message];}[self addChild:loader];
  93. 93. - (void) loadComplete { CCNode *obj = [self getChildByTag:kTag_CCBumper_Loader]; NSAssert([obj isKindOfClass:[CCResourceAsyncLoader class]], @"Not CCResourceAsyncLoader"); CCResourceAsyncLoader *loader = (CCResourceAsyncLoader *)obj; loader.resourceCount--; // Load Complete!! if( loader.resourceCount == 0 ) { /* */ } /* loader.resourceCount */}
  94. 94. - (void) loadComplete { CCNode *obj = [self getChildByTag:kTag_CCBumper_Loader]; NSAssert([obj isKindOfClass:[CCResourceAsyncLoader class]], @"Not CCResourceAsyncLoader"); CCResourceAsyncLoader *loader = (CCResourceAsyncLoader *)obj; loader.resourceCount--; // Load Complete!! if( loader.resourceCount == 0 ) { /* */ } /* loader.resourceCount */}
  95. 95. - (void) loadComplete { CCNode *obj = [self getChildByTag:kTag_CCBumper_Loader]; NSAssert([obj isKindOfClass:[CCResourceAsyncLoader class]], @"Not CCResourceAsyncLoader"); CCResourceAsyncLoader *loader = (CCResourceAsyncLoader *)obj; loader.resourceCount--; // Load Complete!! if( loader.resourceCount == 0 ) { /* */ } /* loader.resourceCount */}
  96. 96. - (void) loadComplete { CCNode *obj = [self getChildByTag:kTag_CCBumper_Loader]; NSAssert([obj isKindOfClass:[CCResourceAsyncLoader class]], @"Not CCResourceAsyncLoader"); CCResourceAsyncLoader *loader = (CCResourceAsyncLoader *)obj; loader.resourceCount--; // Load Complete!! if( loader.resourceCount == 0 ) { /* */ } /* loader.resourceCount */}
  97. 97. Demo
  98. 98. Enjoy cocos2d programming

×