CCActionCallFunc Class Reference

Inherits from CCActionInstant : CCActionFiniteTime : CCAction : NSObject
Conforms to NSCopying
Declared in CCActionInstant.h

Overview

This action allows a custom selector to be called. The selector takes no arguments and returns nothing.

Passing Parameters

The selector takes no parameters. Any parameter that the selector needs would have to be in an ivar or property.

It is often preferable to use CCActionCallBlock if you need to “pass in data” without having to add and assign a ivar/property.

Code Example

id callFunc = [CCActionCallFunc actionWithTarget:self selector@selector(myCallFuncMethod)];
[self runAction:callFunc];

The method needs to be declared as follows within the target’s class (here: the class self is an instance of):

-(void) myCallFuncMethod {
    NSLog(@"call func action ran my method");
}

Note that this simple example above is equivalent (but not as efficient) than simply calling the method directly:

[self myCallFuncMethod];

Creating a Perform Selector Action

+ actionWithTarget:selector:

Creates the action with the callback.

+ (id)actionWithTarget:(id)t selector:(SEL)s

Parameters

t

Target the selector is sent to.

s

Selector to execute. Selector takes no parameters and returns nothing.

Return Value

The call func action object.

Declared In

CCActionInstant.h

– initWithTarget:selector:

Initializes the action with the callback.

- (id)initWithTarget:(id)t selector:(SEL)s

Parameters

t

Target the selector is sent to

s

Selector to execute. Selector takes no parameters and returns nothing.

Return Value

An initialized call func action object.

Declared In

CCActionInstant.h