Questions tagged [skphysicscontact]

A SKPhysicsContact object describes the contact between two physics bodies.

The SKPhysicsContact class is a member of the SpriteKit framework. It is used to describe a contact between two physical bodies in a physics world.

72 questions
0
votes
1 answer

Placing SKPhysicsContact within a GKComponent

At the moment, I use SKPhysicsContact to trigger a change in behaviour for my sprites, from within the GameScene. The problem is with each development, the game scene becomes longer and longer. Has anyone managed to make a GKComponent with…
Shane O'Seasnain
  • 3,534
  • 5
  • 24
  • 31
0
votes
1 answer

Detecting Physics Contact in Swift 2

I want to detect in my app a contact between two objects. I have an enum to define the different types: enum ColliderType: UInt32 { case Ball = 0b010 case Object = 0b001 case Gap = 0b100 } I also added SKPhysicsContactDelegate to my…
henrik-dmg
  • 1,448
  • 16
  • 23
0
votes
1 answer

SKPhysicsContactDelegate collision detection using Swift

I am trying to fix an issue I am having with the SKPhysicsContactDelegate collision detection. I have two nodes, nodeA and nodeB, nodeA is stationary on the screen while nodeB is able to be dragged around the screen by the users finger. nodeA needs…
BCRwar3
  • 45
  • 1
  • 11
0
votes
1 answer

Finding Nil value unwrapping an Optional - for no easily apparent reason

I understand that many post errors similar to this, but I feel this is an exceptional circumstance. As part of a tutorial I am working through the app runs fine for quite sometime, but then for no reason I can work out it crashes with the error…
Frankeex
  • 449
  • 3
  • 20
0
votes
0 answers

Very strange behaviour of SKPhysics

I have this code SKPhysicsBody *firstBody, *secondBody; if (contact.bodyA.categoryBitMask < contact.bodyB.categoryBitMask) { firstBody = contact.bodyA; secondBody = contact.bodyB; } else { firstBody = contact.bodyB; secondBody =…
0
votes
1 answer

SKPhysicsJointFixed in SpriteKit and Swift

I'm making a game in Sprite Kit and Swift and I have a Sprite at the bottom of the screen and falling Sprites from the top which I want to catch and stick to the Sprite at the bottom, so I'm trying to use SKPhysicsJointFixed but when the objects…
0
votes
1 answer

contact even if not directly on physicsbody

I've got a strange behavior of SKPhysicsbody. First let me show you my main-node: self.physicsWorld.contactDelegate = self self.physicsWorld.gravity = CGVectorMake(0, 0) self.physicsBody = SKPhysicsBody(rectangleOfSize:…
Christian
  • 22,585
  • 9
  • 80
  • 106
0
votes
2 answers

Overriding collisions in SpriteKit

I want to override collisions in SpriteKit. The idea is that I have a ball which bounces around the scene. When didBeginContact detects contact between an edge and the ball, I want the ball to rebound in a random direction and speed. import…
0
votes
0 answers

How to call method only once on first contact?

I have an issue where I have a game over/stop function: Hero.m +(id)hero//The hero { JBHero *_hero = [JBHero spriteNodeWithTexture:heroTexture1]; _hero.name = @"hero"; return _hero; } - (void)stop { self.physicsBody.contactTestBitMask =…
-1
votes
2 answers

Sprites not contacting properly

There's a ball and a paddle, the ball should be on the paddle and touching it but the ball never touches the paddle and stops before reaching the paddle, can anyone help me out? import SpriteKit class GameScene: SKScene ,SKPhysicsContactDelegate…
-3
votes
1 answer

Swift programming. Possible problem with SKPhysicscontact

I'm working on a project / game and I'm stuck at adding new enemies to the game and to program them. This is how my code looked before I started changing and only had one type of "alien". I want to create two new types, one that you lose 5 points…
-3
votes
2 answers

Successful Jump detection in sprite-kit

My game play is an animal jumping over holes. If it hits a hole, it loses life. But if it makes three successful jumps it unlocks an achievement. How do I detect a successful jump? I have the logic for detecting failed jumps using SKPhysics​Contact…
merloin
  • 31
  • 3
1 2 3 4
5