Physicsbody doesn't adhere to node's anchor point

前端 未结 7 1242
陌清茗
陌清茗 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:32

    I am using Swift but the SKPhysicsBody was kind of half width and height wrong. I am using anchor point(0,0). Then I used the method with rectangleOfSize, center :

    var cc = SKSpriteNode(color: UIColor.greenColor(), size: CGSizeMake(32, 64))
    cc.physicsBody = SKPhysicsBody(rectangleOfSize: cc.size, center: CGPointMake(32/2, 64/2))
    

    I hope it works for you too guys...thanks !

提交回复
热议问题