Reputation: 157
I'm making another Swift game. The floor is the desert. This floor is a physicsbody (sprite kit) based on it's image texture. I want to know the height of the floor based on a specific x point (by instance the middle of the screen). If i use floor.size.height it gets the height like it is a rectangle (in other words, the maximum height possible). I want to get this Y point to make the player move upon it with physicsbody.
can anyone help with it?
Upvotes: 2
Views: 87
Reputation: 35392
You have no need. Just because you are using the physics, it's simply stating the floor with isDynamic = false
and players with isDynamic = true
and the other parameters as for example:
enum CollisionTypes: UInt32 {
case player1 = 1
case player2 = 2
case floor = 4
}
floor.physicsBody?.categoryBitMask = CollisionTypes.floor.rawValue
floor.physicsBody?.contactTestBitMask = CollisionTypes.player.rawValue
floor.physicsBody?.collisionBitMask = 0
player1.physicsBody?.categoryBitMask = CollisionTypes.player1.rawValue
player1.physicsBody?.contactTestBitMask = CollisionTypes.floor.rawValue
player1.physicsBody?.collisionBitMask = CollisionTypes.floor.rawValue
This is only a point to start so hope it helps you.
Upvotes: 1