cocos.actions.camera_actions module

Camera Actions

Actions that moves the OpenGL camera.

exception CameraException

Bases: Exception

class Camera3DAction(*args, **kwargs)

Bases: cocos.actions.base_actions.IntervalAction

init(duration=2)

Initialize the Camera Action

Parameters
durationint

Number of seconds that the action will last

start()

External code sets self.target and then calls this method. Perform here any extra initialization needed.

class OrbitCamera(*args, **kwargs)

Bases: cocos.actions.camera_actions.Camera3DAction

Orbits the camera around the center of the screen using spherical coordinates

get_spherical_coords()

returns the spherical coordinates from a cartesian coordinates

using this formula:

Return type

(radius, zenith, azimuth)

init(radius=None, delta_radius=0, angle_z=None, delta_z=0, angle_x=None, delta_x=0, *args, **kw)

Initialize the camera with spherical coordinates

Parameters
radiusfloat

Radius of the orbit. Default: current radius

delta_radiusfloat

Delta movement of the radius. Default: 0

angle_zfloat

The zenith angle of the spherical coordinate in degrees. Default: current

delta_zfloat

Relative movement of the zenith angle. Default: 0

angle_xfloat

The azimuth angle of the spherical coordinate in degrees. Default: 0

delta_xfloat

Relative movement of the azimuth angle. Default: 0

For more information regarding spherical coordinates, read this:

http://en.wikipedia.org/wiki/Spherical_coordinates

start()

External code sets self.target and then calls this method. Perform here any extra initialization needed.

update(t)

Gets called on every frame ‘t’ is the time elapsed normalized to [0, 1] If this action takes 5 seconds to execute, t will be equal to 0 at 0 seconds. t will be 0.5 at 2.5 seconds and t will be 1 at 5sec. This method must not use self._elapsed, which is not guaranted to be updated.