skphysicsbody

SpriteKit Weird 'PKPhysicsBody' Crash

泪湿孤枕 提交于 2019-12-05 09:34:06
I am trying to implement a simple category for SKPhysicsBody that will allow me to apply 'perfect bouncing' to a physics body. What this will simply do is when perfectBouncing = YES the following will happen: restitution = 1.0 linearDamping = 0.0 friction = 0.0 However, when I try to use my implementation as shown below, I get a weird crash telling me that I can't send perfectBouncing messages to PKPhysicsBody , which is a class that I never refer to and doesn't exist in my project or to my knowledge in the SpriteKit SDK. And yes, the catagory is being imported. Crash Message -[PKPhysicsBody

swift sprite kit game when I shoot on a enemy sometimes the bullet goes trough the enemy, how can I fix this?

浪尽此生 提交于 2019-12-05 07:47:37
问题 I'm making a game in sprite kit (2D) . I have this code: meteor.physicsBody = SKPhysicsBody(rectangleOfSize: enemy.size) and I have a meteor image that you need to destroy but sometimes when I shoot on my device to the meteor the bullet goes through the meteor is this a bug or did I do something wrong? and How can I fix this issue? thanks for reading my problem, I hope someone can help me! if you don't understand my question plz comment what you don't understand. func fireBullet() { let

How to copy SKSpriteNode with SKPhysicsBody?

我怕爱的太早我们不能终老 提交于 2019-12-04 23:41:31
问题 I am curious about a situation that I came across today when trying to unarchive and copy a SKSpriteNode from one SKScene to another. In the output from the playground below you can see that both linearDamping and angularDamping or not being maintained after the copy (they seem to be dropping back to default values) // PLAYGROUND_SW1.2 - SKSpriteNode Copy import UIKit import SpriteKit // ORIGINAL let spriteNode = SKSpriteNode() spriteNode.name = "HAPPY_NODE" let size = CGSize(width: 55.0,

Can I move dynamic physics bodies using SKAction when only contact detection is needed?

ぃ、小莉子 提交于 2019-12-04 16:26:26
I am looking at tutorial where things are defined like this: planes are sprites with dynamic physics bodies plane moving is done with actions by following the path there is contact detection between bullet and plane bullet is sprite and it has physics body set to be static (which is little unusual in my opinion) Here is the link to tutorial for more information. Questions: When we use actions to move physicsBodies is there a difference how we set body's dynamic property? Because bullet is static but still there is no problem for movement. When we have situation like this, where we don't need

Is there a way to make a soft body with Spritekit using SKSpriteNode and PhysicsBody parameters?

这一生的挚爱 提交于 2019-12-04 14:46:15
I have the following sprite that falls to the bottom of the screen: // The View self.physicsBody = [SKPhysicsBody bodyWithEdgeLoopFromRect:self.frame]; self.physicsWorld.contactDelegate = self; // The Sprite SKSpriteNode *cube = [[SKSpriteNode alloc] initWithImageNamed:@"cube"]; [cube setPosition:CGPointMake(160,250); [self addChild:cube]; // The Physics cube.physicsBody = [SKPhysicsBody bodyWithRectangleOfSize:cube.frame.size]; cube.physicsBody.dynamic = YES; cube.physicsBody.affectedByGravity = YES; cube.physicsBody.mass = 0.02; Is there a way to make it so its sides are bulging when it hits

Giving physics to tiles of SKTileMapNode in Xcode 8

筅森魡賤 提交于 2019-12-04 13:06:42
问题 I am learning Swift, and as a project I am working on a tile based 2D game similar to super mario where my character will walk and jump on tiles. The latest version of Xcode and Sprite Kit give the ability to create a Tile Map directly in Xcode. In the presentation of the new Xcode and Sprite kit, the guy demonstrates a game similar to what i am working on. https://developer.apple.com/videos/play/wwdc2016/610/ (around the 20th minute). He mentions giving Tiles user data properties which i did

Swift SpriteKit edgeLoopFromRect Issue

痞子三分冷 提交于 2019-12-04 09:25:18
The following code recognizes the bottom and top edges of the scene and the ball bounces off as expected. However, the left and right edges of the scene are breached all the time. The ball goes off screen and then eventually returns back if enough force is applied. It is as if the edges of the scene are beyond the edges of the iphone simulator window. import SpriteKit class GameScene: SKScene { override func didMoveToView(view: SKView){ self.physicsBody = SKPhysicsBody(edgeLoopFromRect: self.frame) backgroundColor = UIColor.cyanColor() var ball = SKSpriteNode(imageNamed: "ball") ball.position

swift sprite kit game when I shoot on a enemy sometimes the bullet goes trough the enemy, how can I fix this?

纵然是瞬间 提交于 2019-12-03 23:07:12
I'm making a game in sprite kit (2D) . I have this code: meteor.physicsBody = SKPhysicsBody(rectangleOfSize: enemy.size) and I have a meteor image that you need to destroy but sometimes when I shoot on my device to the meteor the bullet goes through the meteor is this a bug or did I do something wrong? and How can I fix this issue? thanks for reading my problem, I hope someone can help me! if you don't understand my question plz comment what you don't understand. func fireBullet() { let bullet = SKSpriteNode(imageNamed: "bullet") bullet.name = "Bullet" bullet.setScale(2.9) bullet.position =

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

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-03 18:10:27
问题 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

How to copy SKSpriteNode with SKPhysicsBody?

走远了吗. 提交于 2019-12-03 14:17:01
I am curious about a situation that I came across today when trying to unarchive and copy a SKSpriteNode from one SKScene to another. In the output from the playground below you can see that both linearDamping and angularDamping or not being maintained after the copy (they seem to be dropping back to default values) // PLAYGROUND_SW1.2 - SKSpriteNode Copy import UIKit import SpriteKit // ORIGINAL let spriteNode = SKSpriteNode() spriteNode.name = "HAPPY_NODE" let size = CGSize(width: 55.0, height: 150.0) let physics = SKPhysicsBody(rectangleOfSize: size) physics.linearDamping = 0.123 physics