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

Explaining macros


While we know that we can use colors with the hexadecimal notation, Sparrow provides some shorthand constants for the most commonly used colors. In the previous example, instead of using 0xffff00 for the color yellow, we used SP_YELLOW.

To generalize, macros are handy little functions that allow us to simplify the workflow when working with repetitious tasks.

Macros in Objective-C are preprocessor directives and work the same way that macros work in C and C++. Before the code is compiled, the preprocessor goes through the entire code and replaces all occurrences of the macro with the result of the macro.

While we could write each color in the hexadecimal color value notation, sometimes it does make more sense to use an RGB value. The SP_COLOR macro does exactly that, converting a RGB color into a hexadecimal color value.

In this section, we will look at what the different kinds of macros are and how to use them.

The Angles macro

Sparrow uses radians to describe the rotation of...