Created
September 23, 2012 22:21
-
-
Save C4Tutorials/3773248 to your computer and use it in GitHub Desktop.
Getting Things On Screen
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.m | |
// gettingThingsOnScreen | |
// | |
// Created by moi on 12-09-23. | |
// Copyright (c) 2012 moi. All rights reserved. | |
// | |
#import "C4WorkSpace.h" | |
@implementation C4WorkSpace | |
-(void)setup { | |
CGFloat gap = 10.0f; | |
CGFloat width = (self.canvas.width - 6*gap) / 5; | |
//make a rectangle | |
C4Shape *rect = [C4Shape rect:CGRectMake(0, 0, width, width * 0.5)]; | |
//make an image | |
C4Image *image = [C4Image imageNamed:@"C4Sky.png"]; | |
//make a movie | |
C4Movie *movie = [C4Movie movieNamed:@"inception.mov"]; | |
//make a gl object | |
C4GL *gl = [C4GL glWithFrame:CGRectMake(0, 0, width, width *.66)]; | |
//make a camera | |
C4Camera *camera = [C4Camera cameraWithFrame:CGRectMake(0, 0, width, width)]; | |
//make a font, and then a label with some text | |
C4Font *font = [C4Font fontWithName:@"Futura-Medium" size:24.0f]; | |
C4Label *label = [C4Label labelWithText:@"Getting Things On Screen" font:font]; | |
//update a few properties | |
image.width = width; | |
movie.width = width; | |
[camera initCapture]; | |
movie.shouldAutoplay = YES; | |
//position everything | |
CGPoint currentCenter = CGPointMake(gap+width/2,self.canvas.center.y); | |
rect.center = currentCenter; | |
currentCenter.x += width + gap; | |
image.center = currentCenter; | |
currentCenter.x += width + gap; | |
camera.center = currentCenter; | |
currentCenter.x += width + gap; | |
gl.center = currentCenter; | |
currentCenter.x += width + gap; | |
movie.center = currentCenter; | |
currentCenter = self.canvas.center; | |
currentCenter.y += width/2 + 10 + label.height; | |
label.center = currentCenter; | |
//add everything to the canvas | |
[self.canvas addShape:rect]; | |
[self.canvas addImage:image]; | |
[self.canvas addCamera:camera]; | |
[self.canvas addMovie:movie]; | |
[self.canvas addGL:gl]; | |
[self.canvas addLabel:label]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment