开发者

How can we run CCAction of classA in classB ? What method can we use for it?

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 *Action开发者_如何学GoScale;
}
@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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜