You can iterate through all bodies in the world and check whether you have touched a particular body.
You can get all the userdata from the current body
The userdata contains the width, height, sprite etc.
Just Log the userdata in the current body to see all these.

 for (b2Body* b = world->GetBodyList(); b; b = b->GetNext())
  b2Fixture *bf = b->GetFixtureList(); // Get the fixture of current body.
  CCSprite *temp_sprite =(CCSprite *) b->GetUserData();// Got the sprite in that body.
  if(temp_sprite!=NULL){  // Checking if the body has a sprite.

   if (bf->TestPoint(locationWorld))
    NSLog(@"Hooray I touched the body");

    if (temp_sprite.tag==10)
      //do something…..



Leave a Reply

Your email address will not be published. Required fields are marked *




Theme by HermesThemes

Copyright © 2018 CoderzHeaven. All Rights Reserved

Please wait...

Subscribe to our newsletter

Want to be notified when our article is published? Enter your email address and name below to be the first to know.