我想从 HelloWorldLayer 发送消息,并在 ScoreLayer 中接收它,以便更新标签。CCLOG(@"///addNewScore");
工作正常,但是在updateScore
ScoreLayer 中,没有接到电话,你知道为什么吗?这是我的代码:(编辑:我尝试在@property 中使用“retain”,但没有任何改变):
@interface HelloWorldLayer : CCLayer
{
//...
id<ScoreDelegate>delegate;
}
@property (nonatomic,retain) id <ScoreDelegate> delegate;
@implementation HelloWorldLayer
@synthesize delegate;
//...
-(void)addNewScore:(int)num{
CCLOG(@"///addNewScore");//works fine
[delegate updateScore:num];
}
#import <Foundation/Foundation.h>
@protocol ScoreDelegate
-(void)updateScore:(int)num;
@end
@interface ScoreLayer : CCLayer <ScoreDelegate>{
//...
}
-(void)updateScore:(int)num{
CCLOG(@"hello");//DOES NOT WORK
}
@end
非常感谢