cocos2d-iphone  2.1
Improved Cocos2D API Reference (iOS version) for developers
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Defines
CCCamera Class Reference

#import <CCCamera.h>

List of all members.

Public Member Functions

(void) - restore
(void) - locate
(void) - setEyeX:eyeY:eyeZ:
(void) - setCenterX:centerY:centerZ:
(void) - setUpX:upY:upZ:
(void) - eyeX:eyeY:eyeZ:
(void) - centerX:centerY:centerZ:
(void) - upX:upY:upZ:

Static Public Member Functions

(float) + getZEye

Protected Attributes

float _eyeX
float _eyeY
float _eyeZ
float _centerX
float _centerY
float _centerZ
float _upX
float _upY
float _upZ
BOOL _dirty
kmMat4 _lookupMatrix


BOOL dirty

Detailed Description

A CCCamera is used in every CCNode. Useful to look at the object from different views. The OpenGL gluLookAt() function is used to locate the camera.

If the object is transformed by any of the scale, rotation or position attributes, then they will override the camera.

IMPORTANT: Either your use the camera or the rotation/scale/position properties. You can't use both. World coordinates won't work if you use the camera.


  • Some nodes, like CCParallaxNode, CCParticle uses world node coordinates, and they won't work properly if you move them (or any of their ancestors) using the camera.
  • It is recommended to use it ONLY if you are going to create 3D effects. For 2D effects, use the action CCFollow or position/scale/rotate.

Member Function Documentation

- (void) centerX: (float *)  x
centerY: (float *)  y
centerZ: (float *)  z 

get the center vector values in points

- (void) eyeX: (float *)  x
eyeY: (float *)  y
eyeZ: (float *)  z 

get the eye vector values in points

+ (float) getZEye

returns the Z eye

- (void) locate

Sets the camera using gluLookAt using its eye, center and up_vector

- (void) restore

sets the camera in the defaul position

- (void) setCenterX: (float)  x
centerY: (float)  y
centerZ: (float)  z 

sets the center values in points

- (void) setEyeX: (float)  x
eyeY: (float)  y
eyeZ: (float)  z 

sets the eye values in points

- (void) setUpX: (float)  x
upY: (float)  y
upZ: (float)  z 

sets the up values

- (void) upX: (float *)  x
upY: (float *)  y
upZ: (float *)  z 

get the up vector values

Property Documentation

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

whether of not the camera is dirty

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