Class cocos.camera.Camera

Camera used in every CocosNode. 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.

Methods

  __init__(self)
  get_z_eye(cls)
Returns the best distance for the camera for the current window size
  restore(self)
Restore the camera to the initial position and sets it's dirty attribute in False and once in true.
  locate(self, force=False)
Sets the camera using gluLookAt using its eye, center and up_vector

Properties

flaat,float,float eye
Eye of the camera in x,y,z coordinates
flaat,float,float center
Center of the camera in x,y,z coordinates
flaat,float,float up_vector
Up vector of the camera in x,y,z coordinates

Instance Variables

  dirty
whether or not the camera is 'dirty' It is dirty if it is not in the original position
  once
optimization.

Method Details

get_z_eye

Class Method get_z_eye(cls)

Returns the best distance for the camera for the current window size

cocos2d uses a Filed Of View (fov) of 60

restore

restore(self)

Restore the camera to the initial position and sets it's dirty attribute in False and once in true.

If you use the camera, for a while and you want to stop using it call this method.

locate

locate(self, force=False)
Sets the camera using gluLookAt using its eye, center and up_vector
Parameters:
force : bool
whether or not the camera will be located even if it is not dirty

Property Details

eye

Eye of the camera in x,y,z coordinates
Type:
flaat,float,float

center

Center of the camera in x,y,z coordinates
Type:
flaat,float,float

up_vector

Up vector of the camera in x,y,z coordinates
Type:
flaat,float,float

Instance Variable Details

once

optimization. Only renders the camera once