Physicsbody doesn't adhere to node's anchor point

前端 未结 7 1223
陌清茗
陌清茗 2020-12-09 15:09

My scene has a bunch of rectangles with physics bodies that are the same size as the rectangle. I like to anchor all of my objects to CGPointZero, however I\'ve noticed when

7条回答
  •  攒了一身酷
    2020-12-09 15:41

    You can use

          [SKPhysicsBody bodyWithRectangleOfSize:size center: center];
    
    
           CGPoint center = CGPointMake(size.width*(anchorPoint.x-0.5f), size.height*(0.5f-anchorPoint.y))
    

    should transform the bounding box according to the anchorPoint of the parents node

提交回复
热议问题