sprite-kit

SKlabelNode custom font

点点圈 提交于 2020-01-13 20:32:27
问题 I know I can create a custom font using this code: [UIFont fontWithName:@"bebas-neue" size:10]; But if I want to create an SKLabelNode, how can I set this as the font? SKLabelNode only takes a string as the fontName. 回答1: The procedure is essentially the same as for UIFont . To do this from scratch, follow the same process as for adding a custom UIFont (described here), then just use: [SKLabelNode labelNodeWithFontNamed:@"Font Name Here"] 来源: https://stackoverflow.com/questions/21368283

Coordinate System in SpriteKit

断了今生、忘了曾经 提交于 2020-01-13 19:41:35
问题 I am quite confused with the spritekit coordinate system. I need clarification on two cases. Case 1: When a sprite node is added as child to the scene: SKSpriteNode * blueBall = [SKSpriteNode spriteNodeWithImageNamed:@"hRedBall.png"]; blueBall.name=@"blueball"; blueBall.size=CGSizeMake(75, 75); blueBall.position=point; //I am varying this point [self addChild:blueBall]; I have added the node at different points each time.These are the points I added the node at: (100x100)(200x200)(300x300)

SpriteKit. Stop rotate Texture with CameraNode

女生的网名这么多〃 提交于 2020-01-13 18:40:27
问题 I'm doing a little game where the car goes around a planet. The camera is always directed to the machine at an angle of 90 degrees from the planet. I encountered a problem that the texture of the planet rotates along with the camera. If the camera does not rotate, the texture is behaving as it should. How do I fix this? Create planet from beizerPath: planetTexture = SKTexture(imageNamed: "asanoha") planet = SKShapeNode(path: beizerPath.cgPath) planet.position = CGPoint(x: 0, y: 0) planet

How to detect a collision in sprite kit?

好久不见. 提交于 2020-01-13 18:01:46
问题 I am making a game in Sprite Kit and I have struggles with the collision detection between SpriteNodes, I've set a sprite node called sprite and a sprite node called platform. I want the sprite to stop falling when collided with the platform. This is what I have: SKSpriteNode *sprite = [SKSpriteNode spriteNodeWithImageNamed:@"bal.png"]; sprite.position = CGPointMake(self.frame.size.width/4 + arc4random() % ((int)self.frame.size.width/2), (self.frame.size.height/2 + arc4random() % ((int)self

How can I prevent SKAction sequence restarting after decoding?

隐身守侯 提交于 2020-01-13 16:20:26
问题 My app is a SpriteKit game with application state preservation and restoration. When application state is preserved, most of the nodes in my current SKScene are encoded. When a node running an SKAction is encoded and decoded, the action will restart from the beginning. This appears to be standard SpriteKit behavior. For me, this behavior is most noticeable for SKAction sequence . On decoding, the sequence restarts, no matter how many of its component actions have already completed. For

SKCropNode fails when I add extra SKNode children in hierarchy

大憨熊 提交于 2020-01-13 10:06:08
问题 Update: It looks like iOS 10 has fixed this issue. I upgraded to Swift 3 and Xcode 8 and everything is working as expected. I've run into this issue a couple times now and I can't tell if it's a bug in SKCropNode or if I'm just misusing it. Perhaps there's some bit of documentation I'm missing to explain why this is happening? I have a crop node with a 100x100 rectangle shape as the mask. If I place a blue circle inside it, it gets cropped properly. // Create a crope node with a small square.

SKCropNode fails when I add extra SKNode children in hierarchy

你离开我真会死。 提交于 2020-01-13 10:05:22
问题 Update: It looks like iOS 10 has fixed this issue. I upgraded to Swift 3 and Xcode 8 and everything is working as expected. I've run into this issue a couple times now and I can't tell if it's a bug in SKCropNode or if I'm just misusing it. Perhaps there's some bit of documentation I'm missing to explain why this is happening? I have a crop node with a 100x100 rectangle shape as the mask. If I place a blue circle inside it, it gets cropped properly. // Create a crope node with a small square.

SKShapeNode has unbounded memory growth

与世无争的帅哥 提交于 2020-01-13 09:58:08
问题 If I run this code in a SKScene sublass init method for (int i = 0; i < 100; i++) { SKShapeNode *shape = [SKShapeNode node]; shape.antialiased = NO; CGMutablePathRef path = CGPathCreateMutable(); CGPathAddEllipseInRect(path, NULL, CGRectMake(arc4random()%320, arc4random()%320, 10, 10)); shape.path = path; [shape setStrokeColor:[UIColor blackColor]]; CGPathRelease(path); [self addChild:shape]; [shape removeFromParent]; } and everytime I run this code in my SKView controlling controller SKView

SKShapeNode has unbounded memory growth

女生的网名这么多〃 提交于 2020-01-13 09:58:03
问题 If I run this code in a SKScene sublass init method for (int i = 0; i < 100; i++) { SKShapeNode *shape = [SKShapeNode node]; shape.antialiased = NO; CGMutablePathRef path = CGPathCreateMutable(); CGPathAddEllipseInRect(path, NULL, CGRectMake(arc4random()%320, arc4random()%320, 10, 10)); shape.path = path; [shape setStrokeColor:[UIColor blackColor]]; CGPathRelease(path); [self addChild:shape]; [shape removeFromParent]; } and everytime I run this code in my SKView controlling controller SKView

How do you use SKTextureFilteringNearest with SKTextureAtlas

随声附和 提交于 2020-01-13 08:24:10
问题 I seem to be having a problem using SKTextureAtlas and nearest neighbor filtering for textures. When I used the nearest neighbor filtering without SKTextureAtlas it works fine, but everything is just changed to linear filtering when I use an SKTextureAtlas. Code and Result Without SKTextureAtlas: SKTexture* texture = [SKTexture textureWithImageNamed:@"grass"]; texture.filteringMode = SKTextureFilteringNearest; SKSpriteNode* node = [SKSpriteNode spriteNodeWithTexture:texture size:CGSizeMake