Book Image

Cocos2d-x by Example: Beginner's Guide

By : Roger Engelbert
Book Image

Cocos2d-x by Example: Beginner's Guide

By: Roger Engelbert

Overview of this book

Table of Contents (19 chapters)
Cocos2d-x by Example Beginner's Guide Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Texturing our buildings with sprites


So in the test version we just coded, our game screen was divided into tiles of 128 pixels in the iPad retina screen. The width and height properties of the Block objects are based on this measurement. So a building two tiles wide and three tiles tall would have, in effect, 256 pixels in width and 384 pixels in height. A gap too would be measured this way, though its height is set to 0.

The logic we use to texture the buildings will take these tiles into account.

So let's take a look at the code to add texture to our buildings.