Reputation: 109
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
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