Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8309009
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T18:58:40+00:00 2026-06-08T18:58:40+00:00

I have Building CCNode It’s have property: in .h file @property (nonatomic) int testProperty;

  • 0

I have Building CCNode

It’s have property:

in .h file

@property (nonatomic) int testProperty;

in .mm file add tag and set property

[[GB2ShapeCache sharedShapeCache] addShapesWithFile:@"Objects.plist"];
[CCTexture2D PVRImagesHavePremultipliedAlpha:YES];
[CCTexture2D setDefaultAlphaPixelFormat:kCCTexture2DPixelFormat_RGBA8888];
batchNode = [CCSpriteBatchNode batchNodeWithFile:@"sprite.png"];
[self addChild:batchNode];
[[CCSpriteFrameCache sharedSpriteFrameCache]addSpriteFramesWithFile:@"sprite.plist"];
sprite = [CCSprite spriteWithSpriteFrameName:[NSString stringWithFormat:@"%@.png", type]];
[batchNode addChild:sprite];
[sprite setTag:2];                 //SET TAG
[self setTestProperty:10];         //SET PROPERTY
...

Also is the ContactListener class
It’s work correctly with this code and i’m detecting body by tag fine:

#import "ContactListener.h"
#import "Building.h"

void ContactListener::BeginContact(b2Contact* contact)
{
    b2Body* bodyA = contact->GetFixtureA()->GetBody();
    b2Body* bodyB = contact->GetFixtureB()->GetBody();

    Building *buildA = (Building *)bodyA->GetUserData();
    Building *buildB = (Building *)bodyB->GetUserData();
    if (buildA.tag == 2) {
        NSLog(@"Collision with building");
    }
}

PROBLEM:
I don understand how get property from ContactListener

I tried to get it so:

if (buildA.tag == 2) {
            NSLog(@"Collision with building");
            NSLog(@"testProperty == %i", buildA.testProperty);
        }

But buildA.testProperty not work, and get error

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[CCSprite testProperty]: unrecognized selector sent to instance 0x434af0'

If your can explain my please how get property from this class. Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T18:58:42+00:00Added an answer on June 8, 2026 at 6:58 pm

    When I create body, I set into user data sprite.

    In the Building.h

    body->SetUserData(self);
    

    solved the problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been building some GATC tags for a newsletter campaign. When I set
I have a building environment where I add some prepending and appending lines to
I have been building a new application using my current understanding of domain driven
I have problems building a binary tree from the bottom up. THe input of
I have been building a game for a while (nearly done) - But the
So i have been building an AR engine that makes use of the magnetic
I'm just getting into using REST and have started building my first app following
I have been investigating building web parts for sharepoint 2010 and currently have a
Does anyone have instructions on building the opensource version of Qt? Now that the
I don't have any experience building software for Windows but I have experience with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.