Iphone and Ipad development Game with Cocos2D
-
Upload
creagamers -
Category
Technology
-
view
2.730 -
download
2
Transcript of Iphone and Ipad development Game with Cocos2D
- Intro to IOS App Development- Intro Cocos2D- Let’s make a Cocos2D game- Conclusion- Resources
- IOS 2D Gamming
-120 million ios devices-250 apps sold every second
-250000 total apps- Why IOS?
- So, what do you need to get started
- IOS Technology Stack
- Why Cocos2D?
-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, Androidcocos2d-x, in C++, multiplatformcocos2d-android-1, in Java, for Androidcocos2d-javascript, in Javascript, for Webcocos2d-iphone, in Python for iphone and ipad-It is easy to use, to create simple graphics applications
- Why Cocos2D?-Active community
http://www.cocos2d-iphone.org/forum/
- Why Cocos2D?-Wiki
http://www.cocos2d-iphone.org/wiki/doku.php/
-Features / Engine Model
-Quick intro to Objective-C
Apple’s object oriented implementation of CInfluenced by Smalltalk style messagingOriginally built for NeXTSTEPUsed for Mac OS X and IOS developmentModerate
-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
-Declarate Objects
-Class Interfaces
When you want to include header files in your source code, you typically use a #import directive
-Call Methods
-Methods declarate syntax
-Class implementation
-Example 1 - Class#import <Foundation/Foundation.h>class Hello { private: id greeting_text; // holds an NSString public: Hello() { greeting_text = @"Hello, world!"; } Hello(const char* initial_greeting_text) { greeting_text = [[NSString alloc] initWithUTF8String:initial_greeting_text]; } void say_hello() { printf("%s\n", [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
-Example 1 - Main
int main() { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; Greeting *greeting = [[Greeting alloc] init]; [greeting sayGreeting]; // > Hello, world! Hello *hello = new Hello("Bonjour, monde!"); [greeting sayGreeting:hello]; // > Bonjour, monde! delete hello; [greeting release]; [pool release]; return 0;}
Structure
-Game has Scenes-Each Scene has some nuber of Layer-Layers capture user interaction and contain sprites-Director manages the scenes
Director & Scenes
Game made up of «game screens» called ScrenesEach Scene can be considered a separate appDirector handles main windows and executes Scenes
Director
-Manages moving between Scenes -Pausing and running Scenes -Sets up OpenGL ES -Layer ask Director to move on
Scenes
Each Scene contains several full screen LayersLayers define appearance, behavior and user inputYaers contain Sprites wich are the game elements
Layers
-Take up the entire screen-Setup to handle touch and accelerometer-Can contain other layers and sprites
Important Classes
-CocosNode-Scene-Layer-Director-AtlasSprite-AtlasSPriteManager
CocosNode
-Lost of properties-Position, Scale, Camera, OpenGl z position, children-Most objects in cocos2d inherit form CocosNode
Scene
Layer
Director
AtlasSprite
AtlasSpriteManager
Sprite VS AtlasSprite
-Sprite
-AtlasSprite
-In general, dont’t use Sprites-AtlasSPrites way faster-It’s all about the OpenGL ES
-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
-New project
-Execute Xcode, and selected new project cocos aplication
-Project structure -General
-Project structure –AlphaGeeksAppDelegate.m
-Project structure –HelloWordScene.h
-Project structure –HelloWordScene.m
-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
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/