Skip to content

Instantly share code, notes, and snippets.

@C4Code
Created July 23, 2012 23:03
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 C4Code/3166813 to your computer and use it in GitHub Desktop.
Save C4Code/3166813 to your computer and use it in GitHub Desktop.
Walkthrough code for TEI2013 Submission
//
// C4WorkSpace.m
// TEI2013
//
// Created by Travis Kirton on 12-07-23.
// Copyright (c) 2012 POSTFL. All rights reserved.
//
#import "C4WorkSpace.h"
@interface C4WorkSpace ()
-(void)animateMovieSize;
-(void)animateMovieRotation;
-(void)revealMask;
-(void)hideMask;
@end
@implementation C4WorkSpace {
C4Movie *movieObject;
C4Shape *maskShape;
}
-(void)setup {
movieObject = [C4Movie movieNamed:@"inception.mov"];
movieObject.shouldAutoplay = YES;
movieObject.loops = YES;
movieObject.center = self.canvas.center;
maskShape = [C4Shape rect:movieObject.bounds];
maskShape.lineWidth = 0.0f;
C4Font *maskFont = [C4Font fontWithName:@"HelveticaNeue-CondensedBlack" size:180.0f];
C4Shape *maskText = [C4Shape shapeFromString:@"TEI2013" withFont:maskFont];
[maskShape addShape:maskText];
maskText.center = CGPointMake(maskShape.width / 2.0f, maskShape.height / 2.0f);
movieObject.mask = maskShape;
[self.canvas addMovie:movieObject];
[movieObject addGesture:PAN name:@"panGesture" action:@"move:"];
[self addGesture:SWIPELEFT name:@"swipeLeftGesture" action:@"revealMask"];
[self addGesture:SWIPERIGHT name:@"swipeRightGesture" action:@"hideMask"];
[self addGesture:TAP name:@"tapGesture" action:@"animateMovieSize"];
[self addGesture:TAP name:@"twoFingerTapGesture" action:@"animateMovieRotation"];
[self numberOfTouchesRequired:2 forGesture:@"twoFingerTapGesture"];
}
-(void)animateMovieSize {
movieObject.animationDuration = 1.0f;
movieObject.animationOptions = AUTOREVERSE;
movieObject.width = movieObject.width/2.0f;
movieObject.center = self.canvas.center;
}
-(void)revealMask {
maskShape.animationDuration = 1.0f;
maskShape.fillColor = [UIColor whiteColor];
}
-(void)hideMask {
maskShape.animationDuration = 1.0f;
maskShape.fillColor = [UIColor clearColor];
}
-(void)animateMovieRotation {
movieObject.animationOptions = DEFAULT;
movieObject.animationDuration = 1.0f;
movieObject.rotation += TWO_PI;
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment