Transcript
Page 1: Iphone and Ipad development Game with Cocos2D
Page 2: Iphone and Ipad development Game with Cocos2D

- Intro to IOS App Development- Intro Cocos2D- Let’s make a Cocos2D game- Conclusion- Resources

Page 3: Iphone and Ipad development Game with Cocos2D

- IOS 2D Gamming

Page 4: Iphone and Ipad development Game with Cocos2D

-120 million ios devices-250 apps sold every second

-250000 total apps- Why IOS?

Page 5: Iphone and Ipad development Game with Cocos2D

- So, what do you need to get started

Page 6: Iphone and Ipad development Game with Cocos2D

- IOS Technology Stack

Page 7: Iphone and Ipad development Game with Cocos2D

- 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

Page 8: Iphone and Ipad development Game with Cocos2D

- Why Cocos2D?-Active community

http://www.cocos2d-iphone.org/forum/

Page 9: Iphone and Ipad development Game with Cocos2D

- Why Cocos2D?-Wiki

http://www.cocos2d-iphone.org/wiki/doku.php/

Page 10: Iphone and Ipad development Game with Cocos2D

-Features / Engine Model

Page 11: Iphone and Ipad development Game with Cocos2D

-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

Page 12: Iphone and Ipad development Game with Cocos2D

-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

Page 13: Iphone and Ipad development Game with Cocos2D

-Declarate Objects

Page 14: Iphone and Ipad development Game with Cocos2D

-Class Interfaces

When you want to include header files in your source code, you typically use a #import directive

Page 15: Iphone and Ipad development Game with Cocos2D

-Call Methods

Page 16: Iphone and Ipad development Game with Cocos2D

-Methods declarate syntax

Page 17: Iphone and Ipad development Game with Cocos2D

-Class implementation

Page 18: Iphone and Ipad development Game with Cocos2D

-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

Page 19: Iphone and Ipad development Game with Cocos2D

-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;}

Page 20: Iphone and Ipad development Game with Cocos2D

Structure

-Game has Scenes-Each Scene has some nuber of Layer-Layers capture user interaction and contain sprites-Director manages the scenes

Page 21: Iphone and Ipad development Game with Cocos2D

Director & Scenes

Game made up of «game screens» called ScrenesEach Scene can be considered a separate appDirector handles main windows and executes Scenes

Page 22: Iphone and Ipad development Game with Cocos2D

Director

-Manages moving between Scenes -Pausing and running Scenes -Sets up OpenGL ES -Layer ask Director to move on

Page 23: Iphone and Ipad development Game with Cocos2D

Scenes

Each Scene contains several full screen LayersLayers define appearance, behavior and user inputYaers contain Sprites wich are the game elements

Page 24: Iphone and Ipad development Game with Cocos2D

Layers

-Take up the entire screen-Setup to handle touch and accelerometer-Can contain other layers and sprites

Page 25: Iphone and Ipad development Game with Cocos2D

Important Classes

-CocosNode-Scene-Layer-Director-AtlasSprite-AtlasSPriteManager

Page 26: Iphone and Ipad development Game with Cocos2D

CocosNode

-Lost of properties-Position, Scale, Camera, OpenGl z position, children-Most objects in cocos2d inherit form CocosNode

Page 27: Iphone and Ipad development Game with Cocos2D

Scene

Page 28: Iphone and Ipad development Game with Cocos2D

Layer

Page 29: Iphone and Ipad development Game with Cocos2D

Director

Page 30: Iphone and Ipad development Game with Cocos2D

AtlasSprite

Page 31: Iphone and Ipad development Game with Cocos2D

AtlasSpriteManager

Page 32: Iphone and Ipad development Game with Cocos2D

Sprite VS AtlasSprite

-Sprite

-AtlasSprite

-In general, dont’t use Sprites-AtlasSPrites way faster-It’s all about the OpenGL ES

Page 33: Iphone and Ipad development Game with Cocos2D

-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

Page 34: Iphone and Ipad development Game with Cocos2D

-New project

-Execute Xcode, and selected new project cocos aplication

Page 35: Iphone and Ipad development Game with Cocos2D

-Project structure -General

Page 36: Iphone and Ipad development Game with Cocos2D

-Project structure –AlphaGeeksAppDelegate.m

Page 37: Iphone and Ipad development Game with Cocos2D

-Project structure –HelloWordScene.h

Page 38: Iphone and Ipad development Game with Cocos2D

-Project structure –HelloWordScene.m

Page 39: Iphone and Ipad development Game with Cocos2D

-Adding Background

Page 40: Iphone and Ipad development Game with Cocos2D

-Adding Our Hero

Page 41: Iphone and Ipad development Game with Cocos2D

-Adding Bad Guys (Game Logic)

Page 42: Iphone and Ipad development Game with Cocos2D

-Killing Bad Guys (Adding UI)

Page 43: Iphone and Ipad development Game with Cocos2D

-Animating Out Hero

Page 44: Iphone and Ipad development Game with Cocos2D

-Animating Bad Guys Dying

Page 45: Iphone and Ipad development Game with Cocos2D

-Adding Body Count

Page 46: Iphone and Ipad development Game with Cocos2D

-Adding Sound & Music

Page 47: Iphone and Ipad development Game with Cocos2D

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/


Top Related