2010-07-16 2 views
1

CCAction * 동작 1; classA에 나는 classB에서 그 행동을 사용할 필요가있다.
classB의 다른 작업과 함께 action1을 실행해야합니다. 어떻게해야합니까? 다음과 같은 방법으로 작업했지만 작동하지 않았습니다.classB에서 classA의 CCAction을 어떻게 실행할 수 있습니까? 어떤 방법으로 사용할 수 있습니까?

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

여기에 classA와 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; 
} 

//

@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; 
} 

우리가 다른 클래스에 하나 개의 클래스의 CCAction에게 전화를 걸 때 사용합니다 어떤 방법 ClassB가

?

감사합니다.

답변

0

ClassB가에, 나는 당신이 일을하려고 정확히 모르겠지만, 당신은 말할 수 :

id eggAction3 = object1.ActionScale; 

당신에게 다른 객체의 행동에 대한 참조를 줄 것이다 그 이후 다른 클래스의 속성으로 설정했습니다.

이 설정으로 달성하려는 것을 설명하는 것이 도움이 될 수 있습니다.

관련 문제