O'Reilly logo

Cocos2D Game Development Essentials by Ben Trengrove

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 5. User Interaction and Interface

What good is a game when the user can't actually interact with it! User interaction is a key feature of a game and is often overlooked. In this chapter, you will learn how to take input from a wide variety of methods.

In this chapter, you will learn how to:

  • Detect and respond to the user touching the screen
  • Add buttons to your scene in code
  • Take input from the user with form elements such as CCTextField and CCSlider
  • Create a scrollable table view using CCTableView

Detecting touches

In Cocos2D, every CCNode class and subclass can receive and handle touches. You just have to enable one property. This property is the userInteractionEnabled property and is written as follows:

- (id)init { if (self = [super init]) ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required