I created a sample game that follows a 2D side scrolling race car on a race track using the camera.
In the update method I just move the camera to the location where the vehicle is, at a certain distance away from the vehicle in the Z direction, and have the camera look at the vehicle/character’s position.
The sample source code actually uses three cameras. The default one for UI, a second camera for the race car and race track ground, and a third camera for the background.
You can download the source for free, but I’m currently only giving it out to people that join my email list.
In full disclosure, if you join my email list, I will send you free cocos2d-x cocos2d-x development resources, tips, and product offers of things that I sell relating to making games with Cocos2d-x.
Here is a video of what the source code does: