Game Development Reference
In-Depth Information
analyzer is essentially telling you that this warning will occur, and it's just good style to
fix that problem.
This was just a simple example of the analyzer, but it can do a lot more. For instance, it
will highlight problems in code by using arrows to show the flow of execution that, if fol-
lowed, will lead to the proclaimed issue. In Figure 14-11 , an uninitialized variable
testIfTrue is sent to a method. And the method's return value assigned to
testIfTrue is declared a Dead store , meaning a variable that is not actually being
used. This indicates that either the variable is not needed or perhaps some other variable
was incorrectly used in its place.
Figure 14-11 . The analyze build uses arrows to point out the flow of logic leading to an issue
Caution The analyze build may sometimes report false positives. Code that it
deems flawed but isn't. Not every problem reported by the analyzer needs to be
fixed, but you ought to understand the reason for the report well enough to be
confident that the issue can be disregarded. It's the same as with compiler warn-
ings.
Cocos2D Framerate Stats
In addition to doing debug drawing for physics, Cocos2D can also draw profiling coun-
ters, most notably the framerate display. To enable these profiling labels, you only need to
add the line in Listing 14-8 anywhere in your codeā€”for instance, in the startScene
method in AppDelegate.m .
Listing 14-8 . Enabling profiling labels
[CCDirector sharedDirector].displayStats = YES;
Cocos2D will then draw three numbers in the lower left corner, as shown in Figure 14-12 .
Search WWH ::




Custom Search