Created
August 2, 2012 06:06
-
-
Save C4Examples/3234284 to your computer and use it in GitHub Desktop.
C4Image image property
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// 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