Game Development Reference
In-Depth Information
Note The src and dst abbreviations stand for source and destination , re-
spectively. These properties refer to OpenGL blend modes, which affect how
the colors of pixels in overlapping source and destination buffers are blended
together.
The blend modes may work differently or not at all for a gradient node, or any other node
for that matter. Changing blend modes in SpriteBuilder will also not show you the actual
results as they appear in the game—you have to test blend-mode settings in the Simulator
or on a device.
Of course, you can also use a Sprite with a background image large enough to cover the
largest screen size, either in place of the color node or instead of the P_bg sprite, in order
to create a full-screen popover with a full-screen background image.
Changing Scenes with SceneManager
At this point, the restart and exit buttons in the Pause popover menu won't do anything
yet. Except maybe crash. The restart and exit buttons simply present a new scene that will
remove the current scene, so you won't have to worry about closing the popover or any-
thing.
Since you will be presenting scenes from various places throughout the project, and typic-
ally each scene should be presented with the same transition, it makes perfect sense to
have only one method that presents a particular scene in a particular way. That way, you
won't have to skim all of your code for scene changes in order to change the type of trans-
ition used or its duration.
A class that contains only so-called “class” methods (similar to static methods in C++)
helps to extract such common, repetitive tasks that are unfitting to any existing class.
Add a new Objective-C class to the Source group in Xcode. Name the new class
SceneManager , and change the Subclass of field to NSObject , the base class of all
Objective-C classes. It doesn't need to be a CCNode because this class will not be added
as a child to the node hierarchy.
Add the code highlighted in Listing 6-10 to the SceneManager.h file.
Listing 6-10 . The SceneManager interface declares only class methods
Search WWH ::




Custom Search