skphysicsbody

SKFieldNode magneticNode attracting forces

只谈情不闲聊 提交于 2019-11-30 07:25:00
I am currently working with the iOS 8 SpriteKit API's and am having a hard time creating an attractive magnetic force with SKFieldNode. I can create an opposing magnetic force just fine, however I can't reverse the field. Heres what I have currently: touchField = [SKFieldNode magneticField]; touchField.physicsBody = [SKPhysicsBody bodyWithCircleOfRadius:(self.frame.size.height/4 - 34)]; touchField.physicsBody.charge = 3; This particular field is supposed to be interactive with another SKSpriteNode. Electric and Magnetic fields are currently broken, as of iOS 8.1. They don't interact with the

Incorrect behaviour with SKPhysicsJointPin when shouldEnableLimits is true and lowerAngleLimit and upperAngleLimit set

心不动则不痛 提交于 2019-11-30 04:26:12
问题 I currently have a ragdoll figure, which consists of a parent node (with no physics bodies attached), and lots of child nodes which each consist of a circle body. The circles are connected to each other using an SKPhysicsJointPin between each circle, as so: Each SKPhysicsJointPin has shouldEnableLimits = true , and I currently use a value of -0.05 and 0.05 for lowerAngleLimit and upperAngleLimit respectively. This works pretty well and prevents the shape from deforming too much, except when

Sprite Kit - Apply Impulse to shoot projectile at character

有些话、适合烂在心里 提交于 2019-11-29 21:05:28
问题 I am developing a game using Sprite-Kit (Objective-C). It's a game where you control a bird in flight and arrows and other bad projectiles are shot at you from the right/top/bottom sides of the screen. I am using physics instead of an SKAction in order to accomplish this as I want it to seem as life-like as possible. So I know to use applyImpulse on the projectile to shoot it towards the bird, but what I am wondering is how can gaurantee that the projectile will be shot directly at the bird,

SpriteKit: How to create Basic Physics Joints

江枫思渺然 提交于 2019-11-29 18:11:37
问题 I am trying to create simple Joints between two SKPhysicsBodies. But, they are acting weirdly. I am well aware of the fact the anchor points should be on scene coordinate. Please have a look at the Source code attached. For Example this is how a fixed Joint results after attaching a small square on a rectangle. -(void)createFixedJointOnScene:(SKScene*)scene { //Adding Rectangle SKSpriteNode* backBone = [[SKSpriteNode alloc] initWithColor:[UIColor whiteColor] size:CGSizeMake(20, 200)];

Sprite Kit failing assertion: (typeA == b2_dynamicBody || typeB == b2_dynamicBody)

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-29 15:00:06
This was asked earlier , but the original asker didn't need to change the dynamic property so he answered his own question by unasking it. I'm using Sprite Kit in iOS7 and I'd like to be able to change an SKPhysicsBody's dynamic property at runtime. Originally I was changing that in my touchesBegan: method. Someone in the Apple Dev forum suggested moving the change to the didSimulatePhysics: method but that didn't help either. This code causes the error: -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { if (!heyWereSwappingDynamismHere) { heyWereSwappingDynamismHere = YES;

SKFieldNode magneticNode attracting forces

筅森魡賤 提交于 2019-11-29 09:36:55
问题 I am currently working with the iOS 8 SpriteKit API's and am having a hard time creating an attractive magnetic force with SKFieldNode. I can create an opposing magnetic force just fine, however I can't reverse the field. Heres what I have currently: touchField = [SKFieldNode magneticField]; touchField.physicsBody = [SKPhysicsBody bodyWithCircleOfRadius:(self.frame.size.height/4 - 34)]; touchField.physicsBody.charge = 3; This particular field is supposed to be interactive with another

SpriteKit SKPhysicsBody bodyWithTexture is Upside Down

不想你离开。 提交于 2019-11-29 04:30:32
Hi I'm trying to fix this bug with spritekit's physics shape appearing upside down. [SKPhysicsBody bodyWithTexture:monsterTexture size:monsterTexture.size] The first time the monster appears the phsyics body orientation is correct. But the second time and every time after that the monster appears it's physics body is inverted along the Y axis. See picture where skView.showsPhysics = true; so the physics shapes are displayed. The fact that it works correctly the first time makes me think maybe some property I'm not aware of is being modified or something. I thought of putting 2 physics blocks

SKPhysicsBody bodyWithPolygonFromPath memory leaks

a 夏天 提交于 2019-11-28 11:14:11
I have a strange memory leaks when creating Sprite Kit physics bodies with custom shapes. This is how my implementation looks: CGFloat offsetX = self.frame.size.width * self.anchorPoint.x; CGFloat offsetY = self.frame.size.height * self.anchorPoint.y; CGMutablePathRef path = CGPathCreateMutable(); CGPathMoveToPoint(path, NULL, 4 - offsetX, 3 - offsetY); CGPathAddLineToPoint(path, NULL, 66 - offsetX, 3 - offsetY); CGPathAddLineToPoint(path, NULL, 35 - offsetX, 57 - offsetY); CGPathCloseSubpath(path); self.physicsBody = [SKPhysicsBody bodyWithPolygonFromPath:path]; CGPathRelease(path);

Physicsbody doesn't adhere to node's anchor point

删除回忆录丶 提交于 2019-11-28 09:37:12
My scene has a bunch of rectangles with physics bodies that are the same size as the rectangle. I like to anchor all of my objects to CGPointZero, however I've noticed when I do that the physicsbody remains anchored in the middle. In other words, the position of my physics body is like 100 pixels lower and to the left of the visual representation. Here is a simple snippet of code: SKSpriteNode* square = [SKSpriteNode spriteNodeWithColor:[SKColor blackColor] size:CGSizeMake(width, height)]; square.anchorPoint = CGPointZero; //position based on bottom-left corner square.position = CGPointMake(x,

applyForce(0, 400) - SpriteKit inconsistency

爷,独闯天下 提交于 2019-11-28 06:56:31
So I have an object that has a physicsBody and gravity affects it. It is also dynamic. Currently, when the users touches the screen, I run the code: applyForce(0, 400) The object moves up about 200 and then falls back down due to gravity. This only happens some of the time. Other times, it results in the object only moving 50ish units in the Y direction. I can't find a pattern... I put my project on dropbox so it can be opened if anyone is willing to look at it. https://www.dropbox.com/sh/z0nt79pd0l5psfg/bJTbaS2JpY EDIT: It seems this happens when the player is bouncing off of the ground