-1

When I set physicsBody to image with full circle it works fine! LIKE :

sprite.physicsBody = [SKPhysicsBody bodyWithTexture:sprite.texture size:sprite.size];

http://upload.wikimedia.org/wikipedia/commons/thumb/a/a0/Circle_-_black_simple.svg/220px-Circle_-_black_simple.svg.png

but how to set physicsBody if i have dotted image like :

http://www.i2symbol.com/images/symbols/geometry/dotted_circle_u25CC_icon_256x256.png

CodeSmile
  • 64,284
  • 20
  • 132
  • 217
Sambha
  • 1
  • 4
  • possible duplicate of [SpriteKit's SKPhysicsBody with polygon helper tool](http://stackoverflow.com/questions/19040144/spritekits-skphysicsbody-with-polygon-helper-tool) – Vlad Z. Feb 01 '15 at 05:53
  • link in that accepted answer is not available. – Sambha Feb 01 '15 at 05:55
  • looks like site is down, you can try this editor - http://adriancooney.ie/SKImport/Editor/ – Vlad Z. Feb 01 '15 at 05:59

1 Answers1

0

this will give you what you want. just need to add graphics. you might also want to add them to a parent sprite. copy and paste it to check it out, then tweak it for your needs. hope it helps :)

let centerPoint = CGPoint(x: self.size.width/2, y: self.size.height/2)

for i in 1...8 {

    let circleSection = SKSpriteNode(color: SKColor.redColor(), size: CGSize(width: 30, height: 10))
    circleSection.physicsBody = SKPhysicsBody(rectangleOfSize: circleSection.size)

    let angle = CGFloat(M_PI_4) * CGFloat(i)
    let distFromCtr = CGFloat(100)
    var angleToPt = CGPoint(
        x: cos(angle) * distFromCtr,
        y: sin(angle) * distFromCtr
    )

    angleToPt.x += centerPoint.x
    angleToPt.y += centerPoint.y

    circleSection.position = angleToPt
    circleSection.zRotation = angle + CGFloat(M_PI_2)
    self.addChild(circleSection)
}
hamobi
  • 7,940
  • 4
  • 35
  • 64