Error Strange SpriteKit + UIDynamics

So, I am developing a game using SpriteKit. And to make the game more interesting, I decided to use UIDynamicAnimator to add some physics to the UIKit elements in my game. Everything works fine except for one serious problem. At that moment, when I select / initialize the UIDynamicAnimator as follows:

animator = [[UIDynamicAnimator alloc] initWithReferenceView:self.view];

The physical bodies in my game are fully compensated. Even if I do not specify a reference view, physics will still be biased.

What is strange is that I create a UIDynamicAnimator in a completely separate ViewController, so it doesn’t like that it uses the same reference view or something like that.

Update . Even the action of simply creating a UIDynamicItemBehavior:

UIDynamicBehavior* a = [[UIDynamicBehavior alloc] init];

ruined the physics of my scene.

I assume this is an internal error with the physics engine that separates SpriteKit and UIDynamics.

Anyone have any suggestions?

+3
source share
2 answers

Ok, I found a pretty hacky solution. All you have to do is use the UIDynamics interface before submitting your SKScene. For example, simply by running this single line of code before presenting your scene, you will remove the strange physical error caused by the simultaneous use of SpriteKit and UIDynamics at the same time:

UIDynamicBehavior* a = [[UIDynamicBehavior alloc] init];

, , . , , , - .

, UIDynamics UIView Animation , UIDynamics Framework.

IOS 8 doctordoder, iOS 8, .

+2

, iOS 9: @Epic Byte .

( initialize SpriteKit ..), , , .

allocation init UIDynamicAnimator SpriteKit physicsWorld, , gravity, -.

, physicsWorld ( ?) UIDynamicAnimator.

:

  • Alloc init UIDynamicAnimator asap , .

    [UIDynamicAnimator new]; didFinishLaunchingWithOptions

  • UIKit Dynamics SpriteKit
0

All Articles