introduction to cocossharp

25

Upload: james-montemagno

Post on 30-Jul-2015

476 views

Category:

Engineering


3 download

TRANSCRIPT

Page 1: Introduction to CocosSharp
Page 2: Introduction to CocosSharp
Page 3: Introduction to CocosSharp

JamesMontemagnoDeveloper Evangelist, Xamarin

[email protected] motzcod.es @JamesMontemagno

Page 4: Introduction to CocosSharp

DESIGN – DEVELOP -‐ INTEGRATE TEST MONITOR

LEARN

Page 5: Introduction to CocosSharp

Shared C# codebase • 100% native API access • High performance

iOS C# UI Windows C# UIAndroid C# UI

Shared C# Mobile

Page 6: Introduction to CocosSharp

Building Games with Xamarin

§ MonoGame

Apple  Toy  Car  Sample  -­‐ WWDC  2014Angry  Ninjas  Sample

§ Mono for Unreal Engine

§ Sprite Kit

§ Scene Kit

§ CocosSharp

Page 7: Introduction to CocosSharp

What is CocosSharp?

“CocosSharp blends the power of the Cocos2D programming model with C# and the .NET Framework…the API has been designed to follow C# and .NET idioms.”

Miguel de IcazaXamarin

Page 8: Introduction to CocosSharp

Where it came from

Cocos2DObjective-­‐C

Cocos2D-­‐xC++

Cocos2D-­‐XNAC#

CocosSharpC#

§ .NET Idioms

§ Naming, Constructors, C#ier

§ Global State -> Multiple Directors

§ Actions as Immutable

§ NuGet & PCL Libraries

§ Extensions + Sanitized Hierarchy

§ Events, Coloring, Labels, & More

Page 9: Introduction to CocosSharp

CocosSharp API

Page 10: Introduction to CocosSharp

Typical “Scene” Hierarchy

CCApplication CCDirector

CCScene

CCLayer(Sprites)

CCLayer(Labels)

CCLayer(Menus)

CCSprite CCSprite

Page 11: Introduction to CocosSharp

CCApplication

§ Creates & Initializes the Graphics Device

§ Sets the application delegate

§ Starts the Game

var app = new CCApplication (); app.ApplicationDelegate = new MyGameDelegate ();app.StartGame ();

Page 12: Introduction to CocosSharp

CCApplicationDelegate

§ Handles application lifecycle

§ Similar to UIApplicationDelegate on iOS

§ Sets the application’s content folder

§ Load the main window’s first scene

public virtual void ApplicationDidEnterBackground

public virtual void ApplicationDidFinishLaunching

public virtual void ApplicationWillEnterForeground

Page 13: Introduction to CocosSharp

Content Folders

§ Project Folder Contains Resources

§ Fonts

§ Sounds

§ Images

§ Animations

§ Particle Systems

application.ContentRootDirectory = “Content”;application.ContentSearchPaths.Add ("sounds");

Page 14: Introduction to CocosSharp

CCDirector

§ Available via Window.DefaultDirector

§ Manages any additional scene loading

Window.DefaultDirector.ReplaceScene (GameLayer.GameScene (Window));

Page 15: Introduction to CocosSharp

CCScene

§ Manages game logic for various portions

of your game

§ Contains layers (CCLayer)

Page 16: Introduction to CocosSharp

CCLayer

§ Contains CCNodes

§ Labels, Sprites, Menus, and more

var scene = new CCScene (mainWindow);var layer = new GameStartLayer ();scene.AddChild (layer);

Page 17: Introduction to CocosSharp

CCSprite

§ Nodes that create images in your game

§ Image file must be in a Content folder

§ DefaultTexelToContentSizeRatio(s)

§ Used to maintain content across

resolutions

Page 18: Introduction to CocosSharp

CCAction

§ Actions perform tasks on nodes

§ For example, animating sprites

§ Run multiple actions sequentially using

CCSequence

§ Run multiple actions in parallel using

CCSpawn

Page 19: Introduction to CocosSharp

CCTouch

§ Encapsulates a touch on the screen

§ Override touch methods in layer

§ TouchesBegan, TouchesMoved,

TouchesEnded, etc.

§ All touches at once

§ Each touch one by one

Page 20: Introduction to CocosSharp

So Much More§ Accelerometer§ Audio§ Primitives§ Particle Systems§ Parallax§ Effects§ Physics

Page 21: Introduction to CocosSharp

Let’s  BuildA  Game!

Page 22: Introduction to CocosSharp

Resources

§ Samples§ http://github.com/mono/cocos-sharp-samples

§ Gone Bananas Walkthrough§ http://github.com/mono/cocos-sharp-

samples/blob/master/GoneBananas/Walkthrough.md

§ Introduction to CocosSharp§ http://developer.xamarin.com/guides/cross-

platform/game_development/cocossharp/first_game

Page 23: Introduction to CocosSharp

Get Started Todayxamarin.com

Page 24: Introduction to CocosSharp

Free trial - xamarin.com/university

Unrivaled Mobile Development

Training

Live unlimited mobile development training from mobile experts, in your time-zone, on your schedule, and as often as you'd like.

Page 25: Introduction to CocosSharp

Thank you.

JamesMontemagnoDeveloper Evangelist, Xamarin

[email protected] motzcod.es @JamesMontemagno

Questions?16:20  -­‐ 17:20  Right  here!