Iphone and Ipad development Game with Cocos2D


Published on

Published in: Technology
1 Comment
No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Iphone and Ipad development Game with Cocos2D

  1. 2. <ul><li>Intro to IOS App Development </li></ul><ul><li>Intro Cocos2D </li></ul><ul><li>Let’s make a Cocos2D game </li></ul><ul><li>Conclusion </li></ul><ul><li>Resources </li></ul>
  2. 3. <ul><li>IOS 2D Gamming </li></ul>
  3. 4. -120 million ios devices -250 apps sold every second -250000 total apps <ul><li>Why IOS? </li></ul>
  4. 5. <ul><li>So, what do you need to get started </li></ul>
  5. 6. <ul><li>IOS Technology Stack </li></ul>
  6. 7. <ul><li>Why Cocos2D? </li></ul>-iOS game development framework based on original cocos2d for python developed by Ricardo Quesada Based on OpenGL 1.1 -Open Source, latest version -Multiplatforms: iOS, uPhone, Win32. Coming soon: Bada, Android cocos2d-x, in C++, multiplatform cocos2d-android-1, in Java, for Android cocos2d-javascript, in Javascript, for Web cocos2d-iphone, in Python for iphone and ipad - It is easy to use, to create simple graphics applications
  7. 8. <ul><li>Why Cocos2D? </li></ul>-Active community http://www.cocos2d-iphone.org/forum/
  8. 9. <ul><li>Why Cocos2D? </li></ul>-Wiki http://www.cocos2d-iphone.org/wiki/doku.php/
  9. 10. -Features / Engine Model
  10. 11. -Quick intro to Objective-C Apple’s object oriented implementation of C Influenced by Smalltalk style messaging Originally built for NeXTSTEP Used for Mac OS X and IOS development Moderate
  11. 12. -Type files Header files. Header files contain class, type, function, and constant declarations. Source files. This is the typical extension used for source files and can contain both Objective-C and C code. Source files. A source file with this extension can contain C++ code in addition to Objective-C and C code. This extension should be used only if you actually refer to C++ classes or features from your Objective-C code. .h .m .mm When you want to include header files in your source code, you typically use a  #import  directive
  12. 13. -Declarate Objects
  13. 14. -Class Interfaces When you want to include header files in your source code, you typically use a  #import  directive
  14. 15. -Call Methods
  15. 16. -Methods declarate syntax
  16. 17. -Class implementation
  17. 18. -Example 1 - Class #import <Foundation/Foundation.h> class Hello { private: id greeting_text; // holds an NSString public: Hello() { greeting_text = @&quot;Hello, world!&quot;; } Hello(const char* initial_greeting_text) { greeting_text = [[NSString alloc] initWithUTF8String:initial_greeting_text]; } void say_hello() { printf(&quot;%sn&quot;, [greeting_text UTF8String]); } }; @interface Greeting : NSObject { @private Hello *hello; } - (id)init; - (void)dealloc; - (void)sayGreeting; - (void)sayGreeting:(Hello*)greeting; @end @implementation Greeting - (id)init { self = [super init]; if (self) { hello = new Hello(); } return self; } - (void)dealloc { delete hello; [super dealloc]; } - (void)sayGreeting { hello->say_hello(); } - (void)sayGreeting:(Hello*)greeting { greeting->say_hello(); } @end
  18. 19. -Example 1 - Main int main() { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; Greeting *greeting = [[Greeting alloc] init]; [greeting sayGreeting]; // > Hello, world! Hello *hello = new Hello(&quot;Bonjour, monde!&quot;); [greeting sayGreeting:hello]; // > Bonjour, monde! delete hello; [greeting release]; [pool release]; return 0; }
  19. 20. Structure -Game has Scenes -Each Scene has some nuber of Layer -Layers capture user interaction and contain sprites -Director manages the scenes
  20. 21. Director & Scenes Game made up of «game screens» called Screnes Each Scene can be considered a separate app Director handles main windows and executes Scenes
  21. 22. Director -Manages moving between Scenes -Pausing and running Scenes -Sets up OpenGL ES -Layer ask Director to move on
  22. 23. Scenes Each Scene contains several full screen Layers Layers define appearance, behavior and user input Yaers contain Sprites wich are the game elements
  23. 24. Layers -Take up the entire screen -Setup to handle touch and accelerometer -Can contain other layers and sprites
  24. 25. Important Classes -CocosNode -Scene -Layer -Director -AtlasSprite -AtlasSPriteManager
  25. 26. CocosNode -Lost of properties -Position, Scale, Camera, OpenGl z position, children -Most objects in cocos2d inherit form CocosNode
  26. 27. Scene
  27. 28. Layer
  28. 29. Director
  29. 30. AtlasSprite
  30. 31. AtlasSpriteManager
  31. 32. Sprite VS AtlasSprite -Sprite -AtlasSprite -In general, dont’t use Sprites -AtlasSPrites way faster -It’s all about the OpenGL ES
  32. 33. -Setup project -New project -Project Structure -Adding Background -Adding Our Hero -Adding Bad Guys (Game Logic) -Killing Bad Guys (Adding UI) -Animating Out Hero -Animating Bad Guys Dying -Adding Body Count -Adding Sound & Music
  33. 34. -New project -Execute Xcode, and selected new project cocos aplication
  34. 35. -Project structure -General
  35. 36. -Project structure –AlphaGeeksAppDelegate.m
  36. 37. -Project structure –HelloWordScene.h
  37. 38. -Project structure –HelloWordScene.m
  38. 39. -Adding Background
  39. 40. -Adding Our Hero
  40. 41. -Adding Bad Guys (Game Logic)
  41. 42. -Killing Bad Guys (Adding UI)
  42. 43. -Animating Out Hero
  43. 44. -Animating Bad Guys Dying
  44. 45. -Adding Body Count
  45. 46. -Adding Sound & Music
  46. 47. http://developer.apple.com http://www.slideshare.net/360conferences/introtoduction-to-cocos2d?src=related_normal&rel=5237272 http://www.slideshare.net/Greenwell/iphone-and-ipad-game-development-with-cocos2d http://www.cocos2d-iphone.org/ http://cocos2d.org/