Game Development Reference
In-Depth Information
quently cocos2d should update the screen. That's why the parameter is 1 divided by 60,
because that results in 0.0167 seconds. If your app takes longer than this to update the
game logic and render the screen, the framerate will drop below 60 FPS. It's your re-
sponsibility to keep the game running at a high framerate. Don't worry, I explain tech-
niques to improve performance throughout the topic.
In some cases, locking the framerate to 30 frames per second may be preferable. Doing
so may be helpful in very complex games where you know you can't achieve 60 FPS
consistently, and the framerate fluctuates anywhere between 30 and 60 FPS. In such a
case, it's often better to lock the framerate to the lowest common denominator, because
a lower but steady framerate is perceived as smoother by players than a framerate that
tends to fluctuate abruptly, even when the actual average framerate may be higher. Hu-
man perception is a tricky thing.
Note You can't render more than 60 FPS on iOS devices. The device's display
is locked to update at 60 frames per second (Hz), and forcing cocos2d to render
more frames than 60 per second is, at best, not doing anything. At worst, it can
actually slow down your framerate. Stick with the animationInter-
val of 1.0/60 if you want to run cocos2d at the fastest possible rate.
The HelloWorldLayer class is where cocos2d code does its magic to display the
“Hello World” label. Before I get into that, you should understand that cocos2d uses a
hierarchy of CCNode objects to determine what's displayed where.
The base class of all nodes is the CCNode class, which contains a position but has no
visual representation. It's the parent class for all other node classes, including the two
most fundamental ones: CCScene and CCLayer .
CCScene is an abstract concept and does nothing more than allow proper placement
of objects in the scene according to their piXEl coordinates. A CCScene node is
thus always used as the parent object for every cocos2d scene hierarchy. You can only
have one running scene at any time.
Search Nedrilad ::

Custom Search