1

所以我在我的 cocosbuilder 项目中用 cocosbuilder 构建了一个 CCMenuItemImage 并在以后的项目中使用它。但是,从不调用响应方法。在此处输入图像描述

在此处输入图像描述

4

3 回答 3

2

转到“文档”菜单并确保未选中“JavaScript 控制”。

我真的很难受。CCBControlButtons 调用了它们的选择器,但 CCMenuItemImages 没有。更改了该设置,它现在可以工作了。

于 2013-02-03T10:59:42.060 回答
0

well, that's happened to me too...

the solution is first, u have to press enter after u've typed the selector field..

secondly, u have to publish (I do more than once).

for your info.... when u saved cocosbuilder project (cmd + s), u will not save the entire project... u'll only save current scene....

so, just in case u should save and publish on every scene u worry..

last tip (i don't know the different though), I chose document root (not owner ) :D

may this tips help you bro!

于 2013-01-27T13:45:08.073 回答
0

您没有提供太多让我们能够提供帮助的信息。但是,我最近对我的应用程序做了同样的事情,所以也许我可以给你一些关于在哪里看的想法。首先,CCMenu 是它自己的根节点(单独的文件)还是 CocosBuilder 文件中 CCLayer 的子节点?

在第一个场景中,CCMenu(和 CCMenuItemImage)是一个单独的节点文件,然后您可以使用以下语句将其链接到您的游戏层代码:

CCMenu *menu = [CCBReader nodeGraphFromFile:@"filename.ccbi" owner:self];

然后在 Cocosbuilder 程序中,键入 CCMenuItemImage 链接到的方法的名称,确保选择“Owner”而不是“Document root”。

第二种情况是您的 Cocosbuilder 文件是 CCLayer,而 CCMenu 是该层的子层,这可能是更可能的情况。如果您成功加载了 ccb 文件

CCScene *scene = [CCBReader sceneWithNodeGraphFromFile:@"filename.ccbi"]; (might need to double-check that one, I am not at my XCode)

然后,在 Cocosbuilder 中,当您键入 CCMenuItemImage 方法名称时,选择“Document Root”以将其链接到您的代码。

然后在你的游戏层的代码中,你应该有和你在 Cocosbuilder 中输入相同的方法。所以如果你的游戏层的方法是:

-(void)pressedButton:(id)sender {
   CCLOG(@"Button pressed!");
}

然后你需要有相同的方法

pressedButton:

链接到 Cocosbuilder 中的那个按钮。

希望这可以帮助。

于 2012-12-07T11:45:11.513 回答