Game Development Reference
In-Depth Information
needs to be. It would be wasteful for texture memory usage, and there comes a point
where textures simply won't work anymore: a texture can be at most 4096x4096 pixels.
This is a hardware limitation.
Instead, you should compose such large layers out of multiple individual nodes, sprites
mostly. In order to scroll multiple sprites at once, you need to add them to the same layer,
where “layer” refers to a regular node acting as a container for these sprites.
Note If you've used Cocos2D before, you may be thinking “CCLayer”
whenever I say “layer.” But there is no special Layer node anymore. The
CCLayer class itself was never more than just a plain CCNode with the added
capability of handling user input. Now the user input functionality is in the
CCResponder class, which all node classes inherit, including CCNode . That
means you simply use a CCNode whenever you used to use a CCLayer .
Drag and drop three additional Node instances from the Node Library onto the stage. You
may want to rename these nodes in the Timeline View (double-click a node to edit its
name) like in Figure 3-10 .
Figure 3-10 . The initial layer nodes in Background1.ccb
Now select each of these three nodes, and make sure their position is set to 0, 0. Since the
goal is to derive the parallax scrolling factor based on each parallax layer's size, change
each node's “Content size” property to a value that's greater than or equal to 568x384 but
smaller than or equal to the level's size (4000x500 points). Each node's “Content size”
should be larger than the one above it in the Timeline. If that was too confusing, just copy
Search WWH ::




Custom Search