BalloonRide is a sample application demonstrating the basic usage of cocos2d-x.



The game has three scenes that are also layers – Start, Main and End. It has a Start, Restart and Exit buttons and a label showing the player’ s score.

The game has a scrolling background which is composed of three sprites with the same image. The background is scrolling from right to left. The sprites are placed side by side from left to right with the last one off the screen. When the first sprite is off the screen to the left, it is moved off the screen to the right. There was one problem with this procedure. After moving the first sprite from the left side back to the right, a black line appeared between third and first sprite. Maybe it’ s because the third part was added later and was on top of the first. As a workaround, when a background part is moved from left back to the right it is detached from the layer and added again which puts that part on top of the others and removes the black line.

Cocos2d has its own methods for controlling accelerometer and scheduling and it’ s generally a good idea to use them instead of bada equivalents. One thing to note is that if you want a direct access to member variables of a particular object from inside the scheduler callback, you need to add this object to the scheduler’ s scope, e.g. layer~~>addChild, or you’ ll be accessing an empty object.
Press the ‘Start’ label to start the game.
Tilt the device to move the balloon.
Avoid hitting birds or planes for as long as possible.
The longer you avoid hitting, the more points you get.
You can restart the game after being hit.
You can exit the game by pressing the button in the lower right corner of the screen.
HVGA device
Cocos2d-x framework~~ - -


Sign up for our newsletter to keep up with the latest developments, releases and updates for Cocos2d-x.