Skip to content

Instantly share code, notes, and snippets.

@samanthamjohn
Created September 6, 2012 23:08
Show Gist options
  • Save samanthamjohn/3661121 to your computer and use it in GitHub Desktop.
Save samanthamjohn/3661121 to your computer and use it in GitHub Desktop.
Cocos2d with UIKit
- (void)revealToggle:(id)sender
{
self.sliderShown ? [self concealAnimation] : [self revealAnimationWithCallback:^(void){}];
}
- (void)revealAnimationWithCallback:(void (^) (void) )callback
{
[self.backgroundView addSubview:self.overlayView];
NSTimeInterval duration = self.toggleAnimationDuration;
[UIView animateWithDuration:duration delay:0.0f options:UIViewAnimationOptionBeginFromCurrentState|UIViewAnimationOptionAllowUserInteraction animations:^
{
CGRect oldFrame = self.slideInView.frame;
self.slideInView.frame = CGRectMake(STAGE_X, STAGE_Y, oldFrame.size.width, oldFrame.size.height);
}
completion:^(BOOL finished)
{
[[CCDirector sharedDirector] setAnimationInterval:1.0/60];
self.sliderShown = YES;
callback();
}];
}
- (void) concealAnimation
{
NSTimeInterval duration = self.toggleAnimationDuration;
[UIView animateWithDuration:duration delay:0.0f options:UIViewAnimationOptionBeginFromCurrentState|UIViewAnimationOptionAllowUserInteraction animations:^
{
CGRect oldFrame = self.slideInView.frame;
self.slideInView.frame = CGRectMake(IPAD_WIDTH + self.shadowRadius - STAGE_OVERLAP, STAGE_Y, oldFrame.size.width, oldFrame.size.height);
}
completion:^(BOOL finished)
{
[[CCDirector sharedDirector] setAnimationInterval:10.0];
self.sliderShown = NO;
}];
}
-(void) viewDidLoad
{
[[CCDirector sharedDirector] setAnimationInterval:10.0];
[[CCDirector sharedDirector] setView:stageView];
CCScene *scene = [StageLayer scene];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment