Skip to content

Instantly share code, notes, and snippets.

@C4Code
Created January 20, 2013 23:37
Show Gist options
  • Save C4Code/4582594 to your computer and use it in GitHub Desktop.
Save C4Code/4582594 to your computer and use it in GitHub Desktop.
More complex example of using the perspectiveDistance property
//
// C4WorkSpace.m
// test
//
// Created by moi on 13-01-20.
// Copyright (c) 2013 moi. All rights reserved.
//
#import "C4WorkSpace.h"
@implementation C4WorkSpace {
C4Shape *s1, *s2, *centerLine;
}
//the numbers are tweaked for the final state
-(void)setup {
[self createShapes];
s1.animationDuration = 0.25f;
s1.anchorPoint = CGPointMake(0,0.5);
s1.perspectiveDistance = 200;
s1.rotationY = QUARTER_PI;
s2.animationDuration = 0.25f;
s2.anchorPoint = CGPointMake(0,0.5);
s2.perspectiveDistance = 200;
s2.rotationY = QUARTER_PI+HALF_PI;
}
-(void)createShapes {
CGRect frame = CGRectMake(self.canvas.center.x - 116, self.canvas.center.y - 50, 100, 100);
s1 = [C4Shape rect:frame];
frame.origin.x += 233;
s2 = [C4Shape rect:frame];
[self.canvas addShape:s1];
[self.canvas addShape:s2];
CGPoint linePoints[2] ={
CGPointMake(self.canvas.center.x+0.5, 0),
CGPointMake(self.canvas.center.x+0.5, self.canvas.height)
};
centerLine = [C4Shape line:linePoints];
centerLine.lineWidth = 1.0f;
[self.canvas addShape:centerLine];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment