Book Image

Sparrow iOS Game Framework Beginner's Guide

By : Johannes Stein
Book Image

Sparrow iOS Game Framework Beginner's Guide

By: Johannes Stein

Overview of this book

Table of Contents (20 chapters)
Sparrow iOS Game Framework Beginner's Guide
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Afterword
Index

Adding buttons to the screen


Now that we have hit point bars on the screen, let's add some things that the user can actually interact with.

Pausing and resuming the game

The first thing we are going to add is the ability to pause and resume the game at will. This is actually quite important, especially for mobile action games. If a call comes on the mobile device (iPhone) and we don't have a pause functionality, the player might get frustrated by not being able to pause the game and lose their progress or winning streak.

Before we get into implementing these buttons, let's download the necessary graphics for this chapter which are available at https://github.com/freezedev/pirategame-assets/releases/download/0.7/Graphics_07.zip. Copy the contents of the extracted file into the project.

Let's think of what we need to do when pausing the game:

  • Display a button to pause the game

  • Display a button to resume the game

  • Stop all current tweens when the player clicks on the pause button

  • Resume all current...