Leena
Leena

Reputation: 109

How to detect multiple static body in box2d

I have a some issue regarding multiple detection of static bodies.

How can i detect or differentiate multiple static bodies? In my game i am using tile map and create 3 objects in static body. How can i differentiate each other when collied with player sprite?

Thanks in advance

Upvotes: 1

Views: 142

Answers (1)

Guru
Guru

Reputation: 22042

You can do it in 2ways.

id obj1  = (id)bodyA->GetUserData();

if( ((CCSprite*)obj1).tag == kTagStaticBody1 ) //check ur sprite tag
{

}

//OR: For identification of class

id obj1  = (id)bodyA->GetUserData();

if([obj1 isKindOfClass:[MyActor class]])
{

}

Upvotes: 1

Related Questions