@@ -395,6 +395,87 @@ -(void)testAffectedByGravity
395
395
XCTAssertTrue (node2.position .y == 0.0 , @" " );
396
396
}
397
397
398
+ -(void )testAllowsRotation
399
+ {
400
+ CCPhysicsNode *physicsNode = [CCPhysicsNode node ];
401
+ [physicsNode onEnter ];
402
+
403
+ {
404
+ // Regular body.
405
+ CCNode *node = [CCNode node ];
406
+ node.physicsBody = [CCPhysicsBody bodyWithCircleOfRadius: 1.0 andCenter: CGPointZero];
407
+ XCTAssert (node.physicsBody .allowsRotation == YES , @" " );
408
+
409
+ [physicsNode addChild: node];
410
+ XCTAssert (node.physicsBody .allowsRotation == YES , @" " );
411
+
412
+ XCTAssert (node.physicsBody .body .moment < INFINITY, @" " );
413
+ }{
414
+ // Set before adding.
415
+ CCNode *node = [CCNode node ];
416
+ node.physicsBody = [CCPhysicsBody bodyWithCircleOfRadius: 1.0 andCenter: CGPointZero];
417
+ node.physicsBody .allowsRotation = NO ;
418
+ XCTAssert (node.physicsBody .allowsRotation == NO , @" " );
419
+
420
+ [physicsNode addChild: node];
421
+ XCTAssert (node.physicsBody .allowsRotation == NO , @" " );
422
+
423
+ XCTAssert (node.physicsBody .body .moment == INFINITY, @" " );
424
+ }{
425
+ // Set after adding.
426
+ CCNode *node = [CCNode node ];
427
+ node.physicsBody = [CCPhysicsBody bodyWithCircleOfRadius: 1.0 andCenter: CGPointZero];
428
+ XCTAssert (node.physicsBody .allowsRotation == YES , @" " );
429
+
430
+ [physicsNode addChild: node];
431
+ XCTAssert (node.physicsBody .allowsRotation == YES , @" " );
432
+ node.physicsBody .allowsRotation = NO ;
433
+ XCTAssert (node.physicsBody .allowsRotation == NO , @" " );
434
+
435
+ XCTAssert (node.physicsBody .body .moment == INFINITY, @" " );
436
+ }{
437
+ // Set and reverted before adding.
438
+ CCNode *node = [CCNode node ];
439
+ node.physicsBody = [CCPhysicsBody bodyWithCircleOfRadius: 1.0 andCenter: CGPointZero];
440
+ node.physicsBody .allowsRotation = NO ;
441
+ XCTAssert (node.physicsBody .allowsRotation == NO , @" " );
442
+ node.physicsBody .allowsRotation = YES ;
443
+ XCTAssert (node.physicsBody .allowsRotation == YES , @" " );
444
+
445
+ [physicsNode addChild: node];
446
+ XCTAssert (node.physicsBody .allowsRotation == YES , @" " );
447
+
448
+ XCTAssert (node.physicsBody .body .moment < INFINITY, @" " );
449
+ }{
450
+ // Set before and reverted after adding.
451
+ CCNode *node = [CCNode node ];
452
+ node.physicsBody = [CCPhysicsBody bodyWithCircleOfRadius: 1.0 andCenter: CGPointZero];
453
+ node.physicsBody .allowsRotation = NO ;
454
+ XCTAssert (node.physicsBody .allowsRotation == NO , @" " );
455
+
456
+ [physicsNode addChild: node];
457
+ XCTAssert (node.physicsBody .allowsRotation == NO , @" " );
458
+ node.physicsBody .allowsRotation = YES ;
459
+ XCTAssert (node.physicsBody .allowsRotation == YES , @" " );
460
+
461
+ XCTAssert (node.physicsBody .body .moment < INFINITY, @" " );
462
+ }{
463
+ // Set reverted after adding.
464
+ CCNode *node = [CCNode node ];
465
+ node.physicsBody = [CCPhysicsBody bodyWithCircleOfRadius: 1.0 andCenter: CGPointZero];
466
+ XCTAssert (node.physicsBody .allowsRotation == YES , @" " );
467
+
468
+ [physicsNode addChild: node];
469
+ XCTAssert (node.physicsBody .allowsRotation == YES , @" " );
470
+ node.physicsBody .allowsRotation = NO ;
471
+ XCTAssert (node.physicsBody .allowsRotation == NO , @" " );
472
+ node.physicsBody .allowsRotation = YES ;
473
+ XCTAssert (node.physicsBody .allowsRotation == YES , @" " );
474
+
475
+ XCTAssert (node.physicsBody .body .moment < INFINITY, @" " );
476
+ }
477
+ }
478
+
398
479
-(void )testBodyType
399
480
{
400
481
CGPoint points[3 ] = {};
0 commit comments