在Cocos2D v3 iOS中按下CCB按钮时,该按钮无法完全工作

在Cocos2D v3 iOS中按下CCB按钮时,该按钮无法完全工作,ios,cocos2d-iphone,ccnode,Ios,Cocos2d Iphone,Ccnode,我有一个游戏场景,我在上面添加了一个CCNode。我的游戏在节点上有一个重播按钮 该按钮用于重新启动游戏场景。问题是,当我按下“重新启动”按钮时,它会遍历所有行,但不会执行replaceSecene。当按下时,它也不会突出显示。这是我的相关代码: 我在游戏类(.m)的节点上添加游戏的代码: 下面是GameOver类(.h)的代码: 游戏结束(.m): 问题是,它打印出“按钮按下”,也会遍历该方法的其余代码,但什么也没发生 如果你能让我知道我做错了什么,我将不胜感激 谢谢 它无法工作,因为您已暂停

我有一个游戏
场景
,我在上面添加了一个
CCNode
。我的游戏在节点上有一个重播按钮

该按钮用于重新启动游戏场景。问题是,当我按下“重新启动”按钮时,它会遍历所有行,但不会执行
replaceSecene
。当按下时,它也不会突出显示。这是我的相关代码:

我在游戏类(.m)的
节点上添加游戏的代码:

下面是GameOver类(.h)的代码:

游戏结束(.m):

问题是,它打印出“按钮按下”,也会遍历该方法的其余代码,但什么也没发生

如果你能让我知道我做错了什么,我将不胜感激


谢谢

它无法工作,因为您已暂停CCDirector。删除以下行:

[[CCDirector sharedDirector] pause];
或者,如果确实需要,请在尝试替换场景之前恢复导演

[[CCDirector sharedDirector] resume];
[[CCDirector sharedDirector] replaceScene:[GamePlayScene scene] withTransition:t];

它无法工作,因为您已暂停CCDirector。删除以下行:

[[CCDirector sharedDirector] pause];
或者,如果确实需要,请在尝试替换场景之前恢复导演

[[CCDirector sharedDirector] resume];
[[CCDirector sharedDirector] replaceScene:[GamePlayScene scene] withTransition:t];

它无法工作,因为您已暂停CCDirector。删除以下行:

[[CCDirector sharedDirector] pause];
或者,如果确实需要,请在尝试替换场景之前恢复导演

[[CCDirector sharedDirector] resume];
[[CCDirector sharedDirector] replaceScene:[GamePlayScene scene] withTransition:t];

它无法工作,因为您已暂停CCDirector。删除以下行:

[[CCDirector sharedDirector] pause];
或者,如果确实需要,请在尝试替换场景之前恢复导演

[[CCDirector sharedDirector] resume];
[[CCDirector sharedDirector] replaceScene:[GamePlayScene scene] withTransition:t];

你的回答有道理。我试过了,但没有成功。我评论了这部分内容:
[self-unscheduleallselector];[自停止动作];[[OALSimpleAudio sharedInstance]stopBg];[[CCDirector sharedDirector]stopAnimation];[[CCDirector sharedDirector]暂停],然后运行它,令人惊讶的是,当添加GameOver节点时,游戏会自动停止。但是,同样地,
replaceSecene
不起作用。从您添加的代码中,我看不出您的GameOverNode有任何问题,请尝试在您的游戏场景上放置一个按钮,并使用该按钮推送您GamePlaySecene的新实例,以便确认问题不在GameOverNode上。(我假设你的scene类方法创建了你的scene的一个新实例
+(GameplaySecene*)scene{return[[GameplaySecene alloc]init];}
你的回答是有意义的。我试过了,但没有成功。我对这部分都做了评论:
[self unscheduleallselector];[self stopAllActions];[OALSimpleAudio sharedstance]stopBg][[CCDirector sharedDirector]停止动画];[CCDirector sharedDirector]暂停];
,然后运行它,令人惊讶的是,当添加GameOver节点时,游戏会自动停止。但是,
replaceSecene
仍然不起作用。从您添加的代码中,我看不出GameOver节点有任何问题,请尝试在您的游戏场景上放置一个按钮,并使用该按钮推送GamePlaySecene的新实例,这样您就可以确认问题不在GameOverNode上。(我假设您的scene类方法创建了一个新的scene实例
+(GamePlaySecene*)scene{return[[GamePlaySecene alloc]init];}
您的回答是有意义的。我尝试了,但没有成功。我对这部分都做了注释:
[self unscheduleAllSelectors];[self stopAllActions][[OALSimpleAudio sharedInstance]stopBg];[CCDirector sharedDirector]stopAnimation];[CCDirector sharedDirector]pause];
,然后运行它,令人惊讶的是,当添加GameOver节点时,游戏会自动停止。但是,
replaceSecene
仍然不起作用。从您添加的代码中,我看不出GameOver节点有任何问题,请尝试在您的游戏场景上放置一个按钮,并使用该按钮推送GamePlaySecene的新实例,这样您就可以确认问题不在GameOverNode上。(我假设您的scene类方法创建了一个新的scene实例
+(GamePlaySecene*)scene{return[[GamePlaySecene alloc]init];}
您的回答是有意义的。我尝试了,但没有成功。我对这部分都做了注释:
[self unscheduleAllSelectors];[self stopAllActions][[OALSimpleAudio sharedInstance]stopBg];[CCDirector sharedDirector]stopAnimation];[CCDirector sharedDirector]pause];
,然后运行它,令人惊讶的是,当添加GameOver节点时,游戏会自动停止。但是,
replaceSecene
仍然不起作用。从您添加的代码中,我看不出GameOver节点有任何问题,请尝试在您的游戏场景上放置一个按钮,并使用该按钮推送GamePlaySecene的新实例,这样您就可以确认问题不在GameOverNode上。(我假设您的scene类方法创建了一个新的scene实例
+(GamePlaySecene*)scene{return[[GamePlaySecene alloc]init];}