O'Reilly logo

Cocos2d-x Game Development Essentials by Gareth Jones, Arutosh Gurung, Frahaan Hussain

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 7. Moving the Space Pod Using Touch

This chapter will cover how to set up touch events within our game. So far, the game has had no user interaction from a gameplay perspective. This chapter will rectify this by adding touch controls in order to move the space pod and avoid the asteroids.

The topics that will be covered in this chapter are as follows:

  • Implementing touch
    • Single-touch
    • Multi-touch
  • Using touch locations
  • Moving the spaceship when touching the screen

There are two main routes to detect touch provided by Cocos2d-x:

  • Single-touch: This method detects a single-touch event at any given time, which is what will be implemented in the game as it is sufficient for most gaming circumstances
  • Multi-touch: This method provides the functionality that ...

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