Introduction to CocosSharp
-
Upload
james-montemagno -
Category
Engineering
-
view
478 -
download
3
Transcript of Introduction to CocosSharp
JamesMontemagnoDeveloper Evangelist, Xamarin
[email protected] motzcod.es @JamesMontemagno
DESIGN – DEVELOP -‐ INTEGRATE TEST MONITOR
LEARN
Shared C# codebase • 100% native API access • High performance
iOS C# UI Windows C# UIAndroid C# UI
Shared C# Mobile
Building Games with Xamarin
§ MonoGame
Apple Toy Car Sample -‐ WWDC 2014Angry Ninjas Sample
§ Mono for Unreal Engine
§ Sprite Kit
§ Scene Kit
§ 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
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
CocosSharp API
Typical “Scene” Hierarchy
CCApplication CCDirector
CCScene
CCLayer(Sprites)
CCLayer(Labels)
CCLayer(Menus)
CCSprite CCSprite
CCApplication
§ Creates & Initializes the Graphics Device
§ Sets the application delegate
§ Starts the Game
var app = new CCApplication (); app.ApplicationDelegate = new MyGameDelegate ();app.StartGame ();
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
Content Folders
§ Project Folder Contains Resources
§ Fonts
§ Sounds
§ Images
§ Animations
§ Particle Systems
application.ContentRootDirectory = “Content”;application.ContentSearchPaths.Add ("sounds");
CCDirector
§ Available via Window.DefaultDirector
§ Manages any additional scene loading
Window.DefaultDirector.ReplaceScene (GameLayer.GameScene (Window));
CCScene
§ Manages game logic for various portions
of your game
§ Contains layers (CCLayer)
CCLayer
§ Contains CCNodes
§ Labels, Sprites, Menus, and more
var scene = new CCScene (mainWindow);var layer = new GameStartLayer ();scene.AddChild (layer);
CCSprite
§ Nodes that create images in your game
§ Image file must be in a Content folder
§ DefaultTexelToContentSizeRatio(s)
§ Used to maintain content across
resolutions
CCAction
§ Actions perform tasks on nodes
§ For example, animating sprites
§ Run multiple actions sequentially using
CCSequence
§ Run multiple actions in parallel using
CCSpawn
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
So Much More§ Accelerometer§ Audio§ Primitives§ Particle Systems§ Parallax§ Effects§ Physics
Let’s BuildA Game!
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
Get Started Todayxamarin.com
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.
Thank you.
JamesMontemagnoDeveloper Evangelist, Xamarin
[email protected] motzcod.es @JamesMontemagno
Questions?16:20 -‐ 17:20 Right here!