@@ -731,6 +731,45 @@ -(void)testBodyTypeCollisions
731
731
[physicsNode onExit ];
732
732
}
733
733
734
+ -(void )testBodyEachCollisionPair
735
+ {
736
+ CCPhysicsNode *physicsNode = [CCPhysicsNode node ];
737
+ physicsNode.gravity = ccp (0 , -100 );
738
+
739
+ CCNode *node1 = [CCNode node ];
740
+ node1.physicsBody = [CCPhysicsBody bodyWithCircleOfRadius: 1.0 andCenter: CGPointZero];
741
+ node1.physicsBody .type = CCPhysicsBodyTypeStatic;
742
+ [physicsNode addChild: node1];
743
+
744
+ CCNode *node2 = [CCNode node ];
745
+ node2.position = ccp (0 , 10 );
746
+ node2.physicsBody = [CCPhysicsBody bodyWithCircleOfRadius: 1.0 andCenter: CGPointZero];
747
+ node2.physicsBody .type = CCPhysicsBodyTypeDynamic;
748
+ [physicsNode addChild: node2];
749
+
750
+ // Force entering the scene to set up the physics objects.
751
+ [physicsNode onEnter ];
752
+
753
+ // Step the physics for a while.
754
+ for (int i=0 ; i<100 ; i++){
755
+ [physicsNode fixedUpdate: 1.0 /100.0 ];
756
+ }
757
+
758
+ __block BOOL check = NO ;
759
+
760
+ [node1.physicsBody eachCollisionPair: ^(CCPhysicsCollisionPair *pair) {
761
+ CCPhysicsShape *a, *b; [pair shapeA: &a shapeB: &b];
762
+ check = (
763
+ (a.node == node1 && b.node == node2) ||
764
+ (b.node == node1 && a.node == node2)
765
+ );
766
+ }];
767
+
768
+ XCTAssert (check, @" The objects should have had a collision pair listed between them." );
769
+
770
+ [physicsNode onExit ];
771
+ }
772
+
734
773
// TODO
735
774
// * Check that body and shape settings are preserved through multiple add/remove cycles and are actually applied to the cpBody.
736
775
// * Check that changing properties before and after adding to an active physics node updates the properties correctly.
0 commit comments