CCAction Class Reference

Inherits from NSObject
Conforms to NSCopying
Declared in CCAction.h

Overview

CCAction is an abstract base class for all actions. Actions animate nodes by manipulating node properties over time such as position, rotation, scale and opacity.

For more information see the Concepts:Actions article in the Developer Guide

Subclasses

The following actions inherit directly from CCAction and can be used “as is”:

These action subclasses are abstract base classes for instant and “over time” actions, see their references for more information:

Creating an Action

+ action

Creates and returns an action.

+ (id)action

Return Value

The CCAction Object.

Discussion

Warning: If a CCAction subclass provides designated initializers you will have to use those over this one.

Declared In

CCAction.h

– init

Initializes and returns an action object.

- (id)init

Return Value

An initialized CCAction Object.

Declared In

CCAction.h

Action Targets

  target

The “target” is typically the node instance that received the [CCNode runAction:] message. The action will modify the target properties. The target will be set with the ‘startWithTarget’ method. When the ‘stop’ method is called, target will be set to nil.

@property (nonatomic, readonly, unsafe_unretained) id target

Discussion

Warning: The target is ‘assigned’ (unsafe unretained), it is not ‘retained’ nor managed by ARC.

Declared In

CCAction.h

  originalTarget

The original target, since target can be nil.

@property (nonatomic, readonly, unsafe_unretained) id originalTarget

Declared In

CCAction.h

Identifying an Action

  tag

The action tag. An identifier of the action.

@property (nonatomic, readwrite, assign) NSInteger tag

Declared In

CCAction.h

Action Methods Implemented by Subclasses

– isDone

Return YES if the action has finished.

- (BOOL)isDone

Return Value

Action completion status

Declared In

CCAction.h

– startWithTarget:

Assigns a target to the action Called before the action is started.

- (void)startWithTarget:(id)target

Parameters

target

Target to assign to action (weak reference).

Declared In

CCAction.h

– stop

Stops the action Called after the action has finished. Will assign the internal target reference to nil. Note: You should never call this method directly. In stead use: [target stopAction:action]

- (void)stop

Declared In

CCAction.h

– step:

Steps the action. Called for every frame with step interval.

- (void)step:(CCTime)dt

Parameters

dt

Ellapsed interval since last step.

Discussion

Note: Do not override unless you know what you are doing.

Declared In

CCAction.h

– update:

Updates the action with normalized value.

- (void)update:(CCTime)time

Parameters

time

Normalized action progress.

Discussion

For example: A value of 0.5 indicates that the action is 50% complete.

Declared In

CCAction.h