Game Development Reference
In-Depth Information
Listing 7-8 . Declaring the show method
#import "CCNode.h"
@interface MainMenuButtons : CCNode
-(void) show;
@end
And, of course, add the corresponding show method ( Listing 7-9 ) to the MainMenuBut-
tons.m file.
Listing 7-9 . The show implementation
-(void) show
{
self.visible = YES;
}
I've added a suggestion as a comment about what you could be doing when the Set-
tingsLayer closes, besides removing the settings layer and showing the buttons. What
if both CCB classes needed to play a Timeline animation of their own, one that animates
the SettingsLayer out and the MainMenuButtons in?
Whatever that may look like, they would both need to run the animation using their own
animationManager instances, and the SettingsLayer would have to respond to a
Callbacks selector in order to properly remove itself for good.
Of course, playing an animation is just one of many reasons why a class might want to re-
spond to an event in its own way, rather than having it dictated by some other class. If you
follow the principle of separation of concerns, you will find it a lot easier to re-use classes
and individual CCB files, within the same project and even in future projects.
The result of your work can be seen in Figure 7-13 . Notice that the settings background
image is transparent—that's because the image has been designed to be slightly transpar-
ent. You could as well use a fully opaque background and then lower the opacity of the
sprite. Same difference.
Search WWH ::




Custom Search