Created
September 24, 2012 21:38
-
-
Save C4Code/3778566 to your computer and use it in GitHub Desktop.
Dragging + Layering
This file contains hidden or 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.m | |
// gettingThingsOnScreen | |
// | |
// Created by moi on 12-09-23. | |
// Copyright (c) 2012 moi. All rights reserved. | |
// | |
#import "C4WorkSpace.h" | |
@interface C4WorkSpace () | |
-(void)adjustZPos:(NSNotification *)aNotification; | |
@end | |
@implementation C4WorkSpace { | |
C4Shape *s1, *s2; | |
} | |
-(void)setup { | |
s1 = [C4Shape rect:CGRectMake(0, 0, 100, 100)]; | |
s2 = [C4Shape rect:s1.frame]; | |
s2.fillColor = C4GREY; | |
[s1 addGesture:PAN name:@"pan" action:@"move:"]; | |
[s2 addGesture:PAN name:@"pan" action:@"move:"]; | |
[self.canvas addShape:s1]; | |
[self.canvas addShape:s2]; | |
[self listenFor:@"touchesBegan" fromObject:s1 andRunMethod:@"adjustZPos:"]; | |
[self listenFor:@"touchesBegan" fromObject:s2 andRunMethod:@"adjustZPos:"]; | |
} | |
-(void)adjustZPos:(NSNotification *)aNotification { | |
C4Shape *s = (C4Shape *)[aNotification object]; | |
if(s == s1) { | |
s2.zPosition = 0; | |
s1.zPosition = 1; | |
} | |
else if(s == s2) { | |
s1.zPosition = 0; | |
s2.zPosition = 1; | |
} | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment