views:

28

answers:

1

Hi, I have CCAction *action1; in classA. I need to use that action in classB.
I need to run action1 along with other actions in classB. How can I do that ? I did in the following way but not working.

warning: 'CCAction' may not respond to '+actionWithAction:'

Here are my classA and classB.

@interface classA : CCLayer {
    CCAction *ActionScale;
}
@property (nonatomic, retain)CCAction *ActionScale;
@end

#import "classA.h"
@implementation classA
@synthesize ActionScale;

-(id)init
{
    if( (self = [super init]) )
    {
     ...
     ActionScale = [CCScaleBy actionWithDuration:1.0f scale:2.0];
     }
    return self;
}

//classB

@class classA;
@interface classB : CCLayer {
    CCSprite *sprite1;
    classA *object1;
}
@property(nonatomic, retain)classA *object1;
@end

#import "classB.h"
#import "classA.h"
@implementation classB
@synthesize object1;

-(id)init
{
    if( (self = [super init]) )
    {
     ...
     ...
    id eggAction3 = [CCAction actionWithAction:object1.ActionScale]; 
    }return self;
}  

What method should we use to call the CCAction of one class in to other class ?

Thank you.

A: 

I'm not sure exactly what you are trying to do, but couldn't you just say, in classB:

 id eggAction3 = object1.ActionScale;

That would give you a reference to the action in the other object, since you've set it up as a property in the other class.

It might help to describe what you're trying to achieve with this setup.

cc