Esempio n. 1
0
void Level3::contact_level(b2Contact* contact)
{
	Spy *spyA = spymanager->getChildByBody(contact->GetFixtureA()->GetBody());
	Spy *spyB = spymanager->getChildByBody(contact->GetFixtureB()->GetBody());
	if (spyA != nullptr && spyB != nullptr)
	{
		if (((spyA->getTag() == "dan") && (spyB->getTag() == "goal")))
		{
			b2JointEdge *joint = spyB->getBody()->GetJointList();
			if (joint != nullptr || joint != NULL)
			{
				b2Joint *joint_e = joint->joint;
				for (; joint_e != NULL; joint_e = joint_e->GetNext())
				{
					if (joint_e->GetUserData() == "pig_rope")
					{
						spyA->getSprite()->runAction(CallFuncN::create(CC_CALLBACK_0(Level3::doCallback, this, joint_e)));
						break;
					}
				}
			}
		}
		if ((spyB->getTag() == "dan") && (spyA->getTag() == "goal"))
		{
			b2JointEdge *joint = spyA->getBody()->GetJointList();
			if (joint != nullptr || joint != NULL)
			{
				b2Joint *joint_e = joint->joint;
				for (; joint_e != NULL; joint_e = joint_e->GetNext())
				{
					if (joint_e->GetUserData() == "pig_rope")
					{
						spyB->getSprite()->runAction(CallFuncN::create(CC_CALLBACK_0(Level3::doCallback, this, joint_e)));
						break;
					}
				}
			}
		}
	}

}