SpriteKit Joints on Mac OS X
SpriteKit Joints on Mac OS X
- Subject: SpriteKit Joints on Mac OS X
- From: Alexander Reichstadt <email@hidden>
- Date: Mon, 28 Apr 2014 10:53:09 +0200
Hi,
On Mac OS X using SKPhysicsJointPin gives me some problems:
- (void)pjoinBodyA:(NSString *)nameA andB:(NSString *)nameB
{
SKSpriteNode *bodyA = [self childNodeWithName:nameA];
SKSpriteNode *bodyB = [self childNodeWithName:nameB];
if (bodyA.position.x>bodyB.position.x){
bodyB = [self childNodeWithName:nameA];
bodyA = [self childNodeWithName:nameB];
}
CGPoint ap = CGPointMake(bodyB.frame.origin.x-1, bodyB.frame.origin.y);
NSLog(@"JOINING AB AT %@",NSStringFromPoint(ap));
SKPhysicsJointPin *j = [SKPhysicsJointPin jointWithBodyA:bodyA.physicsBody bodyB:bodyB.physicsBody anchor:ap];
[self.physicsWorld addJoint:j];
}
Now, if I create three bodies, coloring them and drawing paths on them with gravity turned on in my physics world, I can see them standing on the floor next to each other, exactly as added at the exact positions. As soon as I add a pin joint (or actually any kind of joint) they overlap looking like one single square.
When I then move one of the squares, it's not that the other joined squares remain in a static distance to the moved square and dangles along the pin-joint point, but instead it behaves like connected through some weird springy thing. If the first object gets moved more quickly, they both get totally lost in some erratic motion all over the screen.
I also tried to have them being joined only after positioning them exactly where they should be in the pjoin method, but that makes no difference.
I found this nice tutorial with all its code inside, but that does not work neither:
http://hub.ae/blog/2014/03/26/soft-body-physics-jellyusing-spritekit/
You can copy paste that code, adjust it to Mac OS X and the alleged jellyblob is just a bunch of dots and lines on the floor.
Take the same code and copy-paste it into the iOS Spritekit template and it works flawlessly exactly as described.
On Mac OS X and as for the other joints, they neither do what is described in their reference sections. The best results I achieved with a rope joint between two bodies, but make that more than two, it falls apart. Before wasting further time, are joints on Mac OS X SpriteKit a known issue at this time?
Thanks
Alex
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden