简体   繁体   English

LevelHelper 和 Box2D Collions:如何获得“标签”?

[英]LevelHelper and Box2D Collions: How to get "tag"?

I have successfully made a very simple LevelHelper/Box2D/Cocos2D project.我已经成功制作了一个非常简单的 LevelHelper/Box2D/Cocos2D 项目。 I am now trying to register a collision as described in the documentation here .我现在正在尝试按照此处的文档中的说明注册冲突。

I used the example code as follows:我使用的示例代码如下:

[lh registerBeginOrEndColisionCallbackBetweenTagA:COIN
                                          andTagB:MARIO
                                       idListener:self
                                      selListener:@selector(beginEndCollisionBetweenMarioAndCoin:)];

My Question is this: how do I get the tag?我的问题是:我如何获得标签? Am I correct in setting it in LevelHelper in the "General Properties" pane?我在“常规属性”窗格中的 LevelHelper 中设置它是否正确? (below) (以下)

LevelHelper 标签设置为 CHARACTER_TAG?

In LevelHelper's Custom Properties window the "Tag Value" for "CHARACTER_TAG" is 1, but if I try and put this into the above code instead of "MARIO" XCode gets upset because it "cannot initialize a parameter of type 'enum LevelHelper_TAG' with an rvalue of type 'int' " (fair enough).在 LevelHelper 的自定义属性窗口中,“CHARACTER_TAG”的“标签值”为 1,但是如果我尝试将其放入上面的代码而不是“MARIO”中,XCode 会感到不安,因为它“无法初始化类型为 'enum LevelHelper_TAG' 的参数'int'" 类型的右值(足够公平)。

Thank you!谢谢!

I've figured it out!我已经想通了!

After setting the tag to CHARACTER_TAG in LevelHelper, I needed to regenerate my code with File\\Generate Code\\Cocos2D with Box2D.在 LevelHelper 中将标签设置为CHARACTER_TAG后,我需要使用 File\\Generate Code\\Cocos2D 和 Box2D 重新生成我的代码。 Then I could simply type CHARACTER_TAG in place of MARIO as seen in my question!然后我可以简单地输入 CHARACTER_TAG 代替 MARIO,如我的问题所示!

I hope this helps someone!我希望这可以帮助别人!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM