Book Image

Cocos2d Game Development Essentials

Book Image

Cocos2d Game Development Essentials

Overview of this book

Table of Contents (13 chapters)

Presenting data in a table with CCTableView


The CCTableView node is the Cocos2d equivalent of UITableView. It can be used in your game whenever you need to present a scrollable list of items such as a high score table. It works a lot like UITableView, where a data source provides the instance of the cell to show on screen. In order to learn how to use CCTableView, you will create a simple mocked up high score screen. The scores will be stubbed out, but could be easily switched for real data if you want to use this implementation in your game.

Start a new Xcode project and delete all the boilerplate code from the HelloWorldScene.m file, so you are left with a blank scene. You might want to leave the back button so that you can navigate back to the main menu.

Creating a CCTableView data source

The first step is to create the data source for your table view. This could be done in a separate class, but to keep things simple in this tutorial, your scene will also be the data source. Following are...