Interval Action
An interval action is an action that takes place within a certain period of time. It has an start time, and a finish time. The finish time is the parameter duration plus the start time.
These IntervalAction have some interesting properties, like:
- They can run normally (default)
- They can run reversed with the Reverse action.
- They can run with the time altered with the Accelerate, AccelDeccel and Speed actions.
For example, you can simulate a Ping Pong effect running the action normally and then running it again in Reverse mode.
Example:
ping_pong_action = action + Reverse( action )
- MoveTo
- MoveBy
- JumpTo
- JumpBy
- Bezier
- Blink
- RotateTo
- RotateBy
- ScaleTo
- ScaleBy
- FadeOut
- FadeIn
- FadeTo
- Delay
- RandomDelay
- Accelerate
- AccelDeccel
- Speed
Examples:
move = MoveBy( (200,0), duration=5 ) # Moves 200 pixels to the right in 5 seconds.
move = MoveTo( (320,240), duration=5) # Moves to the pixel (320,240) in 5 seconds
jump = JumpBy( (320,0), 100, 5, duration=5) # Jumps to the right 320 pixels
# doing 5 jumps of 100 pixels
# of height in 5 seconds
accel_move = Accelerate(move) # accelerates action move
Bases: cocos.actions.base_actions.IntervalAction
Interpolate between values for some specified attribute
Init method.
Parameters: |
|
---|
Bases: cocos.actions.base_actions.IntervalAction
Moves a CocosNode object to the position x,y. x and y are absolute coordinates by modifying it’s position attribute.
Example:
# Move the sprite to coords x=50, y=10 in 8 seconds
action = MoveTo( (50,10), 8 )
sprite.do( action )
Init method.
Parameters: |
|
---|
Bases: cocos.actions.interval_actions.MoveTo
Moves a CocosNode object x,y pixels by modifying it’s position attribute. x and y are relative to the position of the object. Duration is is seconds.
Example:
# Move the sprite 50 pixels to the left in 8 seconds
action = MoveBy( (-50,0), 8 )
sprite.do( action )
Init method.
Parameters: |
|
---|
Bases: cocos.actions.base_actions.IntervalAction
Moves a CocosNode object simulating a jump movement by modifying it’s position attribute.
Example:
action = Jump(50,200, 5, 6) # Move the sprite 200 pixels to the right
sprite.do( action ) # in 6 seconds, doing 5 jumps
# of 50 pixels of height
Init method
Parameters: |
|
---|
Bases: cocos.actions.interval_actions.JumpBy
Moves a CocosNode object to a position simulating a jump movement by modifying it’s position attribute.
Example:
action = JumpTo(50,200, 5, 6) # Move the sprite 200 pixels to the right
sprite.do( action ) # in 6 seconds, doing 5 jumps
# of 50 pixels of height
Bases: cocos.actions.base_actions.IntervalAction
Moves a CocosNode object simulating a jump movement by modifying it’s position attribute.
Example:
# Move the sprite 200 pixels to the right and up
action = JumpBy((100,100),200, 5, 6)
sprite.do( action ) # in 6 seconds, doing 5 jumps
# of 200 pixels of height
Init method
Parameters: |
|
---|
Bases: cocos.actions.base_actions.IntervalAction
Moves a CocosNode object through a bezier path by modifying it’s position attribute.
Example:
action = Bezier( bezier_conf.path1, 5 ) # Moves the sprite using the
sprite.do( action ) # bezier path 'bezier_conf.path1'
# in 5 seconds
Init method
Parameters: |
|
---|
Bases: cocos.actions.base_actions.IntervalAction
Rotates a CocosNode object to a certain angle by modifying it’s rotation attribute. The direction will be decided by the shortest angle.
Example:
# rotates the sprite to angle 180 in 2 seconds
action = RotateTo( 180, 2 )
sprite.do( action )
Init method.
Parameters: |
|
---|
Bases: cocos.actions.base_actions.IntervalAction
Rotates a CocosNode object clockwise a number of degrees by modiying it’s rotation attribute.
Example:
# rotates the sprite 180 degrees in 2 seconds
action = RotateBy( 180, 2 )
sprite.do( action )
Init method.
Parameters: |
|
---|
Bases: cocos.actions.base_actions.IntervalAction
Scales a CocosNode object to a zoom factor by modifying it’s scale attribute.
Example:
# scales the sprite to 5x in 2 seconds
action = ScaleTo( 5, 2 )
sprite.do( action )
Init method.
Parameters: |
|
---|
Bases: cocos.actions.interval_actions.ScaleTo
Scales a CocosNode object a zoom factor by modifying it’s scale attribute.
Example:
# scales the sprite by 5x in 2 seconds
action = ScaleBy( 5, 2 )
sprite.do( action )
Bases: cocos.actions.base_actions.IntervalAction
Delays the action a certain amount of seconds
Example:
action = Delay(2.5)
sprite.do( action )
Init method
Parameters: |
|
---|
Bases: cocos.actions.interval_actions.Delay
Delays the actions between min and max seconds
Example:
action = RandomDelay(2.5, 4.5) # delays the action between 2.5 and 4.5 seconds
sprite.do( action )
Init method
Parameters: |
|
---|
Bases: cocos.actions.base_actions.IntervalAction
Fades out a CocosNode object by modifying it’s opacity attribute.
Example:
action = FadeOut( 2 )
sprite.do( action )
Init method.
Parameters: |
|
---|
Bases: cocos.actions.interval_actions.FadeOut
Fades in a CocosNode object by modifying it’s opacity attribute.
Example:
action = FadeIn( 2 )
sprite.do( action )
Bases: cocos.actions.base_actions.IntervalAction
Fades a CocosNode object to a specific alpha value by modifying it’s opacity attribute.
Example:
action = FadeTo( 128, 2 )
sprite.do( action )
Init method.
Parameters: |
|
---|
Bases: cocos.actions.base_actions.IntervalAction
Blinks a CocosNode object by modifying it’s visible attribute
The action ends with the same visible state than at the start time.
Example:
# Blinks 10 times in 2 seconds
action = Blink( 10, 2 )
sprite.do( action )
Init method.
Parameters: |
|
---|
Bases: cocos.actions.base_actions.IntervalAction
Changes the acceleration of an action
Example:
# rotates the sprite 180 degrees in 2 seconds clockwise
# it starts slow and ends fast
action = Accelerate( Rotate( 180, 2 ), 4 )
sprite.do( action )
Init method.
Parameters: |
|
---|
Bases: cocos.actions.base_actions.IntervalAction
Makes an action change the travel speed but retain near normal speed at the beginning and ending.
Example:
# rotates the sprite 180 degrees in 2 seconds clockwise
# it starts slow, gets fast and ends slow
action = AccelDeccel( RotateBy( 180, 2 ) )
sprite.do( action )
Init method.
Parameters: |
|
---|
Bases: cocos.actions.base_actions.IntervalAction
Changes the speed of an action, making it take longer (speed>1) or less (speed<1)
Example:
# rotates the sprite 180 degrees in 1 secondclockwise
action = Speed( Rotate( 180, 2 ), 2 )
sprite.do( action )
Init method.
Parameters: |
|
---|