Skip to content

Instantly share code, notes, and snippets.

@C4Examples
Created August 2, 2012 06:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save C4Examples/3234284 to your computer and use it in GitHub Desktop.
Save C4Examples/3234284 to your computer and use it in GitHub Desktop.
C4Image image property
//
// C4Workspace.h
// Examples
//
// Created by Travis Kirton
//
#import "C4Workspace.h"
@implementation C4WorkSpace {
//define 2 invisible images
C4Image *i1, *i2;
//define a visible image
C4Image *visibleImage;
BOOL isFirstImage;
}
-(void)setup {
//create two invisible images
i1 = [C4Image imageNamed:@"C4Sky.png"];
i2 = [C4Image imageNamed:@"C4Table.png"];
//create the visible image from the first invisible image
visibleImage = [C4Image imageWithImage:i1];
isFirstImage = YES;
//position it and add it to the canvas
visibleImage.center = self.canvas.center;
[self.canvas addImage:visibleImage];
}
-(void)touchesBegan {
//toggle the contents of the visible image
if(isFirstImage == YES) {
visibleImage.image = i2;
isFirstImage = NO;
} else {
visibleImage.image = i1;
isFirstImage = YES;
}
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment