Ccaction Class Reference
Inherits from |
NSObject |
Conforms to |
Nscopying |
Declared in |
CCAction.h |
Overview
Ccaction is a abstract base class for all actions. Actions animate nodes by manipulating node properties through time such as position, rotation, scale and opacity.
Ccaction is a basic type of all actions. Activates nodes by manipulating the node property, such as position, rotation, transparency, scale, and so on.
For more information see the Concepts:actions article in the Developer Guide
Subclasses
The following actions inherit directly from Ccaction and can being used "as is":
- Ccactionfollow (parent node follows the target node ' s movement)
- Ccactionrepeatforever (runs a ccactioninterval in an endless loop until stopped)
- Ccactionspeed (modifies the speed of a ccactioninterval action and it is running)
These action subclasses is abstract base classes for instant and ' over time ' actions, see their references for more infor Mation:
- Ccactionfinitetime
- Ccactioninstant
- Ccactioninterval
Taskscreating an Action
Action Targets
target
Property
originalTarget
Property
Identifying an Action
Action Methods implemented by subclasses
– isDone
– startWithTarget:
– stop
– step:
– update:
Propertiesoriginaltarget
The original target, since target can be nil.
The original target can be nil.
@property (nonatomic, readonly, unsafe_unretained) id originalTarget
Declared in
CCAction.h
Tag
The action tag. An identifier of the action.
Action tag, which defines an action.
@property (nonatomic, readwrite, assign) NSInteger tag
Declared in
CCAction.h
Target
The "target" is typically the node instance that received the [Ccnode runaction:] message. The action would modify the target properties. The target is set with the ' Startwithtarget ' method. When the ' Stop ' method is called, Target would be set to nil.
"Target" is a typical node instance that can receive the [Ccnode runaction:] method. Acition will define the target property. Target can be set by the Startwithtarget method, and when the Stop method is called, the target is reset to nil.
@property (nonatomic, readonly, unsafe_unretained) id target
Discussion
Warning: The target is ' assigned ' (unsafe unretained), it's not a ' retained ' nor managed by ARC.
Declared in
CCAction.h
Class methodsaction
Creates and returns an action.
Create and return an action
+ (id)action
Return Value
The Ccaction Object.
Discussion
Warning: If a ccaction subclass provides designated initializers You'll have the use of those over this one.
Declared in
CCAction.h
Instance Methodsinit
Initializes and returns an Action object.
Initializes and returns an Action object.
- (id)init
Return Value
An initialized ccaction Object.
Declared in
CCAction.h
IsDone
Return YES If the action has finished.
returns Yes if the action ends.
- (BOOL)isDone
Return Value
Action Completion Status
Action completion status.
Declared in
CCAction.h
Startwithtarget:
Assigns a target to the action called before the action is started.
Assigns a target to the action. This is called before the action starts.
- (void)startWithTarget:(id)target
Parameters
-
Target
-
Target to assign to action (weak reference).
Declared in
CCAction.h
Step
Steps the action. Called for every frame with step interval.
The action step. Each frame is called, step interval.
- (void)step:(CCTime)dt
Parameters
-
Dt
-
Ellapsed interval since last step.
Discussion
Note:do not the override unless you know is doing.
Declared in
CCAction.h
Stop
Stops the action called after the action has finished. Would assign the internal target reference to nil. Note:you should never call the This method directly. In stead use: [Target stopaction:action]
Stopping a action,action is called after the end. will set the internal target to nil.
You should never call this method directly. Replace with [Target stopaction:action].
- (void)stop
Declared in
CCAction.h
Update
Updates the action with normalized value.
Updates the action with normalized values.
- (void)update:(CCTime)time
Parameters
-
Time
-
Normalized action progress.
Discussion
For example:a value of 0.5 indicates, the action is 50% complete.
Declared in
CCAction.h
Ccactioninterval Class Reference
Inherits from |
CCActionFiniteTime:CCAction:NSObject |
Conforms to |
Nscopying |
Declared in |
CCActionInterval.h |
Overview
Abstract base class for interval actions. An interval action was an action, that performs it task over a certain period of time.
Abstract basic class about the interval action. An interval action refers to an action that completes the entire process over a period of time.
Most ccactioninterval actions can reversed or has their speed altered via the Ccactionspeed action.
Most ccactioninterval actions can be reversed or changed in rate, through ccactionspeed action.
Moving, rotating, Scaling a Node
- Moving a node along a straight line or curve:
- Ccactionmoveby, Ccactionmoveto
- Ccactionbezierby, Ccactionbezierto
- Ccactioncardinalsplineto, Ccactioncardinalsplineby
- Ccactioncatmullromby, Ccactioncatmullromto
- Rotating a node:
- Ccactionrotateby, Ccactionrotateto
- Scaling a node:
- Ccactionscaleto, Ccactionscaleby
Animating a Node ' s Visual Properties
- Periodically toggle Visible property on/off:
- Fading a node in/out/to:
- Ccactionfadein, Ccactionfadeout
- Ccactionfadeto
- Colorizing a node:
- Ccactiontintby, Ccactiontintto
- Skewing a node:
- Ccactionskewto, Ccactionskewby
- Animate the sprite frames of a ccsprite with ccanimation:
- Animating a Ccprogressnode:
- Ccactionprogressfromto, Ccactionprogressto
Repeating and reversing Actions
- Repeating an action a specific number of times:
- Reversing an action (if supported by the action):
Creating sequences of Actions
- Creating a linear sequence of actions:
- Ccactionsequence
- Wait for a given time in a ccactionsequence:
- Spawning parallel running actions in a ccactionsequence and continue the sequence, all spawned actions are ended:
Easing the Duration of an Action
- Easing duration of a ccactioninterval:
- Ccactionease
- Ccactioneasebackin, Ccactioneasebackinout, Ccactioneasebackout
- Ccactioneasebounce, Ccactioneasebouncein, Ccactioneasebounceinout, Ccactioneasebounceout
- Ccactioneaseelastic, Ccactioneaseelasticin, Ccactioneaseelasticinout, Ccactioneaseelasticout
- Ccactioneaserate, Ccactioneasein, Ccactioneaseinout, Ccactioneaseout
- Ccactioneasesinein, Ccactioneasesineinout, Ccactioneasesineout
Animating Custom Float/double Properties
- Tweening any node property (of type float or double):
Tasksother Methods
Creating a Interval Action
+ actionWithDuration:
– initWithDuration:
Reversing an Action
Methods implemented by subclasses
Propertieselapsed
How many seconds had elapsed since the actions started to run.
How long has it been since the action was executed?
@property (nonatomic, readonly) CCTime elapsed
Declared in
CCActionInterval.h
Class methodsactionwithduration:
Creates and returns an action interval object.
Creates and returns an action interval object.
+ (id)actionWithDuration:(CCTime)d
Parameters
-
D
-
Action interval.
Return Value
The Ccactioninterval object.
Declared in
CCActionInterval.h
Instance methodsinitwithduration:
Initializes and returns an action interval object.
- (id)initWithDuration:(CCTime)d
Parameters
-
D
-
Action interval.
Return Value
An initialized ccactioninterval Object.
Declared in
CCActionInterval.h
IsDone
Returns YES If the action has finished.
- (BOOL)isDone
Return Value
Action Finished status.
Declared in
CCActionInterval.h
Reverse
Returns a reversed action.
- (CCActionInterval *)reverse
Return Value
Created reversed action.
Declared in
CCActionInterval.h
Ccactionmoveto Class Reference
Inherits from |
CCActionMoveBy:CCActionInterval:CCActionFiniteTime:CCAction:NSObject |
Declared in |
CCActionInterval.h |
Overview
This action moves the target to the position specified, these is absolute coordinates. Several Ccmoveto actions can be concurrently called, and the resulting movement would be the sum of individual movements.
Warning: Move actions shouldn ' is used to move nodes with a dynamic ccphysicsbody as both the physics body and the action would alt Er the node ' s position property, overriding each of the other ' s changes. This leads to unpredictable behavior.
Taskscreating a Move Action
+ actionWithDuration:position:
– initWithDuration:position:
Class methodsactionwithduration:position:
Creates the action.
+ (id)actionWithDuration:(CCTime)duration position:(CGPoint)position
Parameters
-
Duration
-
Action interval.
-
Position
-
Absolute position to move to.
Return Value
New moveto action.
Declared in
CCActionInterval.h
Instance methodsinitwithduration:position:
Initializes the action.
- (id)initWithDuration:(CCTime)duration position:(CGPoint)position
Parameters
-
Duration
-
Action interval.
-
Position
-
Absolute position to move to.
Return Value
New moveto action.
Declared in
CCActionInterval.h
Ccaction class and Ccactioninterval class and Ccactionmoveto class---cocos2d-swift v3.3