Advanced cocos2d

  • 15,143 views
Uploaded on

cocos2d iPhone advanced technics.

cocos2d iPhone advanced technics.

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
15,143
On Slideshare
0
From Embeds
0
Number of Embeds
8

Actions

Shares
Downloads
216
Comments
0
Likes
41

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Advanced cocos2d
  • 2. My Profile
  • 3. Today’s agenda
  • 4. Today’s agenda•Introduction cocos2d
  • 5. Today’s agenda•Introduction cocos2d•How to learn cocos2d
  • 6. Today’s agenda•Introduction cocos2d•How to learn cocos2d•Advanced technics
  • 7. Introduction cocos2d
  • 8. What is cocos2d ?
  • 9. What is cocos2d?
  • 10. What is cocos2d?
  • 11. What is cocos2d?
  • 12. What is cocos2d?
  • 13. What is cocos2d?
  • 14. What is cocos2d?
  • 15. 4 de coX
  • 16. http://d.hatena.ne.jp/Seasons/20110602/1307037640
  • 17. cocos2d News
  • 18. cocos2d News
  • 19. cocos2d News
  • 20. cocos2d News
  • 21. How to learn cocos2d
  • 22. Advanced Technics
  • 23. CCTitleScene CCOptionScene
  • 24. CCTitleScene replaceScene CCOptionScene[[CCDirector sharedDirector] replaceScene:[CCTransitionCrossFade transitionWithDuration:1.0 scene:[HelloWorldLayer scene]]];
  • 25. replaceScene
  • 26. replaceScene
  • 27. replaceScene
  • 28. replaceScene
  • 29. replaceScene
  • 30. replaceScene
  • 31. replaceScene
  • 32. replaceScene
  • 33. pushScene
  • 34. pushScene
  • 35. pushScene
  • 36. pushScene
  • 37. pushScene
  • 38. pushScene
  • 39. popScene
  • 40. popScene
  • 41. So lupushScene t io n
  • 42. CCTransitionScene
  • 43. CCTransitionScene
  • 44. CCTransitionScene
  • 45. Scene AScene B
  • 46. Scene ApushScene Scene B
  • 47. Scene ApushScene popScene Scene B
  • 48. Scene ApushScene popScene Scene B
  • 49. CCTransitionScene Scene A pushScene popScene Scene B
  • 50. CCTransitionScene Scene A pushScene popScene Scene B
  • 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. TexturePackerhttp://www.texturepacker.com/
  • 53. n t io luSo
  • 54. n t io luSo
  • 55. CCSprite *sprite = nil;[CCSprite spriteWithFile:@"Icon.png"];
  • 56. x5 10 speed up!!
  • 57. new
  • 58. new
  • 59. new
  • 60. n t io luSo
  • 61. PVRTC
  • 62. n t io luSo Extrude
  • 63. n t io luSo Extrude
  • 64. n t io luSo Extrude
  • 65. n t io luSo Extrude
  • 66. n t io luSo Extrude
  • 67. So lu t io nExtrude Extrude=2
  • 68. So lu t io nExtrude Extrude=2
  • 69. IMA-ADPCMima PCM
  • 70. afconvert -f caff -d ima4@22050 “ ”
  • 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. #import “cocos2d.h”#import “XXXXX.h” #undef ccp #define ccp(__X__,__Y__) CGPointMake((__X__),(480.0f-(__Y__)))
  • 73. #import “cocos2d.h”#import “XXXXX.h” #undef ccp #define ccp(__X__,__Y__) CGPointMake((__X__),(480.0f-(__Y__)))
  • 74. CCBumper Hello World
  • 75. CCBumper Hello World
  • 76. - (void) applicationDidFinishLaunching:(UIApplication*)application{ /* */! // Run the intro Scene! [[CCDirector sharedDirector] runWithScene: [CCBumper scene]];}CCBumper sceneHelloWorldLayer scene
  • 77. - (void) applicationDidFinishLaunching:(UIApplication*)application{ /* */! // Run the intro Scene! [[CCDirector sharedDirector] runWithScene: [CCBumper scene]];}CCBumper sceneHelloWorldLayer scene
  • 78. Demo
  • 79. CCResourceAsyncLoaderCCResourceAsyncLoader TextureA.png TextureB.png TextureC.png
  • 80. CCResourceAsyncLoaderCCResourceAsyncLoader TextureA.png TextureB.png TextureC.png
  • 81. CCResourceAsyncLoaderCCResourceAsyncLoader TextureA.png TextureB.png TextureC.png
  • 82. CCResourceAsyncLoaderCCResourceAsyncLoader TextureA.png TextureB.png TextureC.png
  • 83. CCResourceAsyncLoaderCCResourceAsyncLoader TextureA.png resourceCount = 3 TextureB.png TextureC.png
  • 84. CCResourceAsyncLoaderCCResourceAsyncLoader TextureB.png resourceCount = 2 3 TextureC.png
  • 85. CCResourceAsyncLoaderCCResourceAsyncLoader resourceCount = 2 3 TextureC.png
  • 86. CCResourceAsyncLoaderCCResourceAsyncLoader resourceCount = 3 TextureC.png resourceCount = 2 1
  • 87. CCResourceAsyncLoaderCCResourceAsyncLoader resourceCount = 3 resourceCount = 2 1
  • 88. CCResourceAsyncLoaderCCResourceAsyncLoader Loading Complete!! resourceCount = 3 resourceCount = 2 0
  • 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. 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. 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. 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. - (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. - (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. - (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. - (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. Demo
  • 98. Enjoy cocos2d programming