Game Development Reference
In-Depth Information
In this case, you expect the node returned by getChildByTag to be an object de-
rived from CCLabelTTF , but you can never be sure, which is why adding an
NSAssert to verify the fact is helpful in finding errors before they lead to a crash.
Note that this adds two more lines of code, but in terms of performance things remain
the same. The call to NSAssert is completely removed in Release builds, and the
cast CCLabelTTF* label = (CCLabelTTF*)node; is what you've done
already, just on the same line. Essentially, both versions perform exactly the same, but
in the second case you get the benefit of being notified when you didn't get the expec-
ted CCLabelTTF object, instead of crashing with an EXC_BAD_ACCESS error.
What Else You Should Know
Because this is the “Getting Started” chapter, I think it's important to take the oppor-
tunity to introduce you to some vital but often overlooked aspects of iOS game devel-
opment. I want you to be aware of the subtle differences among various iOS devices. In
particular, available memory is often incorrectly considered because you can use only a
fraction of each device's memory safely.
I also want you to know that the iOS Simulator is a great tool for testing your game,
but it can't be used to assess performance, memory usage, and other features. The Sim-
ulator experience can differ greatly from running your game on an actual iOS device.
Don't fall into the trap of making assessments based on your game's behavior in the
iOS Simulator. Only the device counts.
The iOS Devices
When you develop for iOS devices, you need to take into account their differences.
Most independent and hobby game developers can't afford to purchase each slightly
different iOS device—of which there are eight at the time of this writing, with roughly
two more to be released each year. At the very least, you need to understand that there
are important differences.
You might want to refer to Apple's spec sheets to familiarize yourself with the iOS
device technical specifications. The following links list the iPhone, iPod touch, and
iPad device specifications, respectively:
Search Nedrilad ::

Custom Search