Skip to content

Instantly share code, notes, and snippets.

@drart
Created June 3, 2013 00:09
Show Gist options
  • Save drart/5695449 to your computer and use it in GitHub Desktop.
Save drart/5695449 to your computer and use it in GitHub Desktop.
Image swapping example improved.
//
// C4Workspace.h
// Examples
//
// Created by Travis Kirton
// Modified by Adam Tindale
//
#import "C4Workspace.h"
@implementation C4WorkSpace {
//define 2 invisible images
C4Image *i1, *i2;
//define a pointer to a selected image
C4Image *visibleImage;
}
-(void)setup {
i1 = [C4Image imageNamed:@"C4Sky.png"];
i2 = [C4Image imageNamed:@"C4Table.png"];
visibleImage = i1;
i1.center = i2.center = self.canvas.center;
[self.canvas addImage:visibleImage];
}
-(void)touchesBegan {
[self.canvas removeObject:visibleImage];
if (visibleImage == i1)
visibleImage = i2;
else
visibleImage = i1;
[self.canvas addImage:visibleImage];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment