Random Notes to Self on Cocos2d Basics

  • Under the Cocos2d coordinate system (0,0) is at the bottom left, like in Core Graphics (vs Flash & standard UIKit, Animation with the upper left)
  • Cocos2d offers convertToGL and convertToUI methods to switch between UIKit and Cocos2d coordinate systems
  • In Cocos2d each new screen is a Scene. Scenes have Layers, Layers have Sprites
  • iPad screen size 1024×768, iPhone 320×480 (460 if you count the status bar). Note the distinction between pixels & points used in iOS dev.
  • Layers act kind of like layers in an .fla, with multiple Sprites per Layer (not the greatest practice for .fla). In a way, each layer is a bit like a Display List of its own
  • Layers have an addChild method with one of the input params being “z”, which works exactly like the z-index in CSS concept or the Display List’s depth order in AS3
  • ‘#import “MyLayerClass.m”‘ causes “Apple Mach-O Linker (Id) Error”. Just fix the import statement to point to a “.h” file instead of “.m”
  • a fun way to get the dreaded EXC_BAD_ACCESS error is to forget to include a “return self;” statement in an -(id)init method for a Layer or Scene class
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s