3

So I'm 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 within my game. Everything works great except there is one major problem. The moment I alloc/init a UIDynamicAnimator like so:

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

The physics bodies in my game get completely offset. Even if I don't specify a reference view the physics still get offset.

What's strange is that i'm creating the UIDynamicAnimator in a completely separate ViewController so it's not like it's sharing the same reference view or something like that.

Update: Even the act of simply creating a UIDynamicItemBehavior like so:

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

messes up my scene's physics.

I'm assuming this is an internal bug with the physics engine that SpriteKit and UIDynamics share.

Anyone have any suggestions?

4

2 に答える 2

0

iOS 9 では、@Epic Byte のソリューションはまだ半分の回避策を実行していることに注意してください。

物理エンジンをより早く(initialize SpriteKitゲームなどの前に)開始しますが、残念ながらそれを混同します.

とはゲーム中にallocationを引き起こし、そのプロパティは異なる動作をします。initUIDynamicAnimatorSpriteKitphysicsWorldgravity

また、初期化physicsWorld中に短時間(エンジンの切り替え?) が削除されたようです。UIDynamicAnimator

結論:

  • できるだけ早く割り当てて初期UIDynamicAnimator化し、物理世界を別の方法で処理します。

    [UIDynamicAnimator new];デリゲートでdidFinishLaunchingWithOptions

また

  • UIKit Dynamics と SpriteKit を混在させないでください
于 2016-01-12T11:33:59.623 に答える