Cocos2D

wrackbaaMobile - Wireless

Dec 10, 2013 (3 years and 10 months ago)

139 views

Cocos2D  
Basics  of  Game  Development  
Why  Use  Cocos2D?  


It  is  powerful  and  does  most  of  the  work  for  
you.  
What  is  Cocos2D  Capable  Of?  
Some  Things  To  Know  About  


AppDelegate
 


RootViewController
 


CCScene
 


CCLayer
 


CCSprite
 


CCLabelTTF
 


CCTime
 


CCMenu
 –  
CCMenuItem
/
CCMenuItemFont
 


Cocos2D  has  great  documentaNon,  check  it  out!  
hQp://www.cocos2d-­‐iphone.org/
wiki
/
doku.php
/
 
CCScene
 +  
CCLayer
 


Cocos2D  has  two  classes  called  
CCScene
 and  
CCLayer
 which  derive  from  
CCNode
 


Most  objects  you  create    
will  be  added  as  a  child    
to  a  
CCLayer
 which  is    
added  as  a  child  of  a    
CCScene
.  


Think  of  each  layer  as  a  
different  view  to  work    
with.  
How  Do  We  Create  a  
CCScene
 that  
contains  a  
CCLayer
?  


In  our  .h  file  we  need  to  define  the  scene  
funcNon  and  implement  it  into  our  .m  file.  


NoNce  that  our  
HelloWorldLayer
 class  derives  
from  
CCLayer
.  
HelloWorldLayer.m
 
HelloWorldLayer.h
 
What  About  The  Rest  of  
HelloWorldLayer.m
?  


Don’t  forget  to  iniNalize  your  layer!  
 
We  also  need  
to  remember    
to  release    
everything  as    
well.  Most    
things  added  to  the  layer  will  be  released  for  
you  through  the  
dealloc
 method.  
How  Do  We  Use  Our  New  Scene?  


When  we  first  create  our  Cocos2D  project  it  
sets  everything  up  for  you  to  run  your  first  
scene.  


AppDelegate.m
 contains  a  line  of  code  that  
executes  your  first  scene.  


Before  you  can  transiNon  to  a  new  scene  you  
must  include  the  scene’s  header  file.  
How  to  install  Cocos2D  to  
Xcode
 


Download  the  latest  version  from:                          
hQp://www.cocos2d-­‐iphone.org/download
 


This  presentaNon  will  be  using  cocos2d-­‐
iphone-­‐1.0.1.tar.gz  
A`er  Downloading  


Unzip  the  file  and  open  up  Terminal  


Do  the  Following:  
This  line  in  Terminal  will  install  cocos2D  as  a  template  in  
Xcode
.  
We’re  Ready  to  Create  a  Cocos2d  Project!  


Open  up  
Xcode
 and  create  a  new  project.  
Use  our  newly  installed  Cocos2d  Template