Public Member Functions | Static Public Member Functions | Properties

CC3UIViewController Class Reference

An instance of CC3UIViewController manages a single CCNode (typically a CCLayer) as changes occur to the device orientation (portrait, landscape, etc). More...

#import <CC3UIViewController.h>

Inheritance diagram for CC3UIViewController:
Inheritance graph
[legend]

List of all members.

Public Member Functions

(void) - loadView
(void) - pauseAnimation
(void) - resumeAnimation
(void) - runSceneOnNode:

Static Public Member Functions

(id) + controller
(BOOL) + isPadUI
(BOOL) + isPhoneUI

Properties

CCNode * controlledNode
BOOL doesAutoRotate DEPRECATED_ATTRIBUTE
ccDeviceOrientation
defaultCCDeviceOrientation 
DEPRECATED_ATTRIBUTE
NSUInteger supportedInterfaceOrientations
EAGLView * view
CGRect viewBounds
Class viewClass
NSString * viewColorFormat
GLenum viewDepthFormat
GLuint viewPixelSamples
BOOL viewShouldUseStencilBuffer

Detailed Description

An instance of CC3UIViewController manages a single CCNode (typically a CCLayer) as changes occur to the device orientation (portrait, landscape, etc).

The loadView method of this controller will automatically create the correct type and configuration of a view suitable for use with cocos3d. You can customize the creation of this view by setting the viewClass, viewBounds, viewColorFormat, viewDepthFormat, viewShouldUseStencilBuffer, and viewPixelSamples properties prior to accessing the view property of this controller for the first time.

If the configuration provided by these properties is not sufficient, you can subclass this class and override the loadView method, or you can create the appropriate view directly, and set it into the view property of this controller.

You can use the supportedInterfaceOrientations property of this controller to configure auto-rotation of the view as the device orientation changes. Although the supportedInterfaceOrientations method is defined in iOS6, for consistency, this property can also be used in iOS versions below iOS6.


Member Function Documentation

+ (id) controller

Allocates and initializes an autoreleased instance.

+ (BOOL) isPadUI

Returns whether the UI idiom is the iPad.

Where different UI behaviour is required between iPad & iPhone idioms, it is recommended that you use UIViewController cluser classes to separate this behaviour. This class-side property can then be used to determine which concrete class to instantiate.

+ (BOOL) isPhoneUI

Returns whether the UI idiom is the iPhone.

Where different UI behaviour is required between iPad & iPhone idioms, it is recommended that you use UIViewController cluser classes to separate this behaviour. This class-side property can then be used to determine which concrete class to instantiate.

- (void) loadView

Invoked automatically the first time the view property is requested, and is currently nil.

This implementation creates a view of the type indicated by the viewClass property of this instance, with parameters defined by the viewBounds, viewColorFormat, viewDepthFormat, viewShouldUseStencilBuffer, and viewPixelSamples properties of this instance. The view will not preserve the back buffer, and will not be attached to a share group.

If your needs cannot be accommodated by configuring the viewBounds, viewColorFormat, viewDepthFormat, viewShouldUseStencilBuffer, and viewPixelSamples properties of this instance, you can either create the view externally and set the view property of this controller, or subclass this controller and override this method to create the appropriate view and set it in the view property.

- (void) pauseAnimation

Reduces cocos2d/3d animation to a minimum.

Invoke this method when you want to reliquish CPU to perform some other task, such as displaying UIKit components. To ensure a responsive UI, you should invoke this method just before displaying UIKit components, such as modal or popover controllers. Once the UIKit components have been dismissed, you can use the resumeAnimation method to restore the original animation level.

Use the resumeAnimation method to restore the original animation level.

- (void) resumeAnimation

Restores cocos2d/3d animation to its original operating level, after having been temporarily reduced by a prior invocation of the pauseAnimation method.

- (void) runSceneOnNode: (CCNode *)  aNode

This is a convenience method designed to change the displayed cocos2d scene, and keep the CCNode being controlled by this controller (typically an instance of CCLayer) synchronized with the scene being run by the shared CCDirector.

This method sets the controlledNode property of this controller to the specified node, wraps the specified node in a CCScene, if it is not already a CCScene, and runs the new scene by invoking either replaceScene: or runWithScene: on the shared CCDirector, depending on whether the director is already running a scene.


Property Documentation

- (CCNode*) controlledNode [read, write, retain]

The CCNode that is being controlled by this controller.

This is typically an instance of CCLayer.

The application should keep this property synchronized with changes in the running scene of the shared CCDirector. The convenience method runSceneOnNode: can be used to enable this.

- (BOOL doesAutoRotate) DEPRECATED_ATTRIBUTE [read, write, assign]
Deprecated:
Use the supportedInterfaceOrientations property to define the allowed orientations.
- (ccDeviceOrientation defaultCCDeviceOrientation) DEPRECATED_ATTRIBUTE [read, write, assign]
Deprecated:
Use the supportedInterfaceOrientations property to define the allowed orientations.
- (NSUInteger) supportedInterfaceOrientations [read, write, assign]

The user interface orientations allowed by this controller.

You set this property to indicate which user interface orientations are supported by this controller.

To indicate more than one allowed orientation, the value of this property can be set to a bitwise-OR combination of UIInterfaceOrientationMask values. If the controller supports all orientations, the value of this property can be set to the special value UIInterfaceOrientationMaskAll.

The initial value of this property is UIInterfaceOrientationMaskLandscape, indicating that the controller supports both landscape orientations, but neither portrait orientation.

- (EAGLView*) view [read, write, retain]

The view of a CC3UIViewController must be of type EAGLView.

- (CGRect) viewBounds [read, write, assign]

Indicates the bounds of the view.

This property is used by the loadView method as it creates the view, when the view property is first accessed and the view property has not already been established.

The initial value of this property is the bounds of the UIScreen mainScreen property. You can set this property prior to referencing the view property of this controller in order to have the view created with different bounds.

To have effect, this property must be set before the view property is first accessed.

Once the view property has been established, reading this property returns the bounds property of the view itself. Prior to the view being established, reading this property returns the value to which it has been set. The initial value of this property is the bounds of the UIScreen mainScreen property.

- (Class) viewClass [read, assign]

Indicates the class of the view.

This property is used by the loadView method as it creates the view, when the view property is first accessed and the view property has not already been established.

The initial value of this property is CC3EAGLView. You can change the value returned by this property by creating a subclass and overriding the property accesser method.

Once the view property has been established, reading this property returns the class property of the view itself. Prior to the view being established, reading this property returns CC3EAGLView, or the value overridden by a subclass.

- (NSString*) viewColorFormat [read, write, retain]

Indicates the pixel color format of the view.

This property is used by the loadView method as it creates the view, when the view property is first accessed and the view property has not already been established.

The initial value is kEAGLColorFormatRGBA8. You can set this property prior to referencing the view property of this controller in order to have the view created with a different color format.

Valid values for this property are kEAGLColorFormatRGBA8 and kEAGLColorFormatRGB565.

The value kEAGLColorFormatRGBA8 is required if models and textures will display transparency or fading. You can set this property to kEAGLColorFormatRGB565 to save display memory if you do not require any transparency or fading.

To have effect, this property must be set before the view property is first accessed.

Once the view property has been established, reading this property returns the pixelFormat property of the view itself. Prior to the view being established, reading this property returns the value to which it has been set. The initial value of this property is kEAGLColorFormatRGBA8.

- (GLenum) viewDepthFormat [read, write, assign]

Indicates the depth format of the view.

This property is used by the loadView method as it creates the view, when the view property is first accessed and the view property has not already been established.

The initial value is GL_DEPTH_COMPONENT16_OES. You can set this property prior to referencing the view property of this controller in order to have the view created with a different depth format.

Valid values for this property are GL_ZERO, GL_DEPTH_COMPONENT16_OES, GL_DEPTH_COMPONENT24_OES, or GL_DEPTH24_STENCIL8_OES.

The value GL_DEPTH_COMPONENT24_OES provides higher fidelity in depth testing than GL_DEPTH_COMPONENT16_OES. The value GL_DEPTH24_STENCIL8_OES is required if shadow volumes, or other types of stencilling will be used in your 3D scene. The value GL_ZERO will turn off all depth testing.

As a convenience, if you require a stencil buffer, consider setting the shouldUseStencilBuffer property instead of setting the value of this property.

To have effect, this property must be set before the view property is first accessed.

Once the view property has been established, reading this property returns the depthFormat property of the view itself. Prior to the view being established, reading this property returns the value to which it has been set. The initial value of this property is GL_DEPTH_COMPONENT16_OES.

- (GLuint) viewPixelSamples [read, write, assign]

Indicates the number of OpenGL ES rendering samples to be used for each pixel in the view.

This property is used by the loadView method as it creates the view, when the view property is first accessed and the view property has not already been established.

The initial value is one. You can set this property prior to referencing the view property of this controller in order to have the view created with a different number of samples per pixel. Setting this value to a number larger than one will smooth out the lines and edges of your displayed models.

The value set will be clamped to the maximum allowable value for the platform. That maximum value can be retrieved from CC3OpenGLES11Engine.engine.platform.maxPixelSamples.value, and generally has a value of four on all current devices that support multisampling.

Retrieving the value of the CC3OpenGLES11Engine.engine.platform.maxPixelSamples.value property can only be done once the OpenGL ES context has been established, which is generally performed when the view is created. This creates a bit of a chicken-and-egg situation where you might need the maximum pixel samples value before you create the view, but can't retrieve it until the view has been created. This particular value does not vary much from device to device, so the work-around is to determine the maximum value at development time, and then select a pixel samples value accordingly.

Setting the value of this property to zero is the same as setting it to one, and either value will effectively turn multisampling off.

To have effect, this property must be set before the view property is first accessed.

Once the view property has been established, reading this property returns the pixelSamples property of the view itself. Prior to the view being established, reading this property returns the value to which it has been set. The initial value of this property is one.

Multisampling is currently incompatible with using the stencil buffer. If the viewShouldUseStencilBuffer property returns YES, the value of this property cannot be set higher than one .

- (BOOL) viewShouldUseStencilBuffer [read, write, assign]

Indicates whether the view should be created with an underlying stencil buffer.

This property is linked to the value of the viewDepthFormat property, and is provided as a configuration convenience.

Setting this property to YES will set the value of the viewDepthFormat property to GL_DEPTH24_STENCIL8_OES. Setting this property to NO will set the value of the viewDepthFormat property to GL_DEPTH_COMPONENT16_OES.

To have effect, this property must be set before the view property is first accessed.

Reading this property will return YES if the value of the viewDepthFormat property is GL_DEPTH24_STENCIL8_OES, and will return NO otherwise.

The initial value of this property is NO.


The documentation for this class was generated from the following file: