Ejemplo n.º 1
0
		protected void OnEvent(CCEventCustom eventC)
		{

			CCPhysicsContact contact = (CCPhysicsContact)eventC.UserData;
			// PhysicsContact) contact = dynamic_cast<PhysicsContact*>(event);


			if (contact == null)
			{
				return;
			}

			switch (contact.GetEventCode())
			{
				case EventCode.BEGIN:
					{
						bool ret = true;

						if (onContactBegin != null
							&& HitTest(contact.GetShapeA(), contact.GetShapeB()))
						{
							contact.GenerateContactData();
							ret = onContactBegin(contact);
						}

						contact.SetResult(ret);
						break;
					}
				case EventCode.PRESOLVE:
					{
						bool ret = true;

						if (onContactPreSolve != null
							&& HitTest(contact.GetShapeA(), contact.GetShapeB()))
						{
							CCPhysicsContactPreSolve solve = new CCPhysicsContactPreSolve(contact._contactInfo);
							contact.GenerateContactData();

							ret = onContactPreSolve(contact, solve);
						}

						contact.SetResult(ret);
						break;
					}
				case EventCode.POSTSOLVE:
					{
						if (onContactPostSolve != null
							&& HitTest(contact.GetShapeA(), contact.GetShapeB()))
						{
							CCPhysicsContactPostSolve solve = new CCPhysicsContactPostSolve(contact._contactInfo);
							onContactPostSolve(contact, solve);
						}
						break;
					}
				case EventCode.SEPERATE:
					{
						if (onContactSeperate != null
							&& HitTest(contact.GetShapeA(), contact.GetShapeB()))
						{
							onContactSeperate(contact);
						}
						break;
					}
				default:
					break;
			}

		}
Ejemplo n.º 2
0
        protected void OnEvent(CCEventCustom eventC)
        {
            CCPhysicsContact contact = (CCPhysicsContact)eventC.UserData;

            // PhysicsContact) contact = dynamic_cast<PhysicsContact*>(event);


            if (contact == null)
            {
                return;
            }

            switch (contact.GetEventCode())
            {
            case EventCode.BEGIN:
            {
                bool ret = true;

                if (onContactBegin != null &&
                    HitTest(contact.GetShapeA(), contact.GetShapeB()))
                {
                    contact.GenerateContactData();
                    ret = onContactBegin(contact);
                }

                contact.SetResult(ret);
                break;
            }

            case EventCode.PRESOLVE:
            {
                bool ret = true;

                if (onContactPreSolve != null &&
                    HitTest(contact.GetShapeA(), contact.GetShapeB()))
                {
                    CCPhysicsContactPreSolve solve = new CCPhysicsContactPreSolve(contact._contactInfo);
                    contact.GenerateContactData();

                    ret = onContactPreSolve(contact, solve);
                }

                contact.SetResult(ret);
                break;
            }

            case EventCode.POSTSOLVE:
            {
                if (onContactPostSolve != null &&
                    HitTest(contact.GetShapeA(), contact.GetShapeB()))
                {
                    CCPhysicsContactPostSolve solve = new CCPhysicsContactPostSolve(contact._contactInfo);
                    onContactPostSolve(contact, solve);
                }
                break;
            }

            case EventCode.SEPERATE:
            {
                if (onContactSeperate != null &&
                    HitTest(contact.GetShapeA(), contact.GetShapeB()))
                {
                    onContactSeperate(contact);
                }
                break;
            }

            default:
                break;
            }
        }