Class cocos.actions.base_actions.IntervalAction

Action --+
         |
        IntervalAction
Known Subclasses:
skeleton.Animate, basegrid_actions.AccelAmplitude, basegrid_actions.AccelDeccelAmplitude, basegrid_actions.GridBaseAction, InstantAction, camera_actions.Camera3DAction, interval_actions.AccelDeccel, interval_actions.Accelerate, interval_actions.Bezier, interval_actions.Blink, interval_actions.Delay, interval_actions.FadeOut, interval_actions.FadeTo, interval_actions.Jump, interval_actions.JumpBy, interval_actions.Lerp, interval_actions.MoveTo, interval_actions.RotateBy, interval_actions.RotateTo, interval_actions.ScaleTo, interval_actions.Speed, Loop_IntervalAction, Sequence_IntervalAction, Spawn_IntervalAction

IntervalAction()

Interval Actions are the ones that have fixed duration, known at the instantiation time, and, conceptually, the expected duration must be positive. Degeneratated cases, when a particular instance gets a zero duration, are allowed for convenience.

IntervalAction adds the method update to the public interfase, and it expreses the changes to target as a function of the time elapsed, relative to the duration, ie f(time_elapsed/duration). Also, it is guaranted that in normal termination .update(1.0) is called. Degenerate cases, when a particular instance gets a zero duration, also are guaranted to call .update(1.0) Note that when a premature termination happens stop will be called but update(1.0) is not called.

Examples: MoveTo , MoveBy , RotateBy are Interval Actions, while Place, Show and CallFunc aren't.

While RotateBy(angle, duration) will usually receive a positive duration, it will accept duration = 0, to ease on cases like action = RotateBy( angle, a-b )

Methods

  step(self, dt)
Dont customize this method: it will not be called when in the component role for certain composite actions (like Sequence_IntervalAction).
  update(self, 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.
  done(self)
When in the worker role, this method is reliable.
  __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
  __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)
  __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)
  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)
Dont customize this method: it will not be called when in the component role for certain composite actions (like Sequence_IntervalAction). In such situation the composite will calculate the suitable t and directly call .update(t) You customize the action stepping by overriding .update
Overrides:
Action.step

done

done(self)
When in the worker role, this method is reliable. When in the component role, if the composite spares the call to step this method cannot be relied (an then the composite must decide by itself when the action is done). Example of later situation is Sequence_IntervalAction.
Overrides:
Action.done

__mul__

__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
Overrides:
Action.__mul__