sprite-kit

Game Center integration with Sprite Kit?

爷,独闯天下 提交于 2019-12-07 18:20:02
问题 How can I use Game Center or the GameKit Framework with a Sprite Kit Xcode template? In Sprite kit, it uses Scenes; but normally to view the leaderboards for example you need to "presentModalViewController" but that is not possible in SKView. And how can I authenticate the player and all that other fun stuff in iOS 6. Thanks in advance! 回答1: you can authenticate like this [[GKLocalPlayer localPlayer] authenticateWithCompletionHandler:^(NSError *error) { if (error == nil) { static_setEnable(

draw a straight line in swift 3 and core graphics

房东的猫 提交于 2019-12-07 18:08:14
问题 I'm trying to draw a single, straight line using core graphics and swift 3 However, when touchesmoved is called, it creates multiple lines instead of just a single line. Code used is below: import UIKit class ViewController: UIViewController { @IBOutlet weak var drawingPlace: UIImageView! var startTouch : CGPoint? var secondTouch : CGPoint? override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) { let touch = touches.first startTouch = touch?.location(in: drawingPlace) }

SKPhysicsBody with restitution 0 still bounces

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-07 17:35:25
问题 I'm am trying to drop the SKSpriteNode with constant speed and without bouncing. Here is the code I'm using: SKSpriteNode *floor = [SKSpriteNode spriteNodeWithColor:[UIColor clearColor] size:CGSizeMake(self.size.width, 1)]; floor.physicsBody = [SKPhysicsBody bodyWithRectangleOfSize:floor.size]; floor.physicsBody.restitution = 0.0f; floor.physicsBody.dynamic = NO; floor.physicsBody.allowsRotation = NO; SKSpriteNode* block = [SKSpriteNode spriteNodeWithTexture:[SKTexture textureWithImageNamed

SKSpriteNode : Handling Collision during SKAction

本小妞迷上赌 提交于 2019-12-07 17:00:42
问题 I'm making a little game, and I'm now stuck with the following problem. I'm running an action (followPath type) on a particular node : let followTrack: SKAction = SKAction.followPath(ballPath!.CGPath, duration: ACTION_SPEED) movingBall.runAction(followTrack) But during the animation, if the node collide with another one (like a wall for exemple), the animation stops and there is no collision animation. I tried some things like : func didBeginContact(contact: SKPhysicsContact) { var firstBody:

Why does [NSSet containsObject] fail for SKNode members in iOS8?

空扰寡人 提交于 2019-12-07 16:57:18
问题 Two objects are added to an NSSet , but when I check membership, I can't find one of them. The test code below worked fine in iOS7 but fails in iOS8. SKNode *changingNode = [SKNode node]; SKNode *unchangingNode = [SKNode node]; NSSet *nodes = [NSSet setWithObjects:unchangingNode, changingNode, nil]; changingNode.position = CGPointMake(1.0f, 1.0f); if ([nodes containsObject:changingNode]) { printf("found node\n"); } else { printf("could not find node\n"); } Output: could not find node What

Sprite Kit: A Lot of sprites (1000+) with Bit Blitting

若如初见. 提交于 2019-12-07 16:27:11
问题 I'm trying to create a scene with SpriteKit which has thousands of sprites (~500 - 2000). Each sprite is just a white pixel 1x1 - there's no need to even use textures for them. Adding this much sprites to the scene directly at once is impossible (or at least i think so). On iPhone 6 I end up with ~200 sprites added, then system ends the adding process because of memory and the rest of the sprites aren't added. I have found a clever solution to this called Bit Blitting where all the sprites

SpriteKit joint: follow the body

…衆ロ難τιáo~ 提交于 2019-12-07 16:11:26
I've been asked to simplify this question, so that's what I'm doing. I'm struggling in SpriteKit's physic joints (and possibly physic body properties). I tried every single subclass and many configurations but seams like nothing works or I'm doing something wrong. I'm developing Snake game. User controls head of snake which should move at constant speed ahead and user can turn it clockwise or anticlockwise. All the remaining snake's pieces should follow the head - they should travel exactly the same path that head was some time ago. I think for this game the Pin joint should be the answer,

Spritekit - Create a “wall”

北慕城南 提交于 2019-12-07 15:38:08
问题 I am wondering how it is possible to create a wall with spritekit. Something at an object cannot move past. I know that I can use this code: self.physicsBody = [SKPhysicsBody bodyWithEdgeLoopFromRect:self.frame]; ...but when I use that code I basically get a "floor" as well. I want objects to be able to pass through the bottom of the screen but not be able to leave the side. Thanks in advance for any help! Best Regards, Louis. 回答1: It sounds like you need 2 physics body, one for each side of

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

Memory Leak in Sprite Kit Application

好久不见. 提交于 2019-12-07 15:26:26
问题 I have a Sprite Kit game that I created in Xcode 5 and when profiling it for leaks using Instruments I see that there are indeed some leaks: The problem is that I can't tell where in my application this is coming from as the "Responsible Frame" column doesn't point me to anywhere in my application. How would one go about debugging/tracking the origins of this issue? Update #1 There is only one file in which I'm interacting w/ CGPath but I am calling CGPathRelease ... CGMutablePathRef path =