Skip to content

Instantly share code, notes, and snippets.

@C4Tutorials
Created April 8, 2013 19:57
Show Gist options
  • Save C4Tutorials/5339967 to your computer and use it in GitHub Desktop.
Save C4Tutorials/5339967 to your computer and use it in GitHub Desktop.
The canvas listening to a specific object.
//
// C4WorkSpace.m
// Notification Tutorial
//
// Created by Travis Kirton.
//
#import "C4WorkSpace.h"
@implementation C4WorkSpace
-(void)setup {
C4Shape *s = [C4Shape ellipse:CGRectMake(0, 0, 192, 192)];
s.center = self.canvas.center;
[self.canvas addShape:s];
[self listenFor:@"touchesBegan" fromObject:s andRunMethod:@"react"];
}
-(void)react {
self.canvas.backgroundColor = [UIColor colorWithWhite:[C4Math randomInt:100]/100.0f alpha:1.0f];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment