Skip to content

Instantly share code, notes, and snippets.

@C4Examples
Created February 21, 2013 22:07
Show Gist options
  • Save C4Examples/5008783 to your computer and use it in GitHub Desktop.
Save C4Examples/5008783 to your computer and use it in GitHub Desktop.
C4Control removeFromSuperview:
//
// C4WorkSpace.m
// Examples
//
// Created by Greg Debicki.
//
#import "C4WorkSpace.h"
@implementation C4WorkSpace {
C4Shape *s1, *s2, *s3, *s4;
}
-(void)setup {
[self setupShapes];
}
-(void)s1remove {
//Here's the bit that removes the shape from the canvas
[s1 removeFromSuperview];
[self runMethod:@"s1add" afterDelay:1.0f];
}
-(void)s1add {
[self.canvas addShape:s1];
}
-(void)s2remove {
[s2 removeFromSuperview];
[self runMethod:@"s2add" afterDelay:1.0f];
}
-(void)s2add {
[self.canvas addShape:s2];
}
-(void)s3remove {
[s3 removeFromSuperview];
[self runMethod:@"s3add" afterDelay:1.0f];
}
-(void)s3add {
[self.canvas addShape:s3];
}
-(void)s4remove {
[s4 removeFromSuperview];
[self runMethod:@"s4add" afterDelay:1.0f];
}
-(void)s4add {
[self.canvas addShape:s4];
}
-(void) setupShapes {
CGRect rect = CGRectMake(0, 0, 100, 100);
s1 = [C4Shape rect:rect];
s2 = [C4Shape rect:rect];
s3 = [C4Shape rect:rect];
s4 = [C4Shape rect:rect];
CGPoint centerPoint = self.canvas.center;
centerPoint.x -= 75;
centerPoint.y -= 75;
s1.center = centerPoint;
centerPoint.x += 150;
s2.center = centerPoint;
centerPoint.y += 150;
s3.center = centerPoint;
centerPoint.x -= 150;
s4.center = centerPoint;
[self.canvas addObjects:@[s1,s2,s3,s4]];
[self listenFor:@"touchesBegan" fromObject:s1 andRunMethod:@"s1remove"];
[self listenFor:@"touchesBegan" fromObject:s2 andRunMethod:@"s2remove"];
[self listenFor:@"touchesBegan" fromObject:s3 andRunMethod:@"s3remove"];
[self listenFor:@"touchesBegan" fromObject:s4 andRunMethod:@"s4remove"];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment