Domanda

I'm developing a game project with some friends.

We started making it with Xcode 5 for iOS 7.0.

The game begins at the first touch. Our character drops from the sky and you can start jumping with him.

Everything was working fine, until my friend zip the project and send to me. I opened it, and tried to run on simulator. All the scene is created, as on my friend's machine, but and I tap. The game crashes.

The error message that I get is:

Assertion failed: (area > 1.19209290e-7F), function ComputeMass, file /SourceCache/PhysicsKit_Sim/PhysicsKit-6.5.4/PhysicsKit/Box2D/Collision/Shapes/b2PolygonShape.cpp, line 395.

So, I looked what was different, and realized that I ran it on iOS 7.1, changed it to 7.0 and everything was normal once again.

But, now I have a game that can't be played on 7.1. I'm just started to learn sprite-kit, so... I don't know what I could do to change it.

UITouch *t = [touches anyObject];

int forca = [t locationInView:self.view].y;

[self.player pular:abs( ((forca/40) -8)*15 )];

[self.physicsWorld removeAllJoints];
self.jogoAtivo = TRUE;
self.player.personagem.physicsBody.dynamic = YES; //<-Acuses to be the error
[[self floor] setMovingEnable];

And in the mainthread, [PKPhysicsBody setDynamic:]:

PhysicsKit`-[PKPhysicsBody setDynamic:]:
0x9533e7e:  pushl  %ebp
0x9533e7f:  movl   %esp, %ebp
0x9533e81:  pushl  %esi
0x9533e82:  subl   $0x14, %esp
0x9533e85:  calll  0x9533e8a                 ; -[PKPhysicsBody setDynamic:] + 12
0x9533e8a:  popl   %ecx
0x9533e8b:  movl   0x8(%ebp), %eax
0x9533e8e:  cmpb   $0x0, 0x10(%ebp)
0x9533e92:  je     0x9533ea9                 ; -[PKPhysicsBody setDynamic:] + 43
0x9533e94:  movl   0x4316e(%ecx), %edx
0x9533e9a:  movl   (%eax,%edx), %edx
0x9533e9d:  movl   0x4316a(%ecx), %esi
0x9533ea3:  movl   %edx, 0x10(%esi,%eax)
0x9533ea7:  jmp    0x9533eb7                 ; -[PKPhysicsBody setDynamic:] + 57
0x9533ea9:  movl   0x4316a(%ecx), %edx
0x9533eaf:  movl   $0x0, 0x10(%edx,%eax)
0x9533eb7:  movl   0x43172(%ecx), %edx
0x9533ebd:  movl   (%eax,%edx), %edx
0x9533ec0:  testl  %edx, %edx
0x9533ec2:  je     0x9533eda                 ; -[PKPhysicsBody setDynamic:] + 92
0x9533ec4:  movl   0x4316a(%ecx), %ecx
0x9533eca:  movl   0x10(%ecx,%eax), %eax
0x9533ece:  movl   %eax, 0x4(%esp)
0x9533ed2:  movl   %edx, (%esp)
0x9533ed5:  calll  0x954a2b4                 ; b2Body::SetType(b2BodyType)
0x9533eda:  addl   $0x14, %esp      // Green Line "Thread 1:signal SIGABRT
0x9533edd:  popl   %esi
0x9533ede:  popl   %ebp
0x9533edf:  ret    

Edit:

So, with @LearnCocos2D comment about the area, I had another look at my code.

When I init my character, I use:

self.personagem.xScale = -self.personagem.xScale;

to flip horizontally my character sprite.

I took it off and my code works now.

I'm assuming that the negative number to flip the sprite is causing a conflict with the mass calculation.

My workaround: flip and save another image with photoshop.

È stato utile?

Soluzione

(area > 1.19209290e-7F), function ComputeMass

This seems to indicate that the area of a polygon is too large. My guess is this is happening because of a polygon with clockwise vertex winding, or perhaps even one that is not convex.

Verify that all polygon bodies (ie the ones created with a custom CGPath) use appropriate shapes. The shape's points must be in counter-clockwise winding, and the polygon itself must be convex.

Also there's I believe a 12-point maximum limit for polygon shapes, though if you exceeded that it would probably assert elsewhere.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top