Game Development Reference
In-Depth Information
I determined the value 6 for _enlargeTextureRadius merely by increasing it until
no parts of the texture were noticeably cut off. Notice that you can set the value much
higher, though with increasing values the texture may become distorted, the player be-
comes smaller, and the player will eventually start to draw parts of other nearby images
within the Sprite Sheet. Therefore, you should opt to use the lowest possible value that
draws the texture without glitches.
The player is still too small compared to its overall collision shape. Therefore,
SoftBodyDrawNode allows you to draw the player larger than its body positions indic-
ate, by moving the actual vertex positions away from the center. This will stretch the tex-
ture and has a similar effect as increasing the scale property.
Note So why not just increase the scale property? Because the
SoftBodyDrawNode does not incorporate scale, rotation, or even the sprite's
position into its drawing code. Once you start to use custom drawing code for a
sprite, it's all yours and each convenience feature Cocos2D provides no longer
works unless you re-implement it yourself.
Open GameScene.ccb , select the root node, and change the _drawPhysicsShapes
property back to 1 . Then run the game to observe the player's collision shape. You'll no-
tice the player will be drawn noticeably smaller than the collision shapes. This is true now
more so than before, because you already increased the radius for the texture coordinates,
which has the effect of decreasing the player's size. See Figure 10-16 for the current state.
Search WWH ::




Custom Search