0

I drew a circle in UIView with a help of UIBezierPath. Then I added gravity behavior to that view using UIGravityBehavior and collision behavior using UICollisionBehavior. When the circle collides with other objects this view bumps as square, but I want to work with this view in collisions as with a circle. How can I do it?

Screenshot provided

Andrew
  • 15,357
  • 6
  • 66
  • 101
  • 2
    Can you provide code that shows what you are describing? – Andrew May 13 '14 at 21:58
  • @SantaClaus I want to work with this view in gravity as with circle, but simulator works with it as with square - pic.twitter.com/OdoFNCyPHF – MrProgrammer May 13 '14 at 22:02
  • 1
    @MrProgrammer - You should click the **Edit** link and add the code to you question. Its OK to edit after posting to help explain your problem. Also, format the code you add. You can do that by highlighting the code, and then clicking the `{}` button in the editor. – jww May 13 '14 at 22:15
  • @MrProgrammer I added your provided screenshot to the question, along with some formatting and grammar corrections. It would still be nice to [edit] the question with the code pasted in. As @jww said, after pasting the code into the editor, highlight the code and click the `{}` button before saving your edits. – Andrew May 13 '14 at 22:22
  • 1
    You might have better luck doing something like this with SpriteKit. I haven’t used it, though, so I don’t know exactly how. – Zev Eisenberg May 13 '14 at 22:51
  • By the way, your `GameViewController` should declare that it conforms to `` to get rid of the warning from your screenshot. – Zev Eisenberg May 13 '14 at 22:52
  • @ZevEisenberg right you are, thank you) But, unfortunately, it doesn't solve my problem) – MrProgrammer May 13 '14 at 22:55

1 Answers1

1

You can’t use UIKit Dynamics to simulate a circle. It works with rectangular bodies only. You can add collision paths, but I think that is only for the reference frame. I recommend looking at SpriteKit’s SKPhysicsBody. Unfortunately, I haven’t used it, so I can’t provide a code sample.

Zev Eisenberg
  • 8,080
  • 5
  • 38
  • 82