ゲームの開始画面にボタンがあり、ユーザーがボタンをタップすると次のページにリダイレクトされます。このボタンクリックイベントで通知を呼び出します。このコードは
- (void)switchsounds
{
CCLOG(@"hiii");
[[NSNotificationCenter defaultCenter] postNotificationName:@"reloadvieweyes" object:nil];
CCTransitionJumpZoom *transition = [CCTransitionJumpZoom transitionWithDuration:1.0 scene:[HelloWorldLayer scene]];
// Tell the director to run the transition
[[CCDirector sharedDirector] replaceScene:transition];
}
上記のコードはボタンクリック機能です
init statmnet の次のページで、ボタン イベントの機能を取得するためにこのコードを入力します。
-(id) init
{
if( (self=[super init])) {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(viewreloadedeyes) name:@"reloadvieweyes" object:nil];
}
return self;
}
-(void)viewreloadedeyes
{
CCLOG(@"hiii");
}
ボタンクリックイベントと次のページの関数でcclogを取得しませんでした。しかし、ページのリダイレクトはボタンlcickで行われます。私のコードの問題は何ですか。 .
前もって感謝します。