skphysicsbody

Issues with SKPhysicsBody from Texture

你。 提交于 2021-02-11 13:46:32
问题 I have searched around the internet / StackOverflow for the past few days without much success in finding an answer to a few questions that I believe are intertwined in some way. How do I prevent my game from freezing when it is rendering an SKPhysicsBody from a texture? Why are my physics bodies sometimes not created at all, and why are they sometimes the wrong shapes? Below is the code I am using to try and generate these pillars (image attached at the bottom of the post. There are roughly

How can I set a physicsbody to be properly centered?

情到浓时终转凉″ 提交于 2021-01-29 22:20:03
问题 Below is the code I use to create a red border in my scene. Well no matter how hard I try I can't get the border to fall straight down. It falls at a tilt. The commented lines are my attempts at trying to fix this problem. And below all that are two screen shots, one without physicsbody, and the other with, but no color so you can see the physicsbody debug lines. I should add that at this moment I am not doing any collision detection. The balls do have their own physics body, and I assume the

How can I set a physicsbody to be properly centered?

早过忘川 提交于 2021-01-29 19:47:02
问题 Below is the code I use to create a red border in my scene. Well no matter how hard I try I can't get the border to fall straight down. It falls at a tilt. The commented lines are my attempts at trying to fix this problem. And below all that are two screen shots, one without physicsbody, and the other with, but no color so you can see the physicsbody debug lines. I should add that at this moment I am not doing any collision detection. The balls do have their own physics body, and I assume the

Swift: No contact detection between nodes

♀尐吖头ヾ 提交于 2020-03-23 08:03:14
问题 Issue This is my code for my game. A brick falls and hits a side of a square. To differentiate what side is hit, four triangles are spawned that make the square. They are invisible from a low opacity. I am not receiving any contact between the brick node and the triangle node. The brick piece just falls right through the square. Any help? Game Code import SpriteKit class GameScene: SKScene { let basicTop = SKSpriteNode(imageNamed: "basic top"); let basicBottom = SKSpriteNode(imageNamed:

Swift: No contact detection between nodes

徘徊边缘 提交于 2020-03-23 08:03:10
问题 Issue This is my code for my game. A brick falls and hits a side of a square. To differentiate what side is hit, four triangles are spawned that make the square. They are invisible from a low opacity. I am not receiving any contact between the brick node and the triangle node. The brick piece just falls right through the square. Any help? Game Code import SpriteKit class GameScene: SKScene { let basicTop = SKSpriteNode(imageNamed: "basic top"); let basicBottom = SKSpriteNode(imageNamed:

how to set physics properties for a circle so it follows given path

拥有回忆 提交于 2020-02-23 09:31:07
问题 The movement of a physics body circle is too erratic for what I want to achieve. I would like to restrict it so it follows a certain path touching specific points (or a range of points) as shown in the image below. How can I set the physics properties to traverse a similar path? 回答1: how to set physics properties for a circle so it follows given path So essentially you are looking to move a node to a particular point using real-time motion. I have an answer here showing how to do this,

SpriteKit physics false positive?

徘徊边缘 提交于 2020-02-06 05:50:47
问题 The contact point provided by didBeginContact does not always rest in the paths that define the physics bodies involved in the collision. This behavior is most problematic in cases where the bodies never come into contact (if the circle node is 1px further right, the contact still happens though it is mathematically impossible.) In the image and program below, the rectangle has a width of 100px, but the contact point (shown in the output) is at 101.4550... import SpriteKit class GameScene:

bodyWithEdgeLoopFromRect not working in landscape

徘徊边缘 提交于 2020-01-24 06:03:46
问题 I'm just trying to set up a basic scene in landscape, with gravity, and having the scene in an edge loop. I set up the scene's physics body and the mainCharacter sprite physics body, here is my code: -(id)initWithSize:(CGSize)size { if (self = [super initWithSize:size]) { self.backgroundColor = [SKColor redColor]; [self setPhysicsBody:[SKPhysicsBody bodyWithEdgeLoopFromRect:[self frame]]]; } return self; } -(void)setupMain { if (!self.mainCharacter) { self.mainCharacter = [[SKSpriteNode alloc