Search code examples
xcodecocos2d-iphonebox2dcollisionlevelhelper

LevelHelper and Box2D Collions: How to get "tag"?


I have successfully made a very simple LevelHelper/Box2D/Cocos2D project. 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? (below)

LevelHelper Tag is set to 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).

Thank you!


Solution

  • 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. Then I could simply type CHARACTER_TAG in place of MARIO as seen in my question!

    I hope this helps someone!