Cocos2d-x Programming

I’m fairly new to Cocos2d-x programming. This forced me spend some time pondering things that haven’t seemed quite as easy as I would have expected. Therefore, I thought I’d share what I’ve learned in a series of posts.

There are also a number of very valuable posts in Chinese which I hope to bring to English. I need to scout these out and talk to their authors first but hopefully they will willing to have me translate them.

I’ve got code for most of the following topics which I will post as time permits. If there is a particular topic that interests you, or if a post needs clarification or correction, more let me know and I’ll get to that sooner

A few things to understand about a Cocos2d-x program:

  • Cocos2d-x Scene Graph – The structure of a Cocos2d-x program,
  • Cocos2d-x Interface with Android – How is Cocos2d-x started,
  • Cocos2d-x Talking to Android – How to use Android services not coded in t Cocos2d-x,
  • Cocos2d-x AppDelegate – Starting up the Cocos2d-x program,
  • Cocos2d-x Talking to Linux Kernel – Socket programming,
  • Cocos2d-x Scene Hierarchy – Which objects can be used as scene root.

Some UI (User Interface) stuff:

  • Cocos2d-x UITextBMFont – Display a fast bit-map font (see below on how to create bit-mapped fonts for your own program,
  • Cocos2d-x UIWebView – Display a webpage within your scenes,
  • Cocos2d-x UIVideoPlayer – Display a video within a scene,
  • Cocos2d-x UITextField
  • Cocos2d-x UITextAtlas
  • Cocos2d-x UIText
  • Cocos2d-x UISlider – Add a slider control to your form, with graduations,
  • Cocos2d-x UIScrollView
  • Cocos2d-x UIRichText – Display font text with attributes,
  • Cocos2d-x UILoadingBar – Display a progress bar,
  • Cocos2d-x UIListView – Display a drop-down type list,
  • Cocos2d-x UILayout
  • Cocos2d-x UIImageView – Display an image,
  • Cocos2d-x UIEditBox – Get text input from user,
  • Cocos2d-x UICheckBox – Setting up a checkbox.

Scheduling Functions:

  • Cocos2d-x Schedule Update – Asynchronous function calls to off-load GUI task and to use timing services,
  • Cocos2d-x Schedule Update – Calls the update function every frame,
  • Cocos2d-x Schedule a function once – One shot function call,
  • Cocos2d-x Schedule a function a set number of times with a set time gap between calls with an initial delay,
  • Cocos2d-x Schedule a function forever – With a set time gap between calls,
  • Cocos2d-x Schedule a custom function – To run every frame,
  • Cocos2d-x Unscheduling – Scheduled functions can be stopped very easily.

Miscellaneous Stuff:

  • Cocos2d-x Hello World – A better starting place,
  • Cocos2d-x PLIST – Reading of PLIST file from Resources, and Reading/Writing from/to Device memory,
  • Cocos2d-x Audio services both for effects and background music,
  • Cocos2d-x Accelerometer Input – Detect when the user has interacted with their device by tilting it,
  • Cocos2d-x Keyboard Input – detect when the user has interacted with their device using a keyboard,
  • Cocos2d-x Mouse Input – Detect when the user has interacted with their device using a mouse,
  • Cocos2d-x Single Touch Input – detect when the user has interacted with their device using touch primarily for mobile devices using a single finger,
  • Cocos2d-x Multi Touch Input – Detect when the user has interacted with their device using touch primarily for mobile devices using a multiple fingers,
  • Cocos2d-x Open URL – Opening up a web page from your Android app,
  • Cocos2d-x Clipping Node – Using a stencil object,
  • Cocos2d-x PageView – Scrolling pages,
  • Cocos2d-x Scene Transitions – The functions: pushScene, popScene, popToRootScene, popToSceneStackLevel,
  • Cocos2d-x Scene Transitions – Doing a scene transition with a transition effect, both push and pop.


Cocos2d-x Programming

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top