This is the code which goes with my cocos2d-x game development talk