Game Development Reference
In-Depth Information
Debug Console, go to View
Debug Area
Activate Console to show it. The message
in the Debug Console should read as follows:
2014-06-05 20:00:01.014 LearnSpriteBuilder[49183:60b]
GameScene did load
Implementing the Button Selector
Now you know that the custom class is loaded by the reader. All that's left to do is imple-
ment the button selector. Create the button method, and name it exactly as you entered it
on the Code Connections Selector field for the button. Your GameScene implementation
should now have this additional method:
-(void) exitButtonPressed
{
NSLog(@"Get me outa here!");
}
Tip You can optionally set up the selectors for Button, Text Field, and Slider
nodes so that they receive the sending node as a parameter. To do so, you would
simply append a colon to the selector name—for instance, exitBut-
tonPressed would become exitButtonPressed: in the Selector field
on the Code Connections tab for the node. Then update the method signature
accordingly, for brevity, in a single line:
-(void) exitButtonPressed:(CCControl*)sender
{ NSLog(@"Sender: %@", sender); }
Instead of CCControl* , you can use the sending node's specific class—for
instance, CCButton*. CCControl is the super class which Button, Text
Field, and Slider nodes inherit from and is guaranteed to work for all of them.
Run the app, tap the button, and you'll see a message like this in the Debug Console:
2014-06-05 20:24:02-959 LearnSpriteBuilder[49437:60b] Get
me outa here!
Search WWH ::




Custom Search