Skip to content

Instantly share code, notes, and snippets.

@is8r
Created June 27, 2014 13:42
Show Gist options
  • Save is8r/81fae24abb4510fa6142 to your computer and use it in GitHub Desktop.
Save is8r/81fae24abb4510fa6142 to your computer and use it in GitHub Desktop.
-(id) init
{
if( (self=[super init])) {
//
CGSize stage = [[CCDirector sharedDirector] winSize];
//btn - ToggleBtn
CCSpriteBtn *b2 = [[CCSpriteBtn alloc] initToggleWithFiles:@"b_border80.png" toggle:@"b_border80_on.png"];
b2.Id = 2;
b2.position = ccp( b2.contentSize.width/2 , stage.height - b2.contentSize.height/2 - 98 );
[b2 addListnerRelease:self selector:@selector(onPress:)];
[b2 addLabel:@"ToggleBtn"];
[self addChild: b2];
}
return self;
}
-(void) onPress:(CCSpriteBtn*)sender
{
switch (sender.Id)
{
case 2:
NSLog(@"toggle:%i", sender.isToggle);
break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment