Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

iOS Gaming with Cocos2d

3,397 views

Published on

Published in: Technology, Design
  • DOWNLOAD FULL BOOKS, INTO AVAILABLE FORMAT ......................................................................................................................... ......................................................................................................................... ,DOWNLOAD FULL. PDF EBOOK here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... ,DOWNLOAD FULL. EPUB Ebook here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... ,DOWNLOAD FULL. doc Ebook here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... ,DOWNLOAD FULL. PDF EBOOK here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... ,DOWNLOAD FULL. EPUB Ebook here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... ,DOWNLOAD FULL. doc Ebook here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • nice ebook game
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Link source code demo: http://www.mediafire.com/?m58eq1fc675i6e0
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

iOS Gaming with Cocos2d

  1. 1. iOS gaming with cocos2d<br />Prepared by Ngo Duc Hiep<br />Copyright 2011 PTT Solution ., JSC. All rights reserved.<br />Hanoi, May 2011<br />
  2. 2. iOS game engines<br />cocos2d<br />Sparrow<br />Galaxy<br />oolong<br />
  3. 3. iOS game engines<br />Game salad<br />Corona<br />Unity<br />iTorque<br />
  4. 4. iOS game engines<br />http://maniacdev.com/2011/01/open-source-and-commercial-ios-game-engine-listings-updated/<br />http://maniacdev.com/2009/09/the-commercial-iphone-game-engine-comparison-3d-and-2d/<br />
  5. 5. cocos2d games<br />Tap Pet Hotel: #1 Free<br />Zombie Farm: #6 Free<br />Tap Zoo: #2 Free<br />iStunt 2: #6 Free<br />
  6. 6. cocos2d games<br />ZombieSmash: #1 Paid<br />Air Penguin: #1 Paid<br />Trainyard: #2 Paid<br />Fishing Frenzy: #7 Paid<br />
  7. 7. cocos2d<br />
  8. 8. App workflow<br />Settings<br />Loading<br />Home<br />Game Play<br />Leaderboard<br />
  9. 9. App workflow<br />CCScene<br />CCDirector: run, push, pop replace scene<br /><ul><li>[[CCDirectorsharedDirector] runWithScene:loading];
  10. 10. [[CCDirectorsharedDirector] replaceScene:home];
  11. 11. CCTransition: transition between scenes</li></li></ul><li>CCLayer<br />
  12. 12. CCLayer<br />Handle event<br /><ul><li>isTouchEnabled_
  13. 13. isAccelerometerEnabled_</li></ul>Game controller<br />Mange game entities - CCNode<br />
  14. 14. CCNode<br />Renderable item<br />CCLayer, CCScene are all nodes<br />Features<br /><ul><li>Contains another nodes
  15. 15. Schedule timer
  16. 16. Play actions
  17. 17. Position/rotation/scale/contentSize</li></li></ul><li>CCSprite<br />Sprites<br />Texture<br />
  18. 18. CCNode: Coordinate<br />contentSize.width<br />contentSize.height<br />
  19. 19. CCNode: Coordinate<br />anchorPoint<br />rotation<br />position<br />
  20. 20. CCNode: Coordinate<br />
  21. 21. CCNode: Transformation<br />- (CGAffineTransform)nodeToParentTransform;<br />- (CGAffineTransform)parentToNodeTransform;<br />- (CGAffineTransform)nodeToWorldTransform;<br />- (CGAffineTransform)worldToNodeTransform;<br />- (CGPoint)convertToNodeSpace:(CGPoint)worldPoint;<br />- (CGPoint)convertToWorldSpace:(CGPoint)nodePoint;<br />
  22. 22. CCNode: Actions<br />Modify node’s attributes by time<br />position/rotation/scale/opacity/grid<br />Interval actions and Instant actions<br />
  23. 23. CCNode: Actions<br />CCMove_<br />CCJump_<br />CCBezier_<br />CCScale_<br />CCRotate_<br />CCFade_<br />
  24. 24. CCNode: Actions<br />Time alter actions:<br /><ul><li>CCEase_
  25. 25. CCEaseExponential_
  26. 26. CCEaseSine_
  27. 27. CCEaseElastic_
  28. 28. CCEaseBounce_</li></li></ul><li>CCNode: Special actions<br />CCCallFunc<br />CCCallBlock<br />CCPropertyAction<br />CCFollow<br />CCSequence<br />CCSpawn<br />CCRepeat<br />
  29. 29. CCNode: 3D Effects<br />CCFlipX3D/CCFlipY3D<br />CCWaves3D<br />CCRipple3D<br />CCSplitRows<br />…<br />
  30. 30. CCSprite: Animation<br />
  31. 31. CCSprite: Animation<br />
  32. 32. CCNode: Scheduler<br />-(void) schedule: (SEL) s interval:(ccTime)seconds;<br />-(void) unschedule: (SEL) s;<br />-(void) pauseSchedulerAndActions;<br />-(void) resumeSchedulerAndActions;<br />
  33. 33. Touch Dispathcher<br />CCTouchDispathcher<br />-(void) addStandardDelegate:(id) delegate priority:(int)priority;<br />-(void) addTargetedDelegate:(id) delegate priority:(int)priority swallowsTouches:(BOOL)swallowsTouches;<br />-(void) removeDelegate:(id) delegate;<br />
  34. 34. Box2D<br />
  35. 35. Features<br />Rigid body<br /><ul><li>Fixture: rectangle, circle, poligon</li></ul>Joint<br />Contact filter<br />Contact listener<br />Simulate<br /> world->Step(dt);<br />
  36. 36. cocos2d  Box2D<br />Body, joint, fixture user data<br />for (b2Body* b = world->GetBodyList(); b; b = b->GetNext())<br />{<br /> if (b->GetUserData() != NULL) {<br />CCSprite *actor = (CCSprite*)b->GetUserData();<br />actor.position = CGPointMake( b->GetPosition().x , b->GetPosition().y);<br />actor.rotation = -b->GetAngle() * 180 / M_PI;<br /> } <br />}<br />
  37. 37. Car<br />Cocos2d<br />ccCarBody<br />ccCarWheel1<br />ccCarWhell2<br />Box2D<br /><ul><li>b2CarBody
  38. 38. b2CarWheel1
  39. 39. b2CarWhell2
  40. 40. b2CarJoint1
  41. 41. b2CarJoint2</li></li></ul><li>cocos2d+ext<br />
  42. 42. CCNode+ext<br />Transform<br /><ul><li>- (CGAffineTransform) nodeToNodeTransform:</li></ul> (CCNode *) node;<br /><ul><li>- (CGAffineTransform) nodeFromNodeTransform:</li></ul> (CCNode *) node;<br />
  43. 43. CCNode+ext<br />Transform<br />Collision<br /><ul><li>- (CGRect) rect;
  44. 44. - (BOOL) isCollideWithNode:(CCNode *) node;</li></li></ul><li>CCNode+ext<br />Transform<br />Collision<br />Containing<br /><ul><li>- (BOOL) containsPoint:(CGPoint) loc;
  45. 45. - (BOOL) containsTouch:(UITouch *) touch;</li></li></ul><li>CCSprite+ext<br />- (CCAction *) animateFramesWithKey:(NSString *) key <br />startIndex:(int) start <br />endIndex:(int) end <br />duration:(float) duration <br />reverse:(BOOL) reverse <br />forever:(BOOL) forever;<br />
  46. 46. CCComponent<br />Independent, portable<br />States control<br />Data driven<br />Callbacks<br />Physics support<br />Composition<br />
  47. 47. CCComponent<br />Data<br />Texture file<br />Texture def file<br />Component def file<br />States<br />Childs<br />
  48. 48. CCComponent<br />States<br />Animate frames<br />Rotate <br />Scale<br />Fade<br />
  49. 49. CCComponent<br />Lion_jump_1.png<br />Lion_jump_2.png<br />Lion_jump_4.png<br />Lion_jump_3.png<br />
  50. 50. CCComponent<br />Lion “jump” state:<br />key=Lion_jump_<br /> type=frame<br />startframe=1<br />endframe=4<br /> duration=0.1<br /> forever=NO<br /> lion.state = @”jump”;<br />
  51. 51. CCComponent<br />- (void) setState:(NSString *) state;<br />- (void) setState:(NSString *) state target:(NSString *) target selector:(SEL) selector;<br />- (void) spawnStates:(NSString *) state1,…;<br />- (void)setStateSequence:(NSString *) state1, …;<br />
  52. 52. CCLayer+ext<br />Actors group<br /><ul><li>addChild:(CCNode *) child group:(int) gid;
  53. 53. removeChild:(CCNode *) child group:(int) gid;</li></li></ul><li>CCLayer+ext<br />Contacts listener<br /><ul><li>addContactListenerBetweenGroup:(int) g1 andGroup:(int) g2 selector:(SEL) listener;</li></ul>- (void) hero:(Hero *) hero collideWith:(Bullet *) bullet{<br />hero.blood -= bullet.effect;<br /> [bullet explode];<br />}<br />
  54. 54. CCLayer+ext<br />Touch helper<br /><ul><li>- (CGPoint) pointForTouches:(NSSet *) touches;
  55. 55. - (CGPoint) pointForTouch:(UITouch *) touch;
  56. 56. - (CCNode *) getActorAtPoint:(CGPoint) pos;
  57. 57. - (CCNode *) getActorAtTouch:(UITouch *) touch;</li></li></ul><li>Tools<br />
  58. 58. Texture: texturetool, TexturePacker, Zwoptex<br />Tile map editor: Tiled<br />SVG editor: Inkscape, svg-edit  Level design<br />Particle: Particle Designer<br />Font editor: Hiero<br />Audio: Audacity<br />3D: Blender<br />
  59. 59. Learning resources<br />
  60. 60. http://cs193p.stanford.edu<br />https://developer.apple.com/itunes/?destination=adc.apple.com.4092414566<br />http://www.71squared.com/<br />http://www.raywenderlich.com/<br />http://iphonedevelopment.blogspot.com/<br />http://maniacdev.com<br />http://iphonedev.net/<br />http://www.learn-cocos2d.com/<br />http://cocoawithlove.com/<br />https://github.com/hiepnd<br />
  61. 61. Demo & QA<br />

×