Skip to content

Instantly share code, notes, and snippets.

@yuchi
Created October 15, 2013 08:05
Show Gist options
  • Save yuchi/6988151 to your computer and use it in GitHub Desktop.
Save yuchi/6988151 to your computer and use it in GitHub Desktop.
using CoffeeScript with Appcelerator Hyperloop
@import('Foundation/NSDictionary');
@import('Foundation/NSMutableDictionary');
@import('Foundation/NSNumber');
@import('Foundation/NSBundle');
@import('Foundation/NSString');
@import('Foundation/NSUTF8StringEncoding');
@import('Foundation/NSObject');
@import('Foundation/UILabel');
@import("Foundation/NSLog");
;
var context, controller, keyWindow, label, view;
context = EAGLContext.alloc().initWithAPI(kEAGLRenderingAPIOpenGLES2);
EAGLContext.setCurrentContext(context);
view = GLKView.alloc().initWithFrame(CGRectMake(0, 0, 0, 0), context);
view.drawableDepthFormat = GLKViewDrawableDepthFormat24;
keyWindow = UIApplication.sharedApplication().keyWindow;
keyWindow.subviews.objectAtIndex(0).removeFromSuperview();
controller = new MyGLController();
controller.view = view;
keyWindow.rootViewController = controller;
keyWindow.addSubview(view);
controller.preferredFramesPerSecond = 60;
label = new UILabel();
label.frame = CGRectMake(0, 20, 100, 40);
label.backgroundColor = UIColor.colorWithRed(180 / 255, 0, 0, 0.8);
label.textColor = UIColor.whiteColor();
label.textAlignment = NSTextAlignmentCenter;
label.setText(__('FPS: '));
keyWindow.addSubview(label);
`
@import('Foundation/NSDictionary');
@import('Foundation/NSMutableDictionary');
@import('Foundation/NSNumber');
@import('Foundation/NSBundle');
@import('Foundation/NSString');
@import('Foundation/NSUTF8StringEncoding');
@import('Foundation/NSObject');
@import('Foundation/UILabel');
@import("Foundation/NSLog");
`
context = EAGLContext.alloc().initWithAPI kEAGLRenderingAPIOpenGLES2
# you *MUST* set this or your calls to APIs will fail
EAGLContext.setCurrentContext context
# create a GL view
view = GLKView.alloc().initWithFrame CGRectMake(0,0,0,0), context
view.drawableDepthFormat = GLKViewDrawableDepthFormat24
# remove the base view
{keyWindow} = UIApplication.sharedApplication()
keyWindow.subviews.objectAtIndex(0).removeFromSuperview()
# create our custom GL controller
controller = new MyGLController()
controller.view = view
keyWindow.rootViewController = controller
keyWindow.addSubview view
# Set preferred frame per second
controller.preferredFramesPerSecond = 60
# add FPS label
label = new UILabel()
label.frame = CGRectMake 0, 20, 100, 40
label.backgroundColor = UIColor.colorWithRed 180/255, 0, 0, 0.8
label.textColor = UIColor.whiteColor()
label.textAlignment = NSTextAlignmentCenter
label.setText __ 'FPS: '
keyWindow.addSubview label
@jhaynie
Copy link

jhaynie commented Oct 15, 2013

sweet

@yuchi
Copy link
Author

yuchi commented Oct 15, 2013

Now I'll work my way through supporting http://ckknight.github.io/gorillascript/, that's the cool guy in the block (of transpilers) in my opinion :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment