CoronaView class is a subclass of the
GLKView class. If you're using the Xcode Storyboard / Interface Builder, you need to override
CoronaView. This allows you to create a full-screen CoronaCards app within a Single View Application project.
CoronaViewController is a subclass of the
GLKViewController class. If you're building a multi-view app, you can programmatically make the
CoronaView a child view. Typically, you instantiate a
CoronaViewController when it's not the root controller, for example when the
CoronaViewController is a child of another controller.
When creating a
CoronaViewController as a child controller, you must override the
viewDidLoad method of the parent controller via the following steps:
CoronaViewController and ensure that it exists for the lifetime of the
CoronaView. In the example below,
coronaController is a property of the parent controller that implicitly retains upon assignment.
CoronaViewController as a child controller of the parent. This ensures that notifications from the parent controller are propagated to the
CoronaViewController, for example when the parent view appears or disappears.
CoronaView. When this view is loaded programmatically, it defaults to the size of the screen.
CoronaView as a child view of the parent controller's view.
main.lua file to run. In the example below, we run the
main.lua that is present at the root of the
.app bundle. However, you can choose an arbitrary
main.lua file by calling
// This method belongs to the parent UIViewController
// Do any additional setup after loading the view, typically from a nib.
self.coronaController = [[[CoronaViewController alloc] init] autorelease]; // (Step 1)
[self addChildViewController:self.coronaController]; // (Step 2)
CoronaView *coronaView = (CoronaView *)self.coronaController.view;
// Same size as parent view
coronaView.frame = self.view.frame; // (Step 3)
[self.view addSubview:coronaView]; // (Step 4)
[coronaView run]; // (Step 5)
In iOS, a
CoronaView can have a transparent background. To accomplish this, two things are required:
- Instruct iOS to enable transparency in the
coronaView.backgroundColor = [UIColor clearColor];
coronaView.opaque = NO;
- Tell Corona to utilize an transparent OpenGL surface by setting the
alpha key to
display.setDefault( "background", 0, 0, 0, 0 )