skphysicsworld

Can't change SKPhysicsJointLimit maxLength after adding the joint to SKPhysicsWorld in Sprite Kit

谁说我不能喝 提交于 2019-12-23 15:42:53
问题 So, I've created a ring of SKSpriteNodes which are essentially rectangles that are joined together using pin joints. I'd like to suspend this ring inside of an SKShapeNode circle. I have connected each of the nodes to the SKShapeNode using SKPhysicsJointLimit's. This all works fine, and I get the effect that I'm looking for if I set the maxLength to the "right" number, which I determine subjectively. I've stored all of the limit joints inside of an Array, so I can get easy access, and I've

didBeginContact not being called Swift

亡梦爱人 提交于 2019-12-23 03:05:17
问题 I am working on an app that when the central ball colour matches a smaller ball that is flying towards the central ball colour the player scores a point. So for this to work I need the didBeginContact function to call when the "enemy" and the "mainBall" collide. The only thing that is moving is the enemy ball as it flies towards the stationary mainBall I believe I have set the bit masks up correctly but the didBeginContact function is not being called. Can someone please help? Here is my code

iOS7 SKScene how to make a sprite bounce off the edge of the screen?

六眼飞鱼酱① 提交于 2019-12-22 09:22:13
问题 I'm building a game with balls bouncing within the iPad's screen. Similar to a Pong game. I see that SKScene's SKPhysicsWorld has gravity property, and also controls how objects collide with each other. Is there some way I can automatically detect if a sprite's edge has collided with the screen's edge, so it can bounce off that? Or do I need to write my own collision code? 回答1: You don't need to write much code to make the ball bounce off the edge of the screen. the physics environment can

Stop SKSpriteNode from slowing down

隐身守侯 提交于 2019-12-07 15:32:44
问题 I am trying to keep my SKSpriteNodes moving at a constant speed forever, even after collisions. I have set gravity to 0, friction to 0, and linear and angular dampening to zero, but the Sprites still slowly slow down to zero velocity. How can I keep them moving? Based on the answer below, this is what I have tried: EDIT This code below works! I just had to check if the nodes were going slower than the limit and speed them up. [self enumerateChildNodesWithName:kBallName usingBlock:^(SKNode

Stop SKSpriteNode from slowing down

…衆ロ難τιáo~ 提交于 2019-12-06 03:38:42
I am trying to keep my SKSpriteNodes moving at a constant speed forever, even after collisions. I have set gravity to 0, friction to 0, and linear and angular dampening to zero, but the Sprites still slowly slow down to zero velocity. How can I keep them moving? Based on the answer below, this is what I have tried: EDIT This code below works! I just had to check if the nodes were going slower than the limit and speed them up. [self enumerateChildNodesWithName:kBallName usingBlock:^(SKNode *node, BOOL *stop) { SKSpriteNode *ball = (SKSpriteNode *)node; if (ball.physicsBody.velocity.dx < 0) { if

iOS Swift didBeginContact not being called

早过忘川 提交于 2019-12-05 22:09:06
问题 I have been struggling for the past two days to get two SKSpriteNodes to register a collision and evoke didBegin#contact . I've set their bit masks ' categoryBitMask ', ' contactTestBitMask ' and ' collisionTestBitMask ' for both objects. I've also set the ' dynamic ' property for both to ' true ' initPhysics() seems to set up the physicsWorld okay. All I'm expecting is that didBegin#Contact is called, but it is not //Set up Physicsbody bit masks let playerCarBitMask: UInt32 = 0x1 << 1 let

iOS7 SKScene how to make a sprite bounce off the edge of the screen?

烂漫一生 提交于 2019-12-05 18:01:28
I'm building a game with balls bouncing within the iPad's screen. Similar to a Pong game. I see that SKScene's SKPhysicsWorld has gravity property, and also controls how objects collide with each other. Is there some way I can automatically detect if a sprite's edge has collided with the screen's edge, so it can bounce off that? Or do I need to write my own collision code? You don't need to write much code to make the ball bounce off the edge of the screen. the physics environment can handle all of the above, you just need to instantiate the sprites in the correct way. First, you will have to