Class cocos.actions.move_actions.Driver

base_actions.Action --+
                      |
                     Driver

Drive a CocosNode object around like a car in x, y according to a direction and speed.

Example:

# control the movement of the given sprite
sprite.do(Driver())

...
sprite.rotation = 45
sprite.speed = 100
...

The sprite MAY have these parameters (beyond the standard position and rotation):

speed : float
Speed to move at in pixels per second in the direction of the target's rotation.
acceleration : float
If specified will automatically be added to speed. Specified in pixels per second per second.
max_forward_speed : float (default None)
Limits to apply to speed when updating with acceleration.
max_reverse_speed : float (default None)
Limits to apply to speed when updating with acceleration.

Methods

  step(self, dt)
Gets called every frame.
  __add__(self, action)
sequence operator - concatenates actions action1 + action2 -> action_result where action_result performs as: first do all that action1 would do; then perform all that action2 would do
(Inherited from cocos.actions.base_actions.Action)
  __init__(self, *args, **kwargs)
dont override - use init
(Inherited from cocos.actions.base_actions.Action)
  __mul__(self, other)
repeats ntimes the action action * n -> action_result where action result performs as: repeat n times the changes that action would do
(Inherited from cocos.actions.base_actions.Action)
  __or__(self, action)
spawn operator - runs two actions in parallel action1 | action2 -> action_result
(Inherited from cocos.actions.base_actions.Action)
  __reversed__(self) (Inherited from cocos.actions.base_actions.Action)
  done(self)
False while the step method must be called.
(Inherited from cocos.actions.base_actions.Action)
  init(*args, **kwargs)
Gets called by __init__ with all the parameteres received, At this time the target for the action is unknown.
(Inherited from cocos.actions.base_actions.Action)
  start(self)
External code sets self.target and then calls this method.
(Inherited from cocos.actions.base_actions.Action)
  stop(self)
When the action must cease to perform this function is called by external code; after this call no other method should be called.
(Inherited from cocos.actions.base_actions.Action)

Instance Variables

  target
CocosNode object that is the target of the action
(Inherited from cocos.actions.base_actions.Action)

Method Details

step

step(self, dt)
Gets called every frame. dt is the number of seconds that elapsed since the last call.
Overrides:
base_actions.Action.step